Generate Endpoint
Create recipes programmatically from structured inputs with USDA-verified nutrition.
POST /api/v1/generateRequires authenticationOverview
The Generate endpoint creates brand-new recipes from structured constraints. You provide a recipe title and key ingredients, then optionally guide cuisine, difficulty, equipment, and target cooking time. The API generates a complete recipe with:
- ✓Full structured ingredients with quantities, units, and substitutions
- ✓Step-by-step instructions with temperatures, durations, and doneness cues
- ✓32 USDA-verified nutrition values per serving
- ✓Dietary flags, storage instructions, troubleshooting tips, and chef notes
Important
The request body is validated before a generate credit is consumed. After validation succeeds, generation and nutrition matching run on demand. Optional constraints guide the model, but minor title, cuisine, difficulty, or equipment variations are treated as soft warnings rather than hard failures.
Rate Limits
Generate requests have separate daily and monthly limits from regular API requests:
| Plan | Daily Limit | Monthly Limit |
|---|---|---|
| Free | 1 | 10 |
| Indie ($29/mo) | 10 | 150 |
| Growth ($99/mo) | 25 | 500 |
| Scale ($299/mo) | 50 | 1,200 |
| Enterprise ($4,999/mo) | 100 | 2,000 |
Per-minute rate limits also apply. If exceeded, you'll receive a 429 response.
Request Schema
Send a POST request with a JSON body containing the following fields:
| Field | Type | Description |
|---|---|---|
titleRequired | string | Recipe name or concept. Max 80 characters. |
key_ingredientsRequired | string[] | Main ingredients to include. 1-16 items, each max 80 characters. All must be matchable to USDA nutrition data. |
cuisineOptional | string | Optional cuisine type (e.g., "Italian", "Mexican", "Japanese"). Max 60 characters. |
difficultyOptional | enum | Optional. One of: Easy, Intermediate, Advanced, Professional |
equipmentOptional | string[] | Optional available equipment. 1-10 items, each max 80 characters. |
timeOptional | integer | Optional target total cooking time in minutes. Range: 5-720 (12 hours). |
notesOptional | string | Additional instructions, preferences, or constraints. Max 500 characters. |
Example Request
{
"title": "Lemon Herb Roasted Chicken",
"key_ingredients": [
"whole chicken",
"lemon",
"garlic",
"rosemary",
"thyme",
"olive oil",
"butter"
],
"cuisine": "Mediterranean",
"difficulty": "Intermediate",
"equipment": [
"roasting pan",
"meat thermometer"
],
"time": 90,
"notes": "Crispy skin is essential. Include a pan sauce from drippings."
}Response Schema
On success (201 Created), the response contains the full recipe and usage information:
Top-Level Response
| Field | Type | Description |
|---|---|---|
data | Recipe | The complete generated recipe object. |
usage | Usage | Your remaining generate credits. |
Recipe Object
| Field | Type | Description |
|---|---|---|
id | string | Unique UUID for this recipe. |
name | string | Recipe name (matches your input title). |
description | string | Brief description of the recipe. |
category | string | Recipe category (e.g., "Dinner", "Dessert"). |
cuisine | string | Cuisine type (matches your input). |
difficulty | string | Difficulty level (matches your input). |
tags | string[] | Descriptive tags for the recipe. |
meta | Meta | Timing and serving information. |
dietary | Dietary | Dietary flags and allergen warnings. |
storage | Storage | Storage and reheating instructions. |
equipment | Equipment[] | Required cooking equipment. |
ingredients | IngredientGroup[] | Ingredients grouped by category. |
instructions | Instruction[] | Step-by-step cooking instructions. |
troubleshooting | Troubleshooting[] | Common problems and solutions. |
chef_notes | string[] | Professional tips and insights. |
cultural_context | string | null | Historical or cultural background. |
nutrition | Nutrition | 32 nutrition values per serving. |
Meta Object
| Field | Type | Description |
|---|---|---|
active_time | string | Hands-on cooking time. ISO 8601 duration (e.g., "PT45M" = 45 minutes). |
passive_time | string | Waiting/resting time. ISO 8601 duration. |
total_time | string | Total time from start to finish. ISO 8601 duration. |
overnight_required | boolean | Whether the recipe requires overnight preparation. |
yields | string | Human-readable yield (e.g., "4 servings", "12 cookies"). |
yield_count | number | Numeric yield for calculations. |
serving_size_g | number | null | Serving size in grams. |
Equipment Object
| Field | Type | Description |
|---|---|---|
name | string | Equipment name. |
required | boolean | Whether this equipment is required. |
alternative | string | null | Alternative equipment if available. |
IngredientGroup Object
| Field | Type | Description |
|---|---|---|
group_name | string | Group name (e.g., "Main", "Sauce", "Garnish"). |
items | Ingredient[] | Ingredients in this group. |
Ingredient Object
| Field | Type | Description |
|---|---|---|
name | string | Ingredient name. |
quantity | number | null | Numeric quantity. |
unit | string | null | Unit of measurement (e.g., "g", "cups", "tbsp"). |
preparation | string | null | Preparation method (e.g., "diced", "minced"). |
notes | string | null | Additional notes. |
substitutions | string[] | Possible substitutions. |
ingredient_id | string | null | UUID from our ingredients database. |
nutrition_source | string | null | Source of nutrition data (e.g., "USDA FoodData Central"). |
Instruction Object
| Field | Type | Description |
|---|---|---|
step_number | number | Step number (1-indexed). |
phase | string | Cooking phase: "prep", "cook", "assemble", or "finish". |
text | string | Human-readable instruction text. |
structured | StructuredStep | null | Machine-readable step data. |
tips | string[] | Tips for this step. |
StructuredStep Object
| Field | Type | Description |
|---|---|---|
action | string | Action verb (e.g., "ROAST", "MIX", "SLICE", "SIMMER"). |
temperature | object | null | Contains celsius and fahrenheit values. |
duration | string | null | Step duration. ISO 8601 duration. |
doneness_cues | object | null | Contains visual and tactile cues. |
Nutrition Object (32 nutrients)
| Field | Type | Description |
|---|---|---|
per_serving | object | All nutrition values are per single serving. |
sources | string[] | Data sources (typically ["USDA FoodData Central"]). |
per_serving fields:
caloriesprotein_gcarbohydrates_gfat_gsaturated_fat_gtrans_fat_gmonounsaturated_fat_gpolyunsaturated_fat_gfiber_gsugar_gsodium_mgcholesterol_mgpotassium_mgcalcium_mgiron_mgmagnesium_mgphosphorus_mgzinc_mgvitamin_a_mcgvitamin_c_mgvitamin_d_mcgvitamin_e_mgvitamin_k_mcgvitamin_b6_mgvitamin_b12_mcgthiamin_mgriboflavin_mgniacin_mgfolate_mcgwater_galcohol_gcaffeine_mgUsage Object
| Field | Type | Description |
|---|---|---|
daily_remaining | number | Generate credits remaining today. |
daily_limit | number | Your daily generate limit. |
monthly_remaining | number | Generate credits remaining this month. |
monthly_limit | number | Your monthly generate limit. |
Full Example
Request
curl -X POST https://recipe-api.com/api/v1/generate \
-H "Content-Type: application/json" \
-H "X-API-Key: rapi_your_key" \
-d '{
"title": "Garlic Butter Shrimp Pasta",
"key_ingredients": ["shrimp", "linguine", "garlic", "butter", "white wine", "parsley", "lemon"],
"cuisine": "Italian",
"difficulty": "Easy",
"equipment": ["large pot", "skillet"],
"time": 30,
"notes": "Quick weeknight dinner. Should be garlicky and buttery."
}'Response (201 Created)
{
"data": {
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"name": "Garlic Butter Shrimp Pasta",
"description": "A quick and elegant pasta dish featuring succulent shrimp tossed in a rich garlic butter sauce with white wine and fresh herbs.",
"category": "Dinner",
"cuisine": "Italian",
"difficulty": "Easy",
"tags": ["seafood", "pasta", "quick", "weeknight"],
"meta": {
"active_time": "PT25M",
"passive_time": "PT5M",
"total_time": "PT30M",
"overnight_required": false,
"yields": "4 servings",
"yield_count": 4,
"serving_size_g": 350
},
"dietary": {
"flags": [],
"not_suitable_for": ["Shellfish allergy", "Dairy allergy"]
},
"storage": {
"refrigerator": { "duration": "P2D", "notes": "Store pasta and shrimp separately" },
"freezer": null,
"reheating": "Reheat gently in a skillet with a splash of water",
"does_not_keep": false
},
"equipment": [
{ "name": "Large pot", "required": true, "alternative": null },
{ "name": "Skillet", "required": true, "alternative": "Saute pan" }
],
"ingredients": [
{
"group_name": "Main",
"items": [
{
"name": "linguine",
"quantity": 400,
"unit": "g",
"preparation": null,
"notes": null,
"substitutions": ["spaghetti", "fettuccine"],
"ingredient_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"nutrition_source": "USDA FoodData Central"
},
{
"name": "large shrimp",
"quantity": 500,
"unit": "g",
"preparation": "peeled and deveined",
"notes": "About 24 shrimp",
"substitutions": ["prawns"],
"ingredient_id": "c9bf9e57-1685-4c89-bafb-ff5af830be8a",
"nutrition_source": "USDA FoodData Central"
},
{
"name": "garlic",
"quantity": 6,
"unit": "cloves",
"preparation": "minced",
"notes": null,
"substitutions": [],
"ingredient_id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
"nutrition_source": "USDA FoodData Central"
},
{
"name": "unsalted butter",
"quantity": 60,
"unit": "g",
"preparation": null,
"notes": null,
"substitutions": ["olive oil for dairy-free"],
"ingredient_id": "550e8400-e29b-41d4-a716-446655440000",
"nutrition_source": "USDA FoodData Central"
}
]
}
],
"instructions": [
{
"step_number": 1,
"phase": "prep",
"text": "Bring a large pot of salted water to a boil. Cook linguine according to package directions until al dente. Reserve 1 cup pasta water before draining.",
"structured": {
"action": "BOIL",
"temperature": null,
"duration": "PT10M",
"doneness_cues": {
"visual": null,
"tactile": "Pasta should be tender but firm when bitten"
}
},
"tips": ["Salt the water generously - it should taste like the sea"]
},
{
"step_number": 2,
"phase": "cook",
"text": "In a large skillet, melt butter over medium-high heat. Add shrimp in a single layer and cook until pink on one side, about 2 minutes. Flip and cook 1 minute more. Remove to a plate.",
"structured": {
"action": "SAUTE",
"temperature": { "celsius": 190, "fahrenheit": 375 },
"duration": "PT3M",
"doneness_cues": {
"visual": "Shrimp turn pink and opaque",
"tactile": "Firm but springy"
}
},
"tips": ["Don't overcrowd the pan or shrimp will steam instead of sear"]
}
],
"troubleshooting": [
{
"symptom": "Shrimp are rubbery",
"likely_cause": "Overcooked",
"prevention": "Remove shrimp as soon as they turn pink",
"fix": "Cannot be fixed once overcooked"
}
],
"chef_notes": [
"The pasta water is key - its starch helps create a silky sauce",
"Add the garlic after the shrimp to prevent burning"
],
"cultural_context": "This dish draws from Italian-American cuisine, combining the simplicity of aglio e olio with the richness of scampi.",
"nutrition": {
"per_serving": {
"calories": 542,
"protein_g": 32.5,
"carbohydrates_g": 58.2,
"fat_g": 18.4,
"saturated_fat_g": 9.1,
"trans_fat_g": 0.5,
"fiber_g": 2.8,
"sugar_g": 2.1,
"sodium_mg": 485,
"cholesterol_mg": 215,
"...": "(32 total nutrients)"
},
"sources": ["USDA FoodData Central"]
}
},
"usage": {
"daily_remaining": 4,
"daily_limit": 5,
"monthly_remaining": 95,
"monthly_limit": 100
}
}Error Codes
| Code | HTTP | Description |
|---|---|---|
BAD_REQUEST | 400 | Invalid input. Missing required fields or invalid values. |
UNAUTHORIZED | 401 | Missing or invalid API key. |
GENERATE_LIMIT_EXCEEDED | 429 | Daily or monthly generate limit reached. Upgrade for more. |
RATE_LIMITED | 429 | Per-minute rate limit exceeded. Wait and retry. |
INVALID_RECIPE_OUTPUT | 502 | Generated recipe did not match the required schema. |
NUTRITION_MATCH_INCOMPLETE | 422 | One or more ingredients couldn't be matched to nutrition data. |
GENERATION_FAILED | 500 | Internal generation error. Retry the request. |
DATABASE_ERROR | 500 | Failed to store recipe. Retry the request. |
Image Generation
Generate photorealistic food photography for any recipe using AI.
POST /api/v1/image-generatePricing
Image generation uses a credit pack model, purchased separately from your API plan.
| Pack | Price | Rate Limit | Managed in |
|---|---|---|---|
| 500 image credits | $125 one-time | 1 per minute | Dashboard |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
recipe_id | UUID | Yes | ID of a public recipe to photograph |
aspect_ratio | string | No | 1:1, 3:4, 4:3 (default), 9:16, 16:9 |
Example Request
curl -X POST https://recipe-api.com/api/v1/image-generate \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"recipe_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"aspect_ratio": "4:3"
}'Response (200 OK)
Returns raw JPEG image bytes (Content-Type: image/jpeg). You are responsible for storing the image.
Response headers:
| Header | Description |
|---|---|
X-Credits-Remaining | Credits remaining after this request |
X-Credits-Total | Total credits purchased |
X-Recipe-Id | Recipe UUID |
X-Aspect-Ratio | Aspect ratio used |
X-Model | AI model used |
Cache-Control | no-store — image is not cached server-side |
Example: Save to File
curl -X POST https://recipe-api.com/api/v1/image-generate \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"recipe_id": "a1b2c3d4-..."}' \
--output recipe-photo.jpegError Codes
| Code | HTTP | Description |
|---|---|---|
NO_IMAGE_CREDITS | 403 | No credits remaining. Purchase a credit pack. |
BAD_REQUEST | 400 | Invalid recipe_id or JSON body. |
NOT_FOUND | 404 | Recipe not found or not public. |
RATE_LIMITED | 429 | 1 image per minute limit exceeded. Check Retry-After header. |
IMAGE_GENERATION_TIMEOUT | 504 | AI model timed out (30s). Retry the request. |
IMAGE_GENERATION_FAILED | 502 | AI model error. Retry the request. |
Ready to Generate Recipes?
Get your API key and start creating recipes programmatically.
Get API Key