Appearance
Images Generations
根据文本提示生成图片,兼容 OpenAI Images Generations API。
请求
POST https://api.mirrorstages.com/openai/v1/images/generations请求头
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
Authorization | string | 是 | Bearer your-api-key |
Content-Type | string | 是 | application/json |
请求体
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 模型名称,如 gpt-image-1 |
prompt | string | 是 | 图片描述文本 |
n | integer | 否 | 生成图片数量,默认 1 |
size | string | 否 | 图片尺寸,如 1024x1024、1536x1024、1024x1536 |
quality | string | 否 | 图片质量,如 low、medium、high |
response_format | string | 否 | 返回格式,b64_json 或 url |
background | string | 否 | 背景设置,transparent 或 opaque |
output_format | string | 否 | 输出图片格式,如 png、webp |
stream | boolean | 否 | 是否启用流式输出,默认 false |
请求示例
bash
curl https://api.mirrorstages.com/openai/v1/images/generations \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-1",
"prompt": "A cute cat sitting on a couch",
"n": 1,
"size": "1024x1024"
}'响应
非流式响应
json
{
"created": 1677858242,
"data": [
{
"b64_json": "<base64-encoded-image>",
"revised_prompt": "A cute cat sitting on a couch"
}
],
"usage": {
"total_tokens": 100,
"input_tokens": 20,
"output_tokens": 80,
"input_tokens_details": {
"text_tokens": 10,
"image_tokens": 10
}
}
}流式响应
当 stream: true 时,响应以 SSE 格式返回部分图片数据。