Appearance
图片
图片接口支持 OpenAI 兼容图片生成、Qwen 图片编辑和 Gemini Nano Banana 图片生成。所有请求均使用 Authorization: Bearer <API Key> 鉴权。
图片生成
text
POST /v1/images/generations统一图片生成入口,兼容 GPT Image、Image 2、Qwen 图片模型与 Nano Banana。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 图像模型 ID。 |
prompt | string | 视模型而定 | 图片描述,GPT Image / Image 2 必填。 |
n | integer | 否 | 生成数量,默认 1。 |
size | string | 否 | 输出尺寸,例如 1024x1536。 |
quality | string | 否 | 输出质量。 |
response_format | string | 否 | url 或 b64_json。 |
watermark | boolean | 否 | 是否添加水印。 |
images | string[] | 否 | 参考图 URL 或 Data URI 列表。 |
aspectRatio | string | 否 | Nano Banana 画面比例,例如 9:16。 |
imageSize | string | 否 | Nano Banana 清晰度,例如 1K、2K、4K。 |
bash
curl 'https://xueyangai.com/v1/images/generations' \
--header 'Authorization: Bearer sk-your-key' \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-image-2",
"prompt": "一只站在雪山前的蓝色机械羊",
"size": "1024x1536",
"n": 1,
"response_format": "url",
"watermark": false
}'Qwen 千问图片编辑
text
POST /v1/images/edits使用 Qwen Image Edit 模型,根据参考图片和文本描述进行编辑。
json
{
"model": "qwen-image-edit-plus",
"input": {
"messages": [
{
"role": "user",
"content": [
{ "image": "https://example.com/source.webp" },
{ "text": "将背景改为清晨的雪山" }
]
}
]
},
"parameters": {
"n": 1,
"prompt_extend": true,
"watermark": false
}
}Gemini 图片
text
POST /v1beta/models/{model}:generateContent使用 Gemini 格式调用 Nano Banana 图片生成能力,model 为路径参数。
json
{
"contents": [
{
"role": "user",
"parts": [{ "text": "draw a cat" }]
}
],
"generationConfig": {
"responseModalities": ["TEXT", "IMAGE"],
"imageConfig": {
"aspectRatio": "16:9",
"imageSize": "4K"
}
}
}成功请求返回图片 URL 或 Base64 数据,具体字段随所选模型和 response_format 不同。
