Docs / Generate

Generate Endpoint

Create recipes programmatically from structured inputs with USDA-verified nutrition.

POST /api/v1/generate Requires authentication

Overview

The Generate endpoint creates brand-new recipes from structured constraints. You provide the recipe title, key ingredients, 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

Generated recipes are validated against your input constraints. The recipe title, cuisine, difficulty, and equipment must match what you requested. If validation fails, an error is returned and the request does not count against your limits.

Rate Limits

Generate requests have separate daily and monthly limits from regular API requests:

Plan Daily Limit Monthly Limit
Free 0 0
Hobby ($9/mo) 1 25
Starter ($59/mo) 5 100
Pro ($199/mo) 10 250

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
title Required string Recipe name. Max 80 characters. The generated recipe must match this title.
key_ingredients Required string[] Main ingredients to include. 1-16 items, each max 80 characters. All must be matchable to USDA nutrition data.
cuisine Required string Cuisine type (e.g., "Italian", "Mexican", "Japanese"). Max 60 characters.
difficulty Required enum One of: Easy, Intermediate, Advanced, Professional
equipment Required string[] Required cooking equipment. 1-10 items, each max 80 characters. Generated recipe must include all specified equipment.
time Required integer Target total cooking time in minutes. Range: 5-720 (12 hours).
notes Optional 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:

calories protein_g carbohydrates_g fat_g saturated_fat_g trans_fat_g monounsaturated_fat_g polyunsaturated_fat_g fiber_g sugar_g sodium_mg cholesterol_mg potassium_mg calcium_mg iron_mg magnesium_mg phosphorus_mg zinc_mg vitamin_a_mcg vitamin_c_mg vitamin_d_mcg vitamin_e_mg vitamin_k_mcg vitamin_b6_mg vitamin_b12_mcg thiamin_mg riboflavin_mg niacin_mg folate_mcg water_g alcohol_g caffeine_mg

Usage 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 didn't match constraints (title, cuisine, difficulty, or equipment mismatch).
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.

Ready to Generate Recipes?

Get your API key and start creating recipes programmatically.

Get API Key