DeerAPI Gemini 生图接口文档:通过统一接口调用 Gemini 3.1 Flash Image、Gemini 3 Pro Image、Gemini 2.5 Flash Image 进行图像生成与编辑,支持 4K 分辨率、Google Search 增强、多图参考等高级功能。
curl -s -X POST \
"https://api.deerapi.com/v1beta/models/gemini-3.1-flash-image-preview:generateContent" \
-H "Authorization: Bearer $DEERAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [{"parts": [{"text": "A cute baby sea otter floating in the ocean"}]}],
"generationConfig": {
"responseModalities": ["TEXT", "IMAGE"]
}
}' | jq -r '.candidates[0].content.parts[] | select(.inlineData) | .inlineData.data' | head -1 | base64 --decode > output.png{
"candidates": [
{
"content": {
"role": "<string>",
"parts": [
{
"text": "<string>",
"inlineData": {
"data": "<string>",
"mimeType": "<string>"
}
}
]
},
"finishReason": "<string>",
"index": 123,
"safetyRatings": [
"<string>"
]
}
],
"usageMetadata": {
"promptTokenCount": 123,
"candidatesTokenCount": 123,
"totalTokenCount": 123,
"thoughtsTokenCount": 123,
"promptTokensDetails": [
{}
]
},
"promptFeedback": {
"safetyRatings": [
"<string>"
]
}
}imageConfig 控制输出图片的宽高比和分辨率。
支持的宽高比:1:1, 1:4, 1:8, 2:3, 3:2, 3:4, 4:1, 4:3, 4:5, 5:4, 8:1, 9:16, 16:9, 21:9
支持的分辨率(Gemini 3 系列):512px、1K(默认)、2K、4K
2K、4K),小写会被拒绝。gemini-2.5-flash-image 固定 1024px,不支持 imageSize 参数。["TEXT", "IMAGE"]:默认模式,同时输出文字描述和图片["IMAGE"]:强制仅输出图片,解决频繁出现纯文本输出的问题tools 中添加 {"google_search": {}} 可让模型基于实时信息生成图片(如天气预报、新闻事件等)。
Gemini 3.1 Flash Image 还支持 Google Image Search,可从网络图片中获取视觉参考。
Bearer token authentication. Use your DeerAPI key.
需要调用的 model_id,例如 gemini-3.1-flash-image-preview(推荐)、gemini-3-pro-image-preview(专业创作)、gemini-2.5-flash-image(快速生成)
curl -s -X POST \
"https://api.deerapi.com/v1beta/models/gemini-3.1-flash-image-preview:generateContent" \
-H "Authorization: Bearer $DEERAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [{"parts": [{"text": "A cute baby sea otter floating in the ocean"}]}],
"generationConfig": {
"responseModalities": ["TEXT", "IMAGE"]
}
}' | jq -r '.candidates[0].content.parts[] | select(.inlineData) | .inlineData.data' | head -1 | base64 --decode > output.png{
"candidates": [
{
"content": {
"role": "<string>",
"parts": [
{
"text": "<string>",
"inlineData": {
"data": "<string>",
"mimeType": "<string>"
}
}
]
},
"finishReason": "<string>",
"index": 123,
"safetyRatings": [
"<string>"
]
}
],
"usageMetadata": {
"promptTokenCount": 123,
"candidatesTokenCount": 123,
"totalTokenCount": 123,
"thoughtsTokenCount": 123,
"promptTokensDetails": [
{}
]
},
"promptFeedback": {
"safetyRatings": [
"<string>"
]
}
}