API Reference
Generate Recipe
Generate a recipe based on a prompt and preferences.
POST
/
v1
/
recipes
/
generate
Generate Recipe
curl --request POST \
--url https://api.mrcook.app/v1/recipes/generate \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"prompt": "Cheesburger with Bacon",
"language": "en",
"preference": "<string>"
}
'import requests
url = "https://api.mrcook.app/v1/recipes/generate"
payload = {
"prompt": "Cheesburger with Bacon",
"language": "en",
"preference": "<string>"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({prompt: 'Cheesburger with Bacon', language: 'en', preference: '<string>'})
};
fetch('https://api.mrcook.app/v1/recipes/generate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mrcook.app/v1/recipes/generate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'prompt' => 'Cheesburger with Bacon',
'language' => 'en',
'preference' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.mrcook.app/v1/recipes/generate"
payload := strings.NewReader("{\n \"prompt\": \"Cheesburger with Bacon\",\n \"language\": \"en\",\n \"preference\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.mrcook.app/v1/recipes/generate")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"Cheesburger with Bacon\",\n \"language\": \"en\",\n \"preference\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mrcook.app/v1/recipes/generate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"Cheesburger with Bacon\",\n \"language\": \"en\",\n \"preference\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"id": "018ff556-a36a-7cb8-95a1-a2ac02da3e93",
"title": "Spicy Bacon Cheddar Cheeseburger with Pickles",
"ingredients": [
"500 grams ground beef",
"4 slices bacon",
"4 slices cheddar cheese",
"4 hamburger buns",
"4 tablespoons mayonnaise",
"4 leaves lettuce",
"1 tomato, sliced",
"8 slices pickles",
"..."
],
"instructions": [
"Season the ground beef with salt, pepper, and cayenne pepper or hot sauce. Mix well until evenly distributed.",
"Form the beef into 4 patties, slightly larger than the buns.",
"...",
"Cover with the top bun and serve immediately."
],
"description": "Add a spicy kick to the classic American cheeseburger by introducing some heat to the flavors. This burger features a juicy beef patty with a melted cheddar cheese and crispy bacon, combined with a spicy twist to elevate the taste.",
"servings": "4 servings",
"preparationTime": 15,
"cookingTime": 15,
"cuisine": "American",
"language": "en"
}
}{
"code": "UNAUTHORIZED",
"message": "Invalid or missing API key. Learn more: https://docs.mrcook.app/business-api/api-key"
}{
"code": "INSUFFICIENT_CREDITS",
"message": "Insufficient credits. Please purchase more credits: https://docs.mrcook.app/business-api/pricing"
}{
"code": "FORBIDDEN",
"message": "You don't have permission to access this resource."
}{
"code": "TOO_MANY_REQUESTS",
"message": "Rate limit exceeded. Please contact support if you need a higher limit."
}{
"code": "GENERATION_FAILED",
"message": "Failed to generate the recipe"
}Authorizations
How to get your API key: https://docs.mrcook.app/business-api/api-key
Body
application/json
The recipe prompt. This can either be a recipe name, description or a list of ingredients. The more details you provide, the better the recipe will be.
Required string length:
1 - 2500Example:
"Cheesburger with Bacon"
The language to generate the recipe in
Available options:
en, de, es, fr, pt-BR, ru, nl, it, nb, sv, tr, da Example:
"en"
Optional dietary preferences (e.g. 'vegetarian', 'vegan', 'gluten-free', 'dairy-free')
⌘I
Generate Recipe
curl --request POST \
--url https://api.mrcook.app/v1/recipes/generate \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"prompt": "Cheesburger with Bacon",
"language": "en",
"preference": "<string>"
}
'import requests
url = "https://api.mrcook.app/v1/recipes/generate"
payload = {
"prompt": "Cheesburger with Bacon",
"language": "en",
"preference": "<string>"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({prompt: 'Cheesburger with Bacon', language: 'en', preference: '<string>'})
};
fetch('https://api.mrcook.app/v1/recipes/generate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mrcook.app/v1/recipes/generate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'prompt' => 'Cheesburger with Bacon',
'language' => 'en',
'preference' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.mrcook.app/v1/recipes/generate"
payload := strings.NewReader("{\n \"prompt\": \"Cheesburger with Bacon\",\n \"language\": \"en\",\n \"preference\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.mrcook.app/v1/recipes/generate")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"Cheesburger with Bacon\",\n \"language\": \"en\",\n \"preference\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mrcook.app/v1/recipes/generate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"Cheesburger with Bacon\",\n \"language\": \"en\",\n \"preference\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"id": "018ff556-a36a-7cb8-95a1-a2ac02da3e93",
"title": "Spicy Bacon Cheddar Cheeseburger with Pickles",
"ingredients": [
"500 grams ground beef",
"4 slices bacon",
"4 slices cheddar cheese",
"4 hamburger buns",
"4 tablespoons mayonnaise",
"4 leaves lettuce",
"1 tomato, sliced",
"8 slices pickles",
"..."
],
"instructions": [
"Season the ground beef with salt, pepper, and cayenne pepper or hot sauce. Mix well until evenly distributed.",
"Form the beef into 4 patties, slightly larger than the buns.",
"...",
"Cover with the top bun and serve immediately."
],
"description": "Add a spicy kick to the classic American cheeseburger by introducing some heat to the flavors. This burger features a juicy beef patty with a melted cheddar cheese and crispy bacon, combined with a spicy twist to elevate the taste.",
"servings": "4 servings",
"preparationTime": 15,
"cookingTime": 15,
"cuisine": "American",
"language": "en"
}
}{
"code": "UNAUTHORIZED",
"message": "Invalid or missing API key. Learn more: https://docs.mrcook.app/business-api/api-key"
}{
"code": "INSUFFICIENT_CREDITS",
"message": "Insufficient credits. Please purchase more credits: https://docs.mrcook.app/business-api/pricing"
}{
"code": "FORBIDDEN",
"message": "You don't have permission to access this resource."
}{
"code": "TOO_MANY_REQUESTS",
"message": "Rate limit exceeded. Please contact support if you need a higher limit."
}{
"code": "GENERATION_FAILED",
"message": "Failed to generate the recipe"
}