OpenAI-Compatible Image API
Crynux Network provides OpenAI-compatible Image Generation and Image Edit APIs. You can use the official OpenAI SDK with only a Crynux base URL and API key.
Quick Start: Image Generation
Call POST /v1/images/generations through the OpenAI SDK images.generate method:
import base64
from openai import OpenAI
client = OpenAI(
base_url="https://api.crynux-as.xyz/api/<endpoint_token>/v1",
api_key="your-api-key",
timeout=300,
max_retries=1,
)
result = client.images.generate(
model="Qwen/Qwen-Image-2.1",
prompt="A product photo of a white ceramic cup on a wooden table",
size="1024x1024",
response_format="b64_json",
)
image_bytes = base64.b64decode(result.data[0].b64_json)
with open("output.png", "wb") as f:
f.write(image_bytes)import fs from "fs";
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.crynux-as.xyz/api/<endpoint_token>/v1",
apiKey: "your-api-key",
timeout: 300000,
maxRetries: 1,
});
async function main() {
const result = await client.images.generate({
model: "Qwen/Qwen-Image-2.1",
prompt: "A product photo of a white ceramic cup on a wooden table",
size: "1024x1024",
response_format: "b64_json",
});
const imageBytes = Buffer.from(result.data[0].b64_json, "base64");
fs.writeFileSync("output.png", imageBytes);
}
main();Image Editing
Call POST /v1/images/edits to create images from one or more input images and a text prompt. You can send images as multipart file uploads or as JSON data URLs.
Multipart upload with the OpenAI SDK
The multipart form accepts one or more file parts named image or image[]. You can upload 1 to 16 images.
JSON request with data URLs
JSON requests must use images as a non-empty array of objects. Each object provides exactly one image_url as a data:image/<type>;base64,... data URL. Absolute http and https URLs are not supported. The total size of all images strings must not exceed 1 MB (1,048,576 bytes).
Supported Standard OpenAI Parameters
model
Yes
Hugging Face Diffusers image model ID, for example Qwen/Qwen-Image-2.1, Tongyi-MAI/Z-Image-Turbo, or black-forest-labs/FLUX.2-klein-4B
prompt
Yes
Text prompt, at most 32,000 characters
images / image
Edits only
1 to 16 input images. JSON uses images: [{"image_url": "data:image/...;base64,..."}]. Multipart uses image or image[] file parts
n
No
Number of images to generate, integer from 1 to 10, default 1
size
No
Default or "auto" becomes 1024x1024. Named sizes: 256x256, 512x512, 1024x1024, 1024x1536, 1536x1024, 1792x1024, 1024x1792. Custom WIDTHxHEIGHT must use positive integers divisible by 8, aspect ratio in [1/3, 3], each edge at most 3840, and pixel count at most 3840 * 2160
quality
No
Maps to denoising steps: "low" → 20; omitted / "auto" / "medium" / "standard" → 40; "high" / "hd" / "xhigh" / "max" → 50
response_format
No
Only "b64_json" is supported
output_format
No
Only "png" is supported
safety_identifier, user
No
Accepted with no side effects
Crynux Extended Parameters
Crynux extends the OpenAI Images APIs with the fields below. In the Python OpenAI SDK, pass them through extra_body. In the JavaScript OpenAI SDK, pass them as top-level request fields.
vram_limit
Minimum GPU VRAM in GB. You can also set it in the URL path as /v1/<vram_limit>/images/generations or /v1/<vram_limit>/images/edits. The path value overrides the body value. When omitted, Crynux uses the matched loaded-model min_vram
queue_timeout
Queue wait budget in seconds. See Flexible Pricing below
quantization_config
Optional object or null for task-time quantization. See Model Quantization. For multipart /images/edits, send either one JSON form field or OpenAI SDK bracket fields such as quantization_config[quant_kwargs][load_in_4bit]
components
Optional object or null that replaces pipeline components, for example a GGUF transformer or a standalone vae. See Model Quantization and Text-to-Image Task
Flexible Pricing with queue_timeout
Crynux schedules queued tasks by task fee. That is Flexible Pricing: a higher Cost Level / task fee ranks higher in the queue, and a lower Cost Level / task fee ranks lower.
You can combine a low project Cost Level with a long queue_timeout (for example several hours). The task stays in the queue longer and can run when the network is quieter, which is cheaper for large batches that do not need an immediate result.
Synchronous Image APIs (/v1/images/generations and /v1/images/edits) hold one HTTP request until the job finishes. That hold is limited (about 10 minutes by default) and is not suitable for long queue waits. For low Cost Level + long queue_timeout, do not use the synchronous Images APIs. Use the asynchronous Raw Task API instead: create the task with POST /inference_tasks or POST /inference_tasks/batch, poll status, then download the PNG when the task succeeds. See Text-to-Image Task.
Example with extended parameters
Unsupported Parameters and Endpoints
These values return HTTP 400 with an OpenAI invalid-request error shape:
Endpoint:
POST /v1/images/variationsOpenAI fields or values:
response_format="url",output_formatother than"png",output_compression,background,moderation,style,stream=true,partial_imagesImage edits only:
mask,input_fidelity,file_id, and non-data-URLhttp://orhttps://image linksUnderlying Raw Task fields that are not accepted on the OpenAI Images APIs:
dtype,lora,steps,negative_prompt,seed,strength,guidance_scale
Need More Complex Features? Use the Raw Task API
Use the OpenAI-compatible Images APIs when you want a simple generation or edit call. Use the Crynux AS Raw Task API when you need finer control, for example:
custom
steps,negative_prompt,guidance_scale, fixedseed, or img2imgstrengthLoRA adapters (
lora)explicit
dtypeasynchronous create-and-poll, batch create (
POST /inference_tasks/batch), or longqueue_timeoutFlexible Pricing jobs
If you need still more direct control over the wallet, Relay task_fee, Bridge-side repeat tasks, or the task lifecycle without Crynux AS, deploy your own Crynux Bridge.
Checking Available Image Models
List currently loaded image models for your project:
Each list entry includes id, min_vram, on_disk_node_count, execution_dtype, quantization_config, components, and lora. The OpenAI Images APIs resolve a concrete execution_dtype from a matching loaded-model row when you do not control dtype directly on the OpenAI request.
Response Format
A successful response looks like this:
The response includes created, data[].b64_json, and echoed size, quality, and output_format. It does not include url, revised_prompt, usage, background, or safety_identifier.
Last updated