Skip to main content
POST
/
v1
/
images
/
generations
GPT Text-to-Image
curl --request POST \
  --url https://api.myrouter.ai/v1/images/generations \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: <content-type>' \
  --data '
{
  "model": "<string>",
  "prompt": "<string>",
  "quality": "<string>",
  "n": 123,
  "size": "<string>"
}
'
{
  "created": 123,
  "data": [
    {
      "b64_json": "<string>"
    }
  ],
  "output_format": "<string>",
  "quality": "<string>",
  "size": "<string>",
  "usage": {
    "input_tokens": 123,
    "input_tokens_details": {
      "image_tokens": 123,
      "text_tokens": 123
    },
    "output_tokens": 123,
    "total_tokens": 123
  }
}
Use GPT image generation models to quickly generate high-quality images from text descriptions. Supports multiple size and quality options to meet various image generation needs.

Request Headers

Content-Type
string
required
Enum: application/json
Authorization
string
required
Bearer authentication format: Bearer {{API Key}}.

Request Body

model
string
required
The model used for image generation. Currently supports gpt-image-1, gpt-image-1.5.
prompt
string
required
Text description of the desired image.For gpt-image-1, gpt-image-1.5, the maximum length is 32000 characters.
quality
string
Quality of the generated image, Default: auto.For gpt-image-1, gpt-image-1.5, supported values are: auto, high, medium, low.
n
integer
Number of images to generate, Range: 1~10, Default: 1.
size
string
Size of the generated image, Default: auto.For gpt-image-1, gpt-image-1.5, supported values are:
  • 1024x1024: Square
  • 1536x1024: Landscape
  • 1024x1536: Portrait
  • auto: Default

Response Parameters

created
integer
required
Unix timestamp (in seconds) of when the image was generated.
data
array
required
List of generated images.
output_format
string
required
Output format of the generated image. Possible values: png, webp, jpeg.
quality
string
required
Quality of the generated image. Possible values: low, medium, high.
size
string
required
Size of the generated image. Possible values: 1024x1024, 1024x1536, 1536x1024.
usage
object
Only supported by gpt-image-1, gpt-image-1.5. Token usage information for image generation.