---
title: "Generate an image"
method: POST
path: "/v1/images/generations"
tags: ["Images"]
---

# Generate an image

`POST /v1/images/generations`

Generates images from text prompts using the specified model.

## Request body

- object
  - `model` string, required — Model identifier in format `provider/model`
  - `prompt` string, required — Text prompt to generate image
  - `n` integer — Number of images to generate
  - `size` '256x256' | '512x512' | '1024x1024' | '1792x1024' | '1024x1792' | '1536x1024' | '1024x1536' | 'auto' — Size of the generated image
  - `quality` 'auto' | 'high' | 'medium' | 'low' | 'hd' | 'standard' — Quality of the generated image
  - `style` 'natural' | 'vivid' — Style of the generated image
  - `response_format` 'url' | 'b64_json' — Format of the response.
  - `background` 'transparent' | 'opaque' | 'auto' — Background type for the image
  - `moderation` 'low' | 'auto' — Content moderation level
  - `partial_images` integer — Number of partial images to generate
  - `output_compression` integer — Compression level (0-100%)
  - `output_format` 'png' | 'webp' | 'jpeg' — Output image format
  - `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 — 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` Fallback[] — Fallback models to try if primary model fails
    - `provider` 'openai' | 'azure' | 'anthropic' | 'bedrock' | 'cohere' | 'vertex' | 'vllm' | 'mistral' | 'ollama' | 'groq' | 'sgl' | 'parasail' | 'perplexity' | 'replicate' | 'cerebras' | 'deepseek' | 'gemini' | 'openrouter' | 'elevenlabs' | 'huggingface' | 'nebius' | 'xai' | 'runway' | 'fireworks', required — AI model provider identifier
    - `model` string, required — Model name

## Response `200`

Successful response. Returns JSON for non-streaming requests, or Server-Sent Events (SSE) stream when `stream=true`.
When streaming, events are sent with the following event types:
- `image_generation.partial_image`: Intermediate image chunks with base64-encoded image data
- `image_generation.completed`: Final event for each image with usage information
- `error`: Error events with error details

- object
  - `id` string — Unique identifier for the generation request
  - `created` integer — Unix timestamp when the image was created
  - `model` string — Model used for generation
  - `data` object[] — Array of generated images
    - `url` string, uri — URL of the generated image
    - `b64_json` string — Base64-encoded image data
    - `revised_prompt` string — Revised prompt used for generation
    - `index` integer — Index of this image
  - `background` string — Background type for the image
  - `output_format` 'png' | 'webp' | 'jpeg' — Output image format
  - `quality` string — Quality of the generated image
  - `size` '256x256' | '512x512' | '1024x1024' | '1792x1024' | '1024x1792' | '1536x1024' | '1024x1536' | 'auto' — Size of the generated image
  - `usage` object
    - `input_tokens` integer — Number of input tokens
    - `input_tokens_details` object
      - `image_tokens` integer — Tokens used for images
      - `text_tokens` integer — Tokens used for text
    - `total_tokens` integer — Total tokens used
    - `output_tokens` integer — Number of output tokens
    - `output_tokens_details` object
      - `image_tokens` integer — Tokens used for images
      - `text_tokens` integer — Tokens used for text
  - `extra_fields` BifrostResponseExtraFields — Additional fields included in responses
    - `request_type` string — Type of request that was made
    - `provider` 'openai' | 'azure' | 'anthropic' | 'bedrock' | 'cohere' | 'vertex' | 'vllm' | 'mistral' | 'ollama' | 'groq' | 'sgl' | 'parasail' | 'perplexity' | 'replicate' | 'cerebras' | 'deepseek' | 'gemini' | 'openrouter' | 'elevenlabs' | 'huggingface' | 'nebius' | 'xai' | 'runway' | 'fireworks' — AI model provider identifier
    - `model_requested` string — The model that was requested
    - `model_deployment` string — The actual model deployment used
    - `latency` integer — Request latency in milliseconds
    - `chunk_index` integer — Index of the chunk for streaming responses
    - `raw_request` object — Raw request if enabled
    - `raw_response` object — Raw response if enabled
    - `cache_debug` BifrostCacheDebug
      - `cache_hit` boolean
      - `cache_id` string
      - `hit_type` string
      - `requested_provider` string
      - `requested_model` string
      - `provider_used` string
      - `model_used` string
      - `input_tokens` integer
      - `threshold` number
      - `similarity` number

## Other responses

- `400` — Bad request
- `500` — Internal server error

---

[API](https://skmtc.net/getbifrost/apis/bifrost-api.md) · [All operations](https://skmtc.net/getbifrost/apis/bifrost-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/getbifrost/bifrost-api/revisions/f8cab88f64ea/schema)
