Images API
Two endpoints: Generate (text → image) and Edit (image + text → image). Both responses follow the OpenAI standard shape data[0].b64_json.
Gemini image models (e.g. google/gemini-3.1-flash-image-preview) on this endpoint only support generation, not editing. For editing, use the Gemini native protocol.
Generate images
POST https://api.ofox.io/v1/images/generationsWith gpt-image-2
Python
import base64
from openai import OpenAI
client = OpenAI(api_key="YOUR_OFOX_API_KEY", base_url="https://api.ofox.io/v1")
resp = client.images.generate(
model="openai/gpt-image-2",
prompt="A simple red apple on a white table",
size="1024x1024",
quality="low",
output_format="png",
)
with open("output.png", "wb") as f:
f.write(base64.b64decode(resp.data[0].b64_json))Sample output:

With gemini-3.1-flash-image-preview
The same endpoint also accepts Gemini image models. Do not pass n — the gateway maps n incorrectly to the numberOfImages field and returns 400. Each call produces exactly one image.
Python
import base64
from openai import OpenAI
client = OpenAI(api_key="YOUR_OFOX_API_KEY", base_url="https://api.ofox.io/v1")
resp = client.images.generate(
model="google/gemini-3.1-flash-image-preview",
prompt="A simple red apple on a white table, photorealistic",
size="1024x1024",
quality="low",
output_format="png",
)
with open("output.png", "wb") as f:
f.write(base64.b64decode(resp.data[0].b64_json))Sample output:

Using reference images (image-to-image · Qwen series)
Qwen image models such as bailian/qwen-image-3.0-pro accept reference images (1–3) directly on this endpoint for image-to-image / editing, via the input_images field (each element is an image URL or base64):
curl -X POST 'https://api.ofox.io/v1/images/generations' \
-H 'Authorization: Bearer YOUR_OFOX_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"model": "bailian/qwen-image-3.0-pro",
"prompt": "Change the apple to blue, keep everything else the same",
"size": "1024x1024",
"input_images": ["https://example.com/ref-apple.png"]
}'When reference images take effect, the response usage contains num_input_images — use it to programmatically confirm the model actually consumed your reference image.
The field name must be input_images. Other spellings such as image_urls, image, or images are silently ignored and the request degrades to plain text-to-image (still HTTP 200).
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | ✅ | openai/gpt-image-2, google/gemini-3.1-flash-image-preview, bailian/qwen-image-3.0-pro |
prompt | string | ✅ | Natural-language description |
quality | string | ✅ | auto / low / medium / high / standard / hd |
n | number | — | 1–10, default 1. Not supported by Gemini models |
size | string | — | auto / 1024x1024 / 1536x1024 / 1024x1536 / 256x256 / 512x512 / 1792x1024 / 1024x1792 |
input_images | string[] | — | Reference images (URL or base64), supported by Qwen image models, 1–3 items; response contains usage.num_input_images when in effect |
output_format | string | — | png / jpeg / webp |
background | string | — | transparent / opaque / auto |
stream | boolean | — | Default false |
Response
{
"created": 1777385517,
"data": [
{ "b64_json": "<image Base64>", "index": 0 }
],
"model": "openai/gpt-image-2",
"size": "1024x1024",
"quality": "low",
"usage": {
"input_tokens": 14,
"input_tokens_details": { "text_tokens": 14 },
"output_tokens": 208,
"total_tokens": 222
}
}The image lives in data[0].b64_json — base64-decode and save it.
Edit images
POST https://api.ofox.io/v1/images/editsmultipart/form-data — you must upload an image file.
This endpoint only supports OpenAI / Azure OpenAI models. Calling it with google/gemini-3.1-flash-image-preview returns Image editing is not supported for model — switch to editing via the Gemini native protocol.
Call
Python
import base64
from openai import OpenAI
client = OpenAI(api_key="YOUR_OFOX_API_KEY", base_url="https://api.ofox.io/v1")
with open("apple.png", "rb") as f:
resp = client.images.edit(
model="openai/gpt-image-2",
image=f,
prompt="把苹果改成绿色,其他保持不变",
size="auto",
quality="low",
)
with open("apple_edited.png", "wb") as out:
out.write(base64.b64decode(resp.data[0].b64_json))The image field takes a local file path (with the @ prefix in cURL), not a URL.
Before / after:
| Original | Edited |
|---|---|
![]() | ![]() |
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | ✅ | openai/gpt-image-2, openai/gpt-image-1.5 (edit-optimized, supports input_fidelity) |
image | file | ✅ | PNG / JPEG file |
prompt | string | ✅ | Edit instruction |
quality | string | ✅ | low / medium / high |
n | number | — | Default 1 |
size | string | — | auto keeps the original size |
Response
Same shape as generation:
{
"created": 1777385669,
"data": [
{ "b64_json": "<edited image Base64>", "index": 0 }
],
"model": "openai/gpt-image-2",
"size": "auto",
"quality": "low",
"usage": {
"input_tokens": 1041,
"input_tokens_details": { "image_tokens": 1024, "text_tokens": 17 },
"num_input_images": 1,
"output_tokens": 358,
"total_tokens": 1399
}
}usage.input_tokens_details.image_tokens is the tokens consumed by the input image; num_input_images is the input image count.
See supported models and pricing in the Model Catalog .
