Skip to main content
POST /v1/images/generations
Creates an image given a text prompt. Supports multiple image generation models including DALL-E, Stable Diffusion, and others.

Request Body

model
string
required
The model to use for image generation (e.g., dall-e-3, dall-e-2, stable-diffusion-xl)
prompt
string
required
A text description of the desired image. Maximum length varies by model.
n
integer
default:"1"
The number of images to generate. Must be between 1 and 10.
size
string
default:"1024x1024"
The size of the generated images. Supported sizes:
  • 256x256
  • 512x512
  • 1024x1024
  • 1536x1024 (landscape)
  • 1024x1536 (portrait)
  • 2048x2048
  • 4096x4096
  • auto
response_format
string
default:"url"
The format of the generated images. Either url or b64_json.
quality
string
default:"standard"
The quality of the image. Either standard or hd.
style
string
default:"vivid"
The style of the generated images (DALL-E 3 only). Either vivid or natural.

Response

created
integer
Unix timestamp of when the images were created.
data
array
Array of generated images.

Examples

Basic Image Generation

from openai import OpenAI

client = OpenAI(
    api_key="sk-voidai-your_key_here",
    base_url="https://api.voidai.app/v1"
)

response = client.images.generate(
    model="dall-e-3",
    prompt="A serene mountain landscape at sunset with a crystal clear lake",
    size="1024x1024",
    n=1
)

print(response.data[0].url)

HD Quality with Natural Style

response = client.images.generate(
    model="dall-e-3",
    prompt="A professional photograph of a coffee cup on a wooden table",
    size="1024x1024",
    quality="hd",
    style="natural",
    n=1
)

Base64 Response

import base64

response = client.images.generate(
    model="dall-e-3",
    prompt="An abstract geometric pattern",
    size="512x512",
    response_format="b64_json",
    n=1
)

# Decode and save the image
image_data = base64.b64decode(response.data[0].b64_json)
with open("image.png", "wb") as f:
    f.write(image_data)

Response Example

{
  "created": 1701691200,
  "data": [
    {
      "url": "https://storage.voidai.app/images/abc123.png",
      "revised_prompt": "A serene mountain landscape at sunset featuring snow-capped peaks reflecting in a crystal clear alpine lake, with warm orange and pink hues in the sky"
    }
  ]
}

Tips for Better Results

More descriptive prompts typically produce better results. Include details about style, lighting, composition, and mood.
Include art style references like “oil painting”, “digital art”, “photograph”, “watercolor”, etc.
Add terms like “high quality”, “4k”, “detailed”, “professional” to improve output quality.
Use landscape (1536x1024) for wide scenes and portrait (1024x1536) for tall subjects.