Skip to Content
OpenInfer Docs
Inference APIs

Image Generation

POST /v1/images/generations

Text-to-image generation with diffusion models, through a subset of the OpenAI images API.

POST https://api.openinfer.ai/v1/images/generations

Request

curl https://api.openinfer.ai/v1/images/generations \
  -H "Authorization: Bearer $OPENINFER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "z-image",
    "prompt": "A lighthouse on a rocky coast at dusk, watercolor",
    "steps": 4,
    "seed": 42
  }' | jq -r '.data[0].b64_json' | base64 -d > lighthouse.png
FieldNotes
modelRequired. An image model slug (type image_gen) from GET /v1/models. A text model is rejected with 400.
promptRequired. Must not be empty.
stepsOptional. Denoising steps, 1 to 8.
seedOptional. Non-negative integer for reproducible output.
nOnly 1 is supported.
response_formatOnly b64_json is supported.
sizeAccepted and ignored. The image is the size the model was compiled for, for example 1024x1024.

Response

{
  "created": 1754000000,
  "data": [{ "b64_json": "iVBORw0KGgo..." }]
}

data[0].b64_json is a base64-encoded PNG.

The response arrives once the whole image is generated, so use a client timeout of at least 300 seconds.

SDK

import base64
from openai import OpenAI

client = OpenAI(base_url="https://api.openinfer.ai/v1", api_key="pk_...")

result = client.images.generate(
    model="z-image",
    prompt="A lighthouse on a rocky coast at dusk, watercolor",
    response_format="b64_json",
    extra_body={"steps": 4},
)
with open("lighthouse.png", "wb") as f:
    f.write(base64.b64decode(result.data[0].b64_json))

On this page