Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.auriko.ai/llms.txt

Use this file to discover all available pages before exploring further.

Send a text prompt to an image-capable model and receive base64-encoded images in choices[0].message.images.

Prerequisites

  • An Auriko API key
  • Python 3.10+ with the OpenAI SDK (pip install openai) or the auriko SDK (pip install auriko)
    • OR Node.js 18+ with the OpenAI SDK (npm install openai) or @auriko/sdk (npm install @auriko/sdk)
  • An image-capable model: gemini-2.5-flash-image, gemini-3-pro-image-preview, or gemini-3.1-flash-image-preview

Generate images

Create a chat completion with an image-capable model and save the generated image:
import os
import base64
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["AURIKO_API_KEY"],
    base_url="https://api.auriko.ai/v1",
)

response = client.chat.completions.create(
    model="gemini-2.5-flash-image",
    messages=[{
        "role": "user",
        "content": "Draw a cartoon cat wearing a top hat",
    }],
)

image = response.choices[0].message.images[0]
image_bytes = base64.b64decode(image["data"])

with open("output.png", "wb") as f:
    f.write(image_bytes)

print(f"Saved {image['mime_type']} image ({len(image_bytes)} bytes)")
image_tokens in usage.completion_tokens_details reports tokens consumed by generated images. The images field is absent when no images are generated. In streaming responses, images arrive complete in a single delta chunk.

Response shape

Each entry in the images array is a GeneratedImage object:
FieldTypeDescription
typestringAlways "image"
mime_typestringMIME type (e.g., image/png)
datastringBase64-encoded image data
thought_signaturestring?Opaque model signature. Response-only