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

# Generate an image

`POST /v1/images/generations`

## Request

- Base URL: `https://api.sandbase.ai`
- URL: `https://api.sandbase.ai/v1/images/generations`
- Auth: HTTP bearer

Generate images through the synchronous OpenAI Images-compatible endpoint. Supported public model names are gpt-image-2, gpt-image-2.5-flare, and gpt-image-2.5-sunburst. Additional compatible JSON fields are forwarded unchanged. Streaming and asynchronous mode are not supported on this endpoint.

## Request body

- ImageGenerationRequest
  - `model` 'gpt-image-2' | 'gpt-image-2.5-flare' | 'gpt-image-2.5-sunburst', required
  - `prompt` string, required
  - `n` integer
  - `size` string: Output size supported by the selected model, such as 1024x1024, 1024x1536, 1536x1024, or auto.
  - `quality` string: Output quality supported by the selected model, such as low, medium, high, or auto.
  - `background` string: Background setting such as transparent, opaque, or auto.
  - `output_format` string: Output encoding such as png, webp, or jpeg.
  - `output_compression` integer
  - `moderation` string
  - `user` string
  - `stream` false: Streaming is not supported by this SandBase endpoint.
  - `mode` 'sync'

## Response `200`

Generated images and authoritative token usage

- ImagesResponse
  - `created` integer
  - `data` union[], required
    - union
      - object
        - `b64_json` string, required: Base64-encoded image data.
        - `url` string, uri
        - `revised_prompt` string
      - object
        - `b64_json` string: Base64-encoded image data.
        - `url` string, uri, required
        - `revised_prompt` string
  - `usage` object, required
    - `input_tokens` integer, required
    - `output_tokens` integer, required
    - `total_tokens` integer, required
    - `input_tokens_details` object, required
      - `text_tokens` integer, required
      - `image_tokens` integer, required
      - `cached_text_tokens` integer
      - `cached_image_tokens` integer
      - `cached_tokens` integer

## Other responses

- `400`: Invalid body, unsupported model, streaming request, or provider request
- `401`: Missing or invalid API key
- `402`: Organization or API Key spending limit reached
- `403`: Organization is disabled, or the API key scope does not authorize this endpoint
- `404`: Routed image model is unavailable
- `429`: Rate limit exceeded
- `500`: Request persistence or response processing failed
- `502`: Provider returned an invalid native response
- `503`: No provider route succeeded

---

[API](https://skmtc.dev/sandbase/apis/sandbase-api.md) · [All operations](https://skmtc.dev/sandbase/apis/sandbase-api/llms.txt) · [OpenAPI document](https://skmtc.dev/sandbase/apis/sandbase-api/revisions/d40df2467ba2?raw)
