Skip to main content

POST /v1/images/generations

Generates one or more images from a text description. The gateway forwards the request to the target provider (e.g. OpenAI DALL·E, Stability AI, or others) and returns image data as URLs or base64-encoded strings.

Request headers

string
The provider to route the request to (e.g. openai, stability-ai). Required when not using a config.
string
Your provider API key.
string
A JSON config object or config ID that defines routing, fallbacks, retries, and more.
string
A virtual key ID from Portkey Cloud.

Request body

string
required
The image generation model to use (e.g. dall-e-3, dall-e-2).
string
required
A text description of the desired image. For dall-e-3, the maximum length is 4000 characters; for dall-e-2, 1000 characters.
integer
default:"1"
The number of images to generate. dall-e-3 supports only n=1; dall-e-2 supports up to 10.
string
default:"1024x1024"
The dimensions of the generated images. Supported values depend on the model:
  • dall-e-2: 256x256, 512x512, 1024x1024
  • dall-e-3: 1024x1024, 1792x1024, 1024x1792
string
default:"standard"
The quality of the image. dall-e-3 supports standard and hd. dall-e-2 ignores this field.
string
default:"vivid"
The visual style of the image. dall-e-3 supports vivid (hyper-real) and natural (photorealistic). dall-e-2 ignores this field.
string
default:"url"
The format in which to return the image. One of url (a temporary URL valid for 60 minutes) or b64_json (base64-encoded PNG).
string
A unique identifier for the end user, used for monitoring and abuse detection.

Response

integer
Unix timestamp of when the images were created.
object[]
An array of generated image objects.

Code examples