DocsAPI reference
Images
POST /v1/images/generations — photorealistic images with legible text from Z-Image-Turbo on your own GPU, in OpenAI's images format.
HTTP
POST https://osarai.xyz/v1/images/generationsGenerates images from a text prompt in OpenAI's images format. Deploy Z-Image-Turbo (z-image-turbo): photorealistic images with legible English and Chinese text, in 8 steps.
Request
Terminal
curl "https://osarai.xyz/v1/images/generations" \
-H "Authorization: Bearer $OSARAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "z-image-turbo",
"prompt": "A red fox in fresh snow at sunrise, soft light, 35 mm photo",
"size": "1024x1024",
"n": 1,
"response_format": "b64_json"
}' | jq -r '.data[0].b64_json' | base64 --decode > fox.pngPython
from openai import OpenAI
import base64, os
client = OpenAI(base_url="https://osarai.xyz/v1", api_key=os.environ["OSARAI_API_KEY"])
result = client.images.generate(
model="z-image-turbo",
prompt="A red fox in fresh snow at sunrise, soft light, 35 mm photo",
size="1024x1024",
n=1,
response_format="b64_json",
)
with open("fox.png", "wb") as f:
f.write(base64.b64decode(result.data[0].b64_json))TypeScript
import OpenAI from "openai";
import { writeFile } from "node:fs/promises";
const client = new OpenAI({ baseURL: "https://osarai.xyz/v1", apiKey: process.env.OSARAI_API_KEY });
const result = await client.images.generate({
model: "z-image-turbo",
prompt: "A red fox in fresh snow at sunrise, soft light, 35 mm photo",
size: "1024x1024",
n: 1,
response_format: "b64_json",
});
await writeFile("fox.png", Buffer.from(result.data[0].b64_json!, "base64"));| Field | Notes |
|---|---|
model | z-image-turbo |
prompt | What to draw. Put text you want in the image in quotes |
size | 512x512, 768x768, 1024x1024, 1280x720, 720x1280 |
n | Number of images, 1 to 4 |
response_format | b64_json |
Response
JSON
{
"created": 1793952000,
"data": [{ "b64_json": "iVBORw0KGgoAAAANSUhEUgAA…" }]
}Each image is a base64-encoded PNG. Images are not stored: save them from the response.