Before you start
Open Resources > Models, select Image, and choose a model that offers the Images operation. An image input capability alone does not enable image generation. The image catalog is also available atGET https://api.aion.to/v1/images/models.
The caller needs model.execute and sufficient organization credits.
Use deployment client credentials with the Python SDK.
For direct HTTP calls, use the common Model Service authentication.
This operation does not need File Service access.
Set AION_IMAGE_MODEL to your chosen model ID for the examples below.
Controls such as size, resolution, quality, format, and output count vary by route.
Check the model’s available controls before adding them to a request.
The model-wide list combines controls for discovery; it does not guarantee that every combination works together.
Python SDK
Installaionto-sdk in your application environment:
Get the JSON response
Save this asgenerate-image.py and run it in your configured deployment-client environment.
data, a list of images with b64_json, and optional usage.
The complete JSON response is held in client memory. To call from an agent coroutine, use the async variant:
Save completed images
The SDK returns image data without creating files. Your application chooses names, storage, and retention. For a local file, decode the base64 value and write the bytes. Save this helper asimage_files.py:
generated-images/. If the response omits its media type, the helper uses
.bin; inspect the bytes to determine a format before renaming it. Allow memory for both base64 and decoded bytes.
Receive streamed events
Usestream_images in a with block. It parses native SSE and handles routes that return JSON instead.
Save this as stream-image.py beside image_files.py:
async with stream_images_async(...) and async for:
AionImageError; files already saved remain available.
No helper retries generation automatically.
See the Python API reference for options and errors.
The existing LangGraph, Google ADK, and Codex model adapters remain Text clients.
The OpenAI Images resource uses a different endpoint. Use these helpers for Aion’s native Images operation.
HTTP API
SetAION_API_KEY to your personal key and AION_IMAGE_MODEL to a model ID from the image catalog.
This example saves the complete JSON response to image-response.json:
Optional SSE and JSON fallback
Setstream: true to request native SSE. Check the actual response Content-Type before parsing the body.
Use text/event-stream as SSE and application/json as the JSON shape above.
Do not parse an image result as a chat-completion chunk.
Model details show streaming support as Available, Unsupported, or Unknown.
Some routes return only JSON, even when the request sets
stream: true.
Previews depend on the selected route and can contain a complete base64 image. Allow for large event payloads.
Controls and limits
model and a nonempty prompt are required.
Optional controls include n, size, resolution, aspect_ratio, quality, output_format, background,
output_compression, seed, input_references, provider, stream, session_id, trace, and user.
Use only controls and combinations verified for the selected model and route.
X-Session-Id supplies a session ID only when the body omits session_id.
These descriptive fields do not select the principal or payer.
Reference images use input_references with supported HTTPS URLs or inline data URLs.
Aion does not import these references into File Service. The generation route retrieves remote references.
The request limits include inline base64 overhead. Model limits can be lower than Aion limits.
Prices and failure behavior
The catalog quotes Aion credits in each applicable unit: image, megapixel, token, request, or another reported unit. Rows retain their route, resolution, and quality qualifiers. Per-token display uses one million tokens. Hybrid models have separate Text and Image price views. Missing rates mean unavailable, not free. When present,usage.cost is an Aion credit quote for the returned result. Fractional credits are valid.
Aion can omit the quote if a reliable price is unavailable. Output can still succeed.
The quote uses the applicable organization pricing policy; it is not a final settlement receipt.
It excludes other billable attempts. Policy changes or later usage information can change the settled charge.
The final charge uses completed-generation usage, not the requested image count alone.
Previews and failures before any completed generation do not create an image-generation charge.
A client disconnect cancels upstream work. A completion that already reached Aion remains billable.
Invalid controls fail before generation. HTTP 429 means the image runtime is busy.
Temporary catalog or runtime failures can return HTTP 503. A failure after SSE headers can end the stream.
A native error event also indicates failure. Preserve completed images and report an incomplete result to the user.
Aion permits one retry after an explicit upstream rate-limit rejection, within the original deadline.
It does not retry ambiguous paid work or repeat generation to recover missing usage prices.