Skip to main content
POST
/
v1
/
images
/
generations
curl --request POST \
  --url https://toapis.com/v1/images/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "flux-2-flex",
    "prompt": "A cute orange cat sunbathing on a windowsill",
    "size": "1:1",
    "metadata": {
      "resolution": "1K"
    }
  }'
{
  "id": "task_img_abc123def456",
  "object": "generation.task",
  "model": "flux-2-flex",
  "status": "queued",
  "progress": 0,
  "created_at": 1703884800,
  "metadata": {}
}
  • Flux 2.0 image generation model
  • Choose flux-2-flex (faster, for quick iteration) or flux-2-pro (higher quality, better details) via the model parameter
  • Supports text-to-image and image-to-image, up to 8 reference images
  • Billed by resolution (1K/2K)
  • Async task mode, returns task_id for querying results
Important Change: For better performance and cost control, we no longer support passing base64 image data directly in image_urls. Please use the Upload Image API first to upload images and get URLs, then call this endpoint.

Authorization

Authorization
string
required
All endpoints require Bearer Token authenticationGet your API Key: Visit the API Key Management Page to get your API KeyAdd to request header:
Authorization: Bearer YOUR_API_KEY

Request Parameters

model
string
required
Image generation model nameOptions:
  • flux-2-flex - Faster, suitable for quick iteration
  • flux-2-pro - Higher quality, better details
prompt
string
required
Text description for image generation
size
string
default:"1:1"
Image aspect ratioSupported aspect ratios:
  • 1:1 - Square (default)
  • 4:3 / 3:4 - Traditional display ratio
  • 16:9 / 9:16 - Widescreen/portrait
  • 3:2 / 2:3 - Standard photo
image_urls
string[]
Reference image URL array for image-to-image⚠️ URL format only (base64 not supported)
  • Publicly accessible image URL (http:// or https://)
  • Use the Upload Image API to upload local images and get URLs
Limits:
  • Maximum 8 reference images
metadata
object
Metadata parameters for additional configuration options

Response

id
string
Unique task identifier for querying task status
object
string
Object type, fixed as generation.task
model
string
Model name used for generation
status
string
Task status
  • queued - Waiting to be processed
  • in_progress - Processing
  • completed - Successfully completed
  • failed - Failed
progress
integer
Task progress percentage (0-100)
created_at
integer
Task creation timestamp (Unix timestamp)
metadata
object
Task metadata

Use Cases

Case 1: Text-to-Image (Quick Iteration)

{
  "model": "flux-2-flex",
  "prompt": "A cute orange cat sunbathing on a windowsill",
  "size": "1:1",
  "metadata": {
    "resolution": "1K"
  }
}

Case 2: Text-to-Image (High Quality Output)

{
  "model": "flux-2-pro",
  "prompt": "Future city skyline, neon lights, cyberpunk style, cinematic quality",
  "size": "16:9",
  "metadata": {
    "resolution": "2K"
  }
}

Case 3: Image-to-Image (Multiple Reference Images)

{
  "model": "flux-2-pro",
  "prompt": "Keep character style, generate a scene of running in the forest",
  "size": "1:1",
  "image_urls": [
    "https://example.com/ref1.jpg",
    "https://example.com/ref2.jpg"
  ],
  "metadata": {
    "resolution": "2K"
  }
}

Case 4: Portrait Poster

{
  "model": "flux-2-flex",
  "prompt": "Concert poster, minimalist style, dark background",
  "size": "9:16",
  "metadata": {
    "resolution": "1K"
  }
}
Query Task ResultsImage generation is an async task. After submission, a task ID is returned. Use the Get Task Status endpoint to query generation progress and results.
curl --request POST \
  --url https://toapis.com/v1/images/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "flux-2-flex",
    "prompt": "A cute orange cat sunbathing on a windowsill",
    "size": "1:1",
    "metadata": {
      "resolution": "1K"
    }
  }'
{
  "id": "task_img_abc123def456",
  "object": "generation.task",
  "model": "flux-2-flex",
  "status": "queued",
  "progress": 0,
  "created_at": 1703884800,
  "metadata": {}
}