Generate high-quality images using our AI models.

Endpoint Details

/api/images/generate
Generate an image from a text prompt

Request Format

Headers

Content-Type
string
required
Must be set to application/json
x-api-key
string
required
Your API key

Body Parameters

prompt
string
required
The text description of the image you want to generate
model
string
The model to use for generation. Defaults to black-forest-labs/FLUX.1-schnell
options
object
Additional generation options

Example Request

{
  "prompt": "Your image description",
  "model": "black-forest-labs/FLUX.1-schnell",
  "options": {
    "steps": 4
  }
}

Response Format

{
  "url": "/api/images/filename.jpg",
  "data": [
    {
      "url": "/api/images/filename.jpg",
      "index": 0
    }
  ],
  "model": "black-forest-labs/FLUX.1-schnell",
  "timings": {}
}

Image Serving

Endpoint

/api/images/:filename
Retrieve a generated image
  • No authentication required
  • Returns the image file directly
  • Images are available immediately after generation

Caching

  • Generated images are cached for 1 hour
  • Cache key is based on prompt, model, and options
  • Images are stored locally and served via public endpoint

Error Scenarios

  • 400: Missing or invalid prompt
  • 401: Missing API key
  • 403: Invalid API key
  • 404: Image not found (for serving endpoint)
  • 429: Rate limit exceeded
  • 500: Internal server error

Error Response Example

{
  "error": {
    "message": "Error description",
    "code": 400
  }
}
In development mode, you’ll receive additional error details:
{
  "error": {
    "message": "Error description",
    "code": 400,
    "detail": "Detailed error message",
    "stack": "Error stack trace"
  }
}