Recipe API
Docs/Generate

Generate Endpoint

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

POST /api/v1/generateRequires authentication

Overview

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:

PlanDaily LimitMonthly Limit
Free110
Indie ($29/mo)10150
Growth ($99/mo)25500
Scale ($299/mo)501,200
Enterprise ($4,999/mo)1002,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:

FieldTypeDescription
titleRequiredstringRecipe name or concept. Max 80 characters.
key_ingredientsRequiredstring[]Main ingredients to include. 1-16 items, each max 80 characters. All must be matchable to USDA nutrition data.
cuisineOptionalstringOptional cuisine type (e.g., "Italian", "Mexican", "Japanese"). Max 60 characters.
difficultyOptionalenumOptional. One of: Easy, Intermediate, Advanced, Professional
equipmentOptionalstring[]Optional available equipment. 1-10 items, each max 80 characters.
timeOptionalintegerOptional target total cooking time in minutes. Range: 5-720 (12 hours).
notesOptionalstringAdditional 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

FieldTypeDescription
dataRecipeThe complete generated recipe object.
usageUsageYour remaining generate credits.

Recipe Object

FieldTypeDescription
idstringUnique UUID for this recipe.
namestringRecipe name (matches your input title).
descriptionstringBrief description of the recipe.
categorystringRecipe category (e.g., "Dinner", "Dessert").
cuisinestringCuisine type (matches your input).
difficultystringDifficulty level (matches your input).
tagsstring[]Descriptive tags for the recipe.
metaMetaTiming and serving information.
dietaryDietaryDietary flags and allergen warnings.
storageStorageStorage and reheating instructions.
equipmentEquipment[]Required cooking equipment.
ingredientsIngredientGroup[]Ingredients grouped by category.
instructionsInstruction[]Step-by-step cooking instructions.
troubleshootingTroubleshooting[]Common problems and solutions.
chef_notesstring[]Professional tips and insights.
cultural_contextstring | nullHistorical or cultural background.
nutritionNutrition32 nutrition values per serving.

Meta Object

FieldTypeDescription
active_timestringHands-on cooking time. ISO 8601 duration (e.g., "PT45M" = 45 minutes).
passive_timestringWaiting/resting time. ISO 8601 duration.
total_timestringTotal time from start to finish. ISO 8601 duration.
overnight_requiredbooleanWhether the recipe requires overnight preparation.
yieldsstringHuman-readable yield (e.g., "4 servings", "12 cookies").
yield_countnumberNumeric yield for calculations.
serving_size_gnumber | nullServing size in grams.

Equipment Object

FieldTypeDescription
namestringEquipment name.
requiredbooleanWhether this equipment is required.
alternativestring | nullAlternative equipment if available.

IngredientGroup Object

FieldTypeDescription
group_namestringGroup name (e.g., "Main", "Sauce", "Garnish").
itemsIngredient[]Ingredients in this group.

Ingredient Object

FieldTypeDescription
namestringIngredient name.
quantitynumber | nullNumeric quantity.
unitstring | nullUnit of measurement (e.g., "g", "cups", "tbsp").
preparationstring | nullPreparation method (e.g., "diced", "minced").
notesstring | nullAdditional notes.
substitutionsstring[]Possible substitutions.
ingredient_idstring | nullUUID from our ingredients database.
nutrition_sourcestring | nullSource of nutrition data (e.g., "USDA FoodData Central").

Instruction Object

FieldTypeDescription
step_numbernumberStep number (1-indexed).
phasestringCooking phase: "prep", "cook", "assemble", or "finish".
textstringHuman-readable instruction text.
structuredStructuredStep | nullMachine-readable step data.
tipsstring[]Tips for this step.

StructuredStep Object

FieldTypeDescription
actionstringAction verb (e.g., "ROAST", "MIX", "SLICE", "SIMMER").
temperatureobject | nullContains celsius and fahrenheit values.
durationstring | nullStep duration. ISO 8601 duration.
doneness_cuesobject | nullContains visual and tactile cues.

Nutrition Object (32 nutrients)

FieldTypeDescription
per_servingobjectAll nutrition values are per single serving.
sourcesstring[]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_mg

Usage Object

FieldTypeDescription
daily_remainingnumberGenerate credits remaining today.
daily_limitnumberYour daily generate limit.
monthly_remainingnumberGenerate credits remaining this month.
monthly_limitnumberYour 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

CodeHTTPDescription
BAD_REQUEST400Invalid input. Missing required fields or invalid values.
UNAUTHORIZED401Missing or invalid API key.
GENERATE_LIMIT_EXCEEDED429Daily or monthly generate limit reached. Upgrade for more.
RATE_LIMITED429Per-minute rate limit exceeded. Wait and retry.
INVALID_RECIPE_OUTPUT502Generated recipe did not match the required schema.
NUTRITION_MATCH_INCOMPLETE422One or more ingredients couldn't be matched to nutrition data.
GENERATION_FAILED500Internal generation error. Retry the request.
DATABASE_ERROR500Failed to store recipe. Retry the request.

Image Generation

Generate photorealistic food photography for any recipe using AI.

POST /api/v1/image-generate

Pricing

Image generation uses a credit pack model, purchased separately from your API plan.

PackPriceRate LimitManaged in
500 image credits$125 one-time1 per minuteDashboard

Request Body

FieldTypeRequiredDescription
recipe_idUUIDYesID of a public recipe to photograph
aspect_ratiostringNo1: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:

HeaderDescription
X-Credits-RemainingCredits remaining after this request
X-Credits-TotalTotal credits purchased
X-Recipe-IdRecipe UUID
X-Aspect-RatioAspect ratio used
X-ModelAI model used
Cache-Controlno-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.jpeg

Error Codes

CodeHTTPDescription
NO_IMAGE_CREDITS403No credits remaining. Purchase a credit pack.
BAD_REQUEST400Invalid recipe_id or JSON body.
NOT_FOUND404Recipe not found or not public.
RATE_LIMITED4291 image per minute limit exceeded. Check Retry-After header.
IMAGE_GENERATION_TIMEOUT504AI model timed out (30s). Retry the request.
IMAGE_GENERATION_FAILED502AI model error. Retry the request.

Ready to Generate Recipes?

Get your API key and start creating recipes programmatically.

Get API Key