Create an image
POST
/openai/v1/images/generations● SupportedRequest body
modelstringrequiredVerified to take effect.
response_formatstringoptional○ UnsupportedOmit for GPT Image models, which return native base64 data. Only send for models that explicitly support response_format; platform hosting is a separate Image extension.
gpt-image-2 returns 400 for both b64_json and url; omit this field.
promptstringrequiredVerified to take effect.
nintegeroptionalControls image count; zero returns 400 and values 1–10 are accepted.
sizestringoptional◐ Partially supportedgpt-image-2 supports tested 1024x1024 and 1024x1536 sizes; 512x512 returns 400.
qualitystringoptionalVerified to take effect.
backgroundstringoptionaltransparent returns a transparent PNG on gpt-image-2.
output_formatstringoptionaljpeg returns JPEG on gpt-image-2.
Returns
200
Errors follow the OpenAI format — see error codes
Request
curl
curl https://api.deepraxis.com/openai/v1/images/generations \
-H "Authorization: Bearer $PRAXIS_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-image-2","prompt":"一只在书桌上打盹的猫","size":"1024x1024","quality":"low"}'Python
from openai import OpenAI
client = OpenAI(
base_url="https://api.deepraxis.com/openai/v1",
api_key="$PRAXIS_API_KEY",
)
image = client.images.generate(
model="gpt-image-2",
prompt="一只在书桌上打盹的猫",
size="1024x1024",
quality="low",
)TypeScript
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.deepraxis.com/openai/v1",
apiKey: "$PRAXIS_API_KEY",
});
const image = await client.images.generate({
model: "gpt-image-2",
prompt: "一只在书桌上打盹的猫",
size: "1024x1024",
quality: "low",
});Response 200
{
"created": 1790319281,
"background": "opaque",
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAABAAAAAQACAIAAADwf7zUAABJ7WNhQlgAAEntanVt…(采样时截断:原图 base64 共 2116428 字符,此处保留前 64)"
}
],
"output_format": "png",
"quality": "low",
"size": "1024x1024",
"usage": {
"input_tokens": 17,
"input_tokens_details": {
"image_tokens": 0,
"text_tokens": 17
},
"output_tokens": 196,
"output_tokens_details": {
"image_tokens": 196,
"text_tokens": 0
},
"total_tokens": 213
}
}Response
HTTP 200
Image generation response
application/json
| Name | Type | Description |
|---|---|---|
| created | integer | |
| data | array<object> | |
| data[].url | string | |
| data[].b64_json | string | |
| data[].revised_prompt | string |