pydo.images.generate()

Generated on 1 Oct 2026 from pydo version v0.43.0

Usage

client.images.generate(
    model="openai-gpt-image-1",
    prompt="A cute baby sea otter floating on its back in calm blue water",
    size="auto",
    quality="auto",
    n=1,
)
Returns JSONRaises HttpResponseError

Serverless inference methods can authenticate with a model access key instead of a DigitalOcean API token:

client = Client(token=os.environ.get("MODEL_ACCESS_KEY"))

Description

Creates a high-quality image from a text prompt using GPT-IMAGE-1, the latest image generation model with automatic prompt optimization and enhanced visual capabilities.

Parameters

prompt string required

Example: A cute baby sea otter floating on its back in calm blue water

A text description of the desired image(s). Supports up to 32,000 characters and provides automatic prompt optimization for best results.

Min length: 1

model string required

Example: openai-gpt-image-1

The model to use for image generation.

moderation string or null optional

Example: auto

The moderation setting for the image generation. Supported values: low, auto.

background string or null optional

Example: auto

The background setting for the image generation. Supported values: transparent, opaque, auto.

output_format string or null optional

Example: png

The output format for the image generation. Supported values: png, webp, jpeg.

output_compression integer or null optional

Example: 100

The output compression level for the image generation (0-100).

Min: 0

n integer required

Example: 1

The number of images to generate. Must be between 1 and 10.

Min: 1

Max: 10

quality string or null optional

Example: auto

The quality of the image that will be generated. Supported values: auto, high, medium, low.

size string optional

The size of the generated images. GPT-IMAGE-1 supports: auto (automatically select best size), 1536x1024 (landscape), 1024x1536 (portrait).

One of: auto, 1536x1024, 1024x1536

stream boolean or null optional

Example: False

If set to true, partial image data will be streamed as the image is being generated. The response will be sent as server-sent events with partial image chunks. When stream is true, partial_images must be greater than 0.

Default: False

partial_images integer or null optional

Example: 1

The number of partial image chunks to return during streaming generation. Defaults to 0. When stream=true, this must be greater than 0 to receive progressive updates of the image as it is being generated.

Min: 0

user string or null optional

Example: user-1234

A unique identifier representing your end-user, which can help DigitalOcean to monitor and detect abuse.

Max length: 256

Request Sample

Show Request Sample
import os
from pydo import Client

client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))

resp = client.images.generate(
    model="openai-gpt-image-1",
    prompt="A cute baby sea otter floating on its back in calm blue water",
    size="auto",
    quality="auto",
    n=1,
)

print(resp.data[0].b64_json)

Response Example

Show Response Example
{
  "created": 1677649456,
  "data": [
    {
      "b64_json": "iVBORw0KGgoAAAANSUhEUgAAAQAAAAEAAQMAAABmvDolAAAAA1BMVEX...",
      "revised_prompt": "A cute baby sea otter floating on its back in calm blue water, captured with professional photography lighting and composition"
    }
  ],
  "background": "opaque",
  "output_format": "png",
  "quality": "high",
  "size": "1024x1024",
  "usage": {
    "total_tokens": 4172,
    "input_tokens": 12,
    "output_tokens": 4160
  }
}

More Information

See /v1/images/generations in the API reference for additional detail on responses, headers, parameters, and more.

We can't find any results for your search.

Try using different keywords or simplifying your search terms.