| Endpoint | What it does |
|---|---|
POST /v1/images/generations | Generate an image from a text prompt |
POST /v1/images/edits | Edit an existing image (see Image editing) |
Step 1: Send a request
A request needs just two things: amodel and a prompt. Browse the available ids on the image models page. deepshi-banana-pro is a fast, low-cost default.
curl
data[0].b64_json:
| Field | What it is |
|---|---|
data[].b64_json | The image, base64-encoded. Decode it to get the file, which is Step 2. |
data[].index | The image’s position in the batch, starting at 0. |
size | The actual output dimensions, as WIDTHxHEIGHT. |
usage.cost.total_cost | The exact amount, in USD, charged for this request. |
Step 2: Save the image
Decodeb64_json and write it to a file. With the OpenAI SDK that’s just a few lines:
Step 3: Set the image size
Models size their output in different ways. Send the field or fields your chosen model supports:- Pixel dimensions: exact
widthandheight. Examples:deepshi-banana-pro,flux-2-pro. - Resolution tier: an
aspect_ratioplus aresolutionlike1K,2K, or4K. Examples:nano-banana-2,nano-banana-pro. - Aspect ratio: just an
aspect_ratiolike16:9. Example:grok-imagine. - Preset size: a named
image_sizelikeauto_2Kor1024x1024. Examples:seedream-4.5,gpt-image-2.
Pixel-dimension model
Resolution-tier model
Not sure which fields a model takes? See Choosing a model below. Every
model lists its sizing fields in
GET /v1/models. A model ignores fields it doesn’t support,
so don’t carry one model’s sizing style over to another.Choosing a model
Each image model supports different parameters, sizing styles, and limits. There are two ways to see them:- The image models page, with a card per model showing its sizing style, prompt limit, and editing support.
GET /v1/models, the same facts as JSON, scoped to your key (you only see models your key can call).
parameters it accepts (with type, allowed values, and default), plus an edit block, prompt_max_length, and its modalities:
Example image model entry
Common parameters
These apply across image models. Anything else you send is passed straight to the model and only takes effect if that model supports it.| Parameter | Type | Description |
|---|---|---|
model | string | The image model id. Required. |
prompt | string | What to generate. Required. Each model caps the length (8,000 to 50,000 characters); over the limit returns 400 PROMPT_TOO_LONG. |
n | integer | Number of images (1 to 4). Defaults to 1. deepshi-banana-pro and deepshi-image-1 support only n: 1. |
response_format | string | b64_json (default) or url (an inline data: URI). |
output_format | string | png, jpeg, or webp (per model; some support only png or jpeg). |
quality | string | For the GPT Image models: low, medium, or high. Higher tiers cost more. Other models ignore it. |
seed | integer | Seed for reproducible output. Omit for a random seed. Supported by some models. |
stream | boolean | Stream the result as Server-Sent Events. See Long-running generations. |
Pricing
Image pricing is per image for most models, and per megapixel for a few. For many models it depends on what you request, such as theresolution, quality, or output size.
You never calculate this yourself. Every response includes usage.cost.total_cost in USD, the exact amount deducted from your balance. Per-model prices are listed on deepshi.ai.
Long-running generations
High-resolution generations can take a while. For a slow generation, setstream: true to receive the result as Server-Sent Events instead of one buffered response. Streamed generations bill exactly the same. See Streaming.
Next steps
Image editing
Edit an existing image with a prompt.
Image models
Browse image models and their sizing options.