Skip to main content
POST
/
v1
/
async
/
images
/
generations
Create async image generation
curl --request POST \
  --url http://localhost:8080/v1/async/images/generations \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "<string>",
  "prompt": "<string>",
  "n": 5,
  "size": "256x256",
  "quality": "auto",
  "style": "natural",
  "response_format": "url",
  "background": "transparent",
  "moderation": "low",
  "partial_images": 1,
  "output_compression": 50,
  "output_format": "png",
  "user": "<string>",
  "seed": 123,
  "negative_prompt": "<string>",
  "num_inference_steps": 123,
  "stream": false,
  "fallbacks": [
    {
      "provider": "openai",
      "model": "<string>"
    }
  ]
}
'
{
  "id": "<string>",
  "status": "pending",
  "created_at": "2023-11-07T05:31:56Z",
  "expires_at": "2023-11-07T05:31:56Z",
  "completed_at": "2023-11-07T05:31:56Z",
  "status_code": 123,
  "result": "<unknown>",
  "error": {
    "event_id": "<string>",
    "type": "<string>",
    "is_bifrost_error": true,
    "status_code": 123,
    "error": {
      "type": "<string>",
      "code": "<string>",
      "message": "<string>",
      "param": "<string>",
      "event_id": "<string>"
    },
    "extra_fields": {
      "provider": "openai",
      "model_requested": "<string>",
      "request_type": "<string>"
    }
  }
}

Headers

x-bf-async-job-result-ttl
integer
default:3600

Time-to-live in seconds for the job result after completion. Defaults to 3600 (1 hour). After expiry, the job result is automatically cleaned up.

Body

application/json
model
string
required

Model identifier in format provider/model

prompt
string
required

Text prompt to generate image

n
integer

Number of images to generate

Required range: 1 <= x <= 10
size
enum<string>

Size of the generated image

Available options:
256x256,
512x512,
1024x1024,
1792x1024,
1024x1792,
1536x1024,
1024x1536,
auto
quality
enum<string>

Quality of the generated image

Available options:
auto,
high,
medium,
low,
hd,
standard
style
enum<string>

Style of the generated image

Available options:
natural,
vivid
response_format
enum<string>
default:url

Format of the response.

Available options:
url,
b64_json
background
enum<string>

Background type for the image

Available options:
transparent,
opaque,
auto
moderation
enum<string>

Content moderation level

Available options:
low,
auto
partial_images
integer

Number of partial images to generate

Required range: 0 <= x <= 3
output_compression
integer

Compression level (0-100%)

Required range: 0 <= x <= 100
output_format
enum<string>

Output image format

Available options:
png,
webp,
jpeg
user
string

User identifier for tracking

seed
integer

Seed for reproducible image generation

negative_prompt
string

Negative prompt to guide what to avoid in generation

num_inference_steps
integer

Number of inference steps for generation

stream
boolean
default:false

Whether to stream the response. When true, images are sent as SSE. When streaming, providers may return base64 chunks (b64_json) and/or URLs (url) depending on provider and configuration.

fallbacks
object[]

Fallback models to try if primary model fails

Response

Job accepted for processing

Response returned when creating or polling an async job

id
string
required

Unique identifier for the async job

status
enum<string>
required

The status of an async job

Available options:
pending,
processing,
completed,
failed
created_at
string<date-time>
required

When the job was created

expires_at
string<date-time>

When the job result expires and will be cleaned up

completed_at
string<date-time>

When the job completed (successfully or with failure)

status_code
integer

HTTP status code of the completed operation

result
any

The result of the completed operation (shape depends on the request type)

error
object

Error response from Bifrost