1. 原生格式
undyingapi
  • 面板功能
  • 渠道指南
  • 模型指南
    • Gemini API 使用文档
  • 聊天(Chat)
    • 谷歌Gemini 接口
      • 原生格式
        • 图片生成
          POST
        • 图片生成 gemini-2.5-flash-image
          POST
        • 图片生成 gemini-2.5-flash-image 控制宽高比
          POST
        • 图片生成 gemini-3-pro-image-preview 控制宽高比 +清晰度
          POST
  • 应用设置教程
    • 获取令牌
    • Cherry Studio
    • 在线画图
    • Chat Box
  1. 原生格式

图片生成

POST
/v1beta/models/gemini-2.5-flash-image-preview:generateContent
官方文档:https://ai.google.dev/gemini-api/docs/image-generation?hl=zh-cn

请求参数

Authorization
在 Header 添加参数
Authorization
,其值为在 Bearer 之后拼接 Token
示例:
Authorization: Bearer ********************
Query 参数

Header 参数

Body 参数application/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": [
      "TEXT",
      "IMAGE"
    ]
  }
}

请求示例代码

Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location -g --request POST '/v1beta/models/gemini-2.5-flash-image-preview:generateContent?key={{YOUR_API_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": [
      "TEXT",
      "IMAGE"
    ]
  }
}'

返回响应

🟢200成功
application/json
Body

示例
{}
修改于 2025-11-25 11:22:47
上一页
Gemini API 使用文档
下一页
图片生成 gemini-2.5-flash-image
Built with