v1

latestOpenAPI 3.1.02026-07-26793302.3 KB

Create images

Generate images from a text prompt using OpenAI-compatible request shapes on DeerAPI. For the latest model-specific output controls and parameter support, refer to the OpenAI image generation guide: https://developers.openai.com/api/docs/guides/image-generation

post/v1/images/generations

Request body

modelstring required

The image generation model to use. Choose a current model from the Models page.

promptstring required

Text description of the image you want to generate.

ninteger

Number of images to generate. Keep this at 1 for the broadest compatibility.

qualitystring

Quality setting for models that support it. See the OpenAI image generation guide for the latest model-specific values.

sizestring

Requested output size. Supported values depend on the selected model. See the OpenAI image generation guide for the latest model-specific ranges.

response_format'url' | 'b64_json'

The response container for dall-e-2 and dall-e-3. This parameter is not supported for GPT image models, which return base64-encoded image data.

output_formatstring

The encoded image type for GPT image model results, such as png, jpeg, or webp. See the OpenAI image generation guide for current GPT image output controls.

Example request

{
  "prompt": "A paper boat floating on calm water at sunrise.",
  "size": "1024x1024",
  "output_format": "jpeg"
}

Response

Image generation result.

createdinteger required

Unix timestamp for the completed generation.

backgroundstring

Background mode returned by models that expose it.

output_formatstring

Encoded image type returned by GPT image models.

qualitystring

Quality level returned by models that expose it.

sizestring

Output size returned by models that expose it.

Example response

{
  "created": 1776841943,
  "background": "opaque",
  "output_format": "jpeg",
  "quality": "low",
  "size": "1024x1024",
  "usage": {
    "input_tokens": 16,
    "input_tokens_details": {
      "image_tokens": 0,
      "text_tokens": 16
    },
    "output_tokens": 208,
    "total_tokens": 224
  },
  "data": [
    {
      "b64_json": "<base64-image-data>"
    }
  ]
}