生成图像
/model/v1/images/generations● 支持请求体
modelstring必填Image model id; list candidates with listModels?type=image. Router support (supported): Verified to take effect.
已验证生效。
response_formatstring可选◐ 部分支持Image response encoding. Only b64_json is accepted; url returns 400.
gpt-image-2 支持 b64_json;url 返回 400。
promptstring必填Text description of the image to generate. Router support (supported): Verified to take effect.
已验证生效。
ninteger可选Number of images to generate, from 1 to 10; defaults to 1. Router support (supported): Controls image count; zero returns 400 and values 1–10 are accepted.
控制图片数量,0 返回 400,允许 1–10。
sizestring可选◐ 部分支持Size of the generated images. Router support (partial): gpt-image-2 supports tested 1024x1024 and 1024x1536 sizes; 512x512 returns 400.
gpt-image-2 已验证 1024x1024、1024x1536;512x512 返回 400。
qualitystring可选Quality of the generated images. Router support (supported): Verified to take effect.
已验证生效。
backgroundstring可选gpt-image-2 的 transparent 返回透明 PNG。
output_formatstring可选gpt-image-2 的 jpeg 返回 JPEG。
返回
200
鉴权、限流、参数校验等平台错误按 problem+json 返回;OCR 的错误也为 problem+json,其它模型调用的错误按该端点所属格式(OpenAI 或 Anthropic)返回,参见 错误码
请求示例
curl
curl https://api.deepraxis.com/model/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/model/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/model/v1",
apiKey: "$PRAXIS_API_KEY",
});
const image = await client.images.generate({
model: "gpt-image-2",
prompt: "一只在书桌上打盹的猫",
size: "1024x1024",
quality: "low",
});响应示例 200
{
"created": 1790305639,
"background": "opaque",
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAABAAAAAQACAIAAADwf7zUAABJ7WNhQlgAAEntanVt…(采样时截断:原图 base64 共 2044340 字符,此处保留前 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
}
}响应
HTTP 200
Image generation response
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| created | integer | Unix time in seconds at which the images were created. |
| data | array<object> | Generated images. |
| data[].url | string | URL of the image; present when response_format is url. |
| data[].b64_json | string | Base64-encoded image; present when response_format is b64_json. |
| data[].revised_prompt | string | Prompt after the image model rewrote it, when the model reports it. |