Skip to content

图片生成

POST https://az.gptplus5.com/v1beta/models/{modeName}:generateContent

官方文档:https://ai.google.dev/gemini-api/docs/image-generation?hl=zh-cn

请求参数

Authorization

在 Header 添加参数Authorization,其值为在 Bearer 之后拼接 Token

示例:Authorization: Bearer ********************

Path 参数

参数名类型必需说明
modeNamestring必需模型名称: gemini-2.5-flash-image gemini-2.5-flash-image-preview gemini-3-pro-image-preview gemini-3.1-flash-image-preview

Query 参数

参数名类型必需说明示例
keystring必需{{YOUR_API_KEY}}

Header 参数

参数名类型必需说明示例
Content-Typestring必需application/json

Body 参数 (application/json)

参数名类型必需说明
contentsarray[object]必需
  └ partsarray[object]必需
generationConfigobject可选
  └ responseModalitiesarray[string]可选响应模式: Text、Image 默认:["Text", "Image"]
  └ imageConfigobject可选

请求示例

json
{
  "contents": [
    {
      "role": "user",
      "parts": [
        {
          "text": "Hi, can you create a 3d rendered image of a pig with wings and a top hat flying over a happy futuristic scifi city with lots of greenery?"
        }
      ]
    }
  ],
  "generationConfig": {
    "responseModalities": [
      "IMAGE"
    ]
  }
}

cURL 示例

bash
curl --location -g --request POST 'https://az.gptplus5.com/v1beta/models/gemini-2.5-flash-image-preview:generateContent?key=' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data-raw '{
  "contents": [
    {
      "role": "user",
      "parts": [
        {
          "text": "Hi, can you create a 3d rendered image of a pig with wings and a top hat flying over a happy futuristic scifi city with lots of greenery?"
        }
      ]
    }
  ],
  "generationConfig": {
    "responseModalities": [
      "IMAGE"
    ]
  }
}'

返回响应

🟢200成功

响应示例

json
{}