Cookest
Backend APIsEndpoints

Image Generation

Async App API endpoints for generating recipe hero and step images through the Python image service

Image Generation

These endpoints live on the App API and require a JWT. The App API proxies requests to the Python image-generation microservice configured at IMAGE_GEN_URL and adds IMAGE_GEN_TOKEN server-side when present.

Image generation will not work unless the Python microservice is running and reachable at IMAGE_GEN_URL.

POST /api/image-gen/recipes/:id/steps/batch

Generate images for all recipe steps.

MethodPathAuth
POST/api/image-gen/recipes/:id/steps/batchJWT Bearer

Request body

{
  "style": "watercolor"
}

Response 200 OK

{
  "job_id": "img_batch_123",
  "status": "pending"
}

POST /api/image-gen/recipes/:id/steps/:n

Generate an image for a single recipe step.

MethodPathAuth
POST/api/image-gen/recipes/:id/steps/:nJWT Bearer

Request body

{
  "step_index": 2,
  "description": "Whisk the eggs with parmesan until smooth.",
  "style": "editorial food photography"
}

Response 200 OK

{
  "job_id": "img_step_456",
  "status": "pending"
}

POST /api/image-gen/recipes/:id/hero

Generate a hero image for the recipe.

MethodPathAuth
POST/api/image-gen/recipes/:id/heroJWT Bearer

Request body

{
  "title": "Frittata al Parmigiano",
  "description": "A fluffy baked egg dish with parmesan and herbs.",
  "style": "bright studio lighting"
}

Response 200 OK

{
  "job_id": "img_hero_789",
  "status": "pending"
}

GET /api/image-gen/jobs/:job_id

Poll an async image-generation job.

MethodPathAuth
GET/api/image-gen/jobs/:job_idJWT Bearer

Response 200 OK

{
  "job_id": "img_step_456",
  "status": "done",
  "result_url": "https://cdn.cookest.app/generated/img_step_456.png",
  "error": null
}
FieldTypeNotes
job_idstringStable job handle returned by the POST route
status"pending" | "running" | "done" | "failed"Current job state
result_urlstring | nullPresent once generation succeeds
errorstring | nullPresent when generation fails

All three POST routes are asynchronous. Start the job first, then poll /api/image-gen/jobs/{job_id} until it reaches done or failed.

On this page