API
Image generation
POST /api/v1/images/generations generates an image from a text prompt.
Compatible with the OpenAI Images API.
Request
curl https://api.pendra.ai/api/v1/images/generations \
-H "Authorization: Bearer pdr_sk_..." \
-H "Content-Type: application/json" \
-d '{
"model": "x/z-image-turbo",
"prompt": "A misty Welsh valley at dawn, painted in oils",
"size": "1024x1024"
}' Fields
model— image model ID, e.g.x/z-image-turbo. List models at /models?type=image.prompt— the text description.size— e.g.1024x1024. Supported sizes depend on the model.n— number of images to generate (model permitting; default 1).response_format—b64_json(default) orurldepending on the underlying backend.
Response
OpenAI-shaped image response. data contains one entry per
requested image (set by n). With the default
response_format: "b64_json", each entry carries a
base64-encoded PNG — decode it before writing to disk. Backends that
return URLs (some hosted models, set response_format: "url")
populate url instead.
{
"created": 1715346200,
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAA...Cg=="
}
]
} Python
from pendra import Pendra
import base64, pathlib
client = Pendra()
result = client.images.generate(
model="x/z-image-turbo",
prompt="A misty Welsh valley at dawn",
size="1024x1024",
)
pathlib.Path("out.png").write_bytes(base64.b64decode(result.data[0].b64_json)) Timeouts
Image requests have a longer ceiling than chat — up to ~600 seconds — because generation can be slow on busy workers. For interactive UX, render a spinner; you'll usually get a response in 5–30 seconds depending on model and size.
Usage tracking
Image requests appear under Images in the console usage view alongside chat and embeddings.