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/generationsRequest
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| Field | Notes |
|---|---|
model | Required. An image model slug (type image_gen) from GET /v1/models. A text model is rejected with 400. |
prompt | Required. Must not be empty. |
steps | Optional. Denoising steps, 1 to 8. |
seed | Optional. Non-negative integer for reproducible output. |
n | Only 1 is supported. |
response_format | Only b64_json is supported. |
size | Accepted 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))