https://comfyrouter.com/v1beta/models/gemini-2.5-flash-image:generateContentPOST{
"Content-Type": "application/json",
"Authorization": "Bearer {api_key}"
}{
"contents": [
{
"parts": [
{
"text": "string - 图像生成/编辑的提示词"
},
{
"inline_data": {
"mime_type": "image/png | image/jpeg",
"data": "string - base64 编码的图片数据(不含前缀)"
}
}
]
}
],
"generationConfig": {
"responseModalities": ["IMAGE", "TEXT"],
"imageConfig": {
"aspectRatio": "1:1 | 16:9 | 9:16 | 4:3 | 3:4"
}
}
}contents.parts: 数组,可包含多个 text 和 inline_data 部分parts[0]: 通常是文本提示词parts[1+]: 可选的输入图片,支持多张inline_data.mime_type: 图片 MIME 类型inline_data.data: base64 编码的图片数据(注意:不包含 data:image/png;base64, 前缀)responseModalities: 响应模式,["IMAGE", "TEXT"] 表示同时返回图片和文本imageConfig.aspectRatio: 输出图片的宽高比{
"candidates": [
{
"content": {
"role": "model",
"parts": [
{
"text": "Here's the adjusted image for you: \n"
}
]
},
"finishReason": "STOP",
"index": 0,
"safetyRatings": []
}
],
"usageMetadata": {
"promptTokenCount": 206,
"candidatesTokenCount": 45,
"totalTokenCount": 251,
"thoughtsTokenCount": 0,
"promptTokensDetails": null
}
}candidates[0].content.parts[0].text: 包含生成的图片 URL,格式为 Markdown finishReason: 完成原因,STOP 表示正常完成usageMetadata: Token 使用统计信息!\[image\]\((https?://[^\)]+)\)https://filesystem.site/cdn/20251107/xoxSjLn4vB40KTJje4hUBBa1PK7rqz.png{
"candidates": [
{
"content": {
"role": "model",
"parts": [
{
"text": ""
}
]
},
"finishReason": "STOP",
"index": 0,
"safetyRatings": []
}
],
"usageMetadata": {
"promptTokenCount": 536,
"candidatesTokenCount": 1290,
"totalTokenCount": 1826,
"thoughtsTokenCount": 0,
"promptTokensDetails": null
}
}candidates[0].content.parts[0].text: 包含 base64 编码的图片数据,格式为 Markdown data URI 