1. Gemini v1beta
梧柏API使用文档
WHBAI · Google Gemini 原生
  • WHBAI · Google Gemini 原生 (v1alpha)
  • WHBAI · Google Gemini 原生
  • WHBAI · Ideogram
  • WHBAI · Ideogram V3
  • WHBAI · Midjourney
  • WHBAI · Jimeng
  • WHBAI · Kling
  • WHBAI · Luma
  • WHBAI · Luma V1
  • WHBAI · Omni 视频
  • WHBAI · Pixverse
  • WHBAI · Runway
  • WHBAI · Sora2
  • WHBAI · 统一视频 VEO
  • WHBAI · Vidu
  • WHBAI · 豆包 Volc
  • WHBAI · Suno
  • WHBAI · Playground
  • WHBAI · 账号与令牌
  • WHBAI · 阿里 Pix
  • WHBAI · 阿里百炼
  • WHBAI · 私域人像
  • WHBAI · Fal.ai
  • WHBAI · Replicate
  • WHBAI · 腾讯云 VOD
  • WHBAI · MiniMax
  • WHBAI · 支持模型列表
  • WHBAI · Grok Imagine
  • WHBAI · Seedance 2.0
  • WHBAI · TypeSafe
  • WHBAI · OpenAI 兼容
  • Gemini v1beta
    • Gemini 原生内容生成
      POST
    • 视频理解-url [原生格式] 开发中
      POST
    • 文本生成-流
      POST
    • 文本生成+思考-流
      POST
    • 图片生成
      POST
    • 图片生成 gemini-2.5-flash-image 控制宽高比
      POST
    • 图片生成 gemini-3-pro-image-preview 控制宽高比 +清晰度
      POST
    • 图片编辑
      POST
    • 谷歌联网搜索
      POST
    • TTS 文本转语音
      POST
    • 文本生成 gemini-3-pro-preview:generateContent
      POST
    • Imagen 生成图片
      POST
    • Imagen 4 开发中
      POST
    • gemini-tts文本转语音
      POST
    • 文本嵌入
      POST
    • gemini-3.1-flash-lite-image
      POST
  • 数据模型
    • PostV1betaModelsModeNameGenerateContentRequest
    • PostV1betaModelsGemini25FlashImageGenerateContentRequest
    • PostV1betaModelsGemini3ProImagePreviewGenerateContentRequest
    • PostV1betaModelsGemini20FlashExpImageGenerationGenerateContentRequest
    • PostV1betaModelsGemini25FlashPreviewTtsGenerateContentRequest
    • PostV1betaModelsImagen40UltraGenerate001PredictRequest
    • PostV1betaModelsImagen40Generate001PredictRequest
    • PostV1betaModelsGemini25ProPreviewTtsGenerateContentRequest
    • PostV1betaModelsGeminiEmbedding001EmbedContentRequest
    • Gemini 3.1 Flash-Lite Image generateContent Request
    • PostV1betaModelsGemini31FlashLiteImageGenerateContentResponse
    • NewApiError
  1. Gemini v1beta

gemini-3.1-flash-lite-image

POST
/v1beta/models/gemini-3.1-flash-lite-image:generateContent
官方文档:https://ai.google.dev/gemini-api/docs/image-generation?hl=zh-cn — Gemini 3.1 Flash-Lite Image(Nano Banana 2 Lite)文生图、图生图、视频转图与图像编辑。

网站中的模型与调用示例#

gemini-3.1-flash-lite-image#

请求参数#

{
  "contentType": "application/json",
  "properties": {
    "contents": {
      "description": "对话内容列表,必填。文生图时至少包含 1 条 user 消息;图生图/编辑时在 parts 中附带 inlineData 或 fileData;多轮编辑时按时间顺序追加历史消息。上游约束:总输入 token 不超过 65536;单文件输入不超过 500MB。",
      "items": {
        "additionalProperties": false,
        "properties": {
          "parts": {
            "description": "消息分片列表。每个 part 至少包含 text、inlineData、fileData 之一。参考图最多 14 张,官方建议 ≤3 张以获得最佳一致性。",
            "items": {
              "additionalProperties": false,
              "anyOf": [
                {
                  "required": [
                    "text"
                  ]
                },
                {
                  "required": [
                    "inlineData"
                  ]
                },
                {
                  "required": [
                    "fileData"
                  ]
                }
              ],
              "description": "单条内容分片。同一 part 通常只使用一种主要内容类型。",
              "properties": {
                "fileData": {
                  "additionalProperties": false,
                  "description": "通过 URI 引用的媒体文件,常用于 GCS / File API 上传后的参考图。",
                  "properties": {
                    "fileUri": {
                      "description": "媒体文件 URI,如 gs://bucket/object 或 Google File API 返回的 file URI。上游约束:文件必须可被模型访问。",
                      "minLength": 1,
                      "type": "string",
                      "x-i18n": {
                        "en-US": {
                          "description": "Media file URI, such as gs://bucket/object or the file URI returned by the Google File API. Upstream constraint: The file must be accessible to the model."
                        }
                      }
                    },
                    "mimeType": {
                      "description": "文件 MIME 类型。",
                      "enum": [
                        "image/png",
                        "image/jpeg",
                        "image/webp",
                        "video/mp4"
                      ],
                      "type": "string",
                      "x-apifox-enum": [
                        {
                          "description": "参考图/编辑原图",
                          "name": "PNG",
                          "value": "image/png"
                        },
                        {
                          "description": "参考图/编辑原图",
                          "name": "JPEG",
                          "value": "image/jpeg"
                        },
                        {
                          "description": "参考图",
                          "name": "WebP",
                          "value": "image/webp"
                        },
                        {
                          "description": "视频转图输入",
                          "name": "MP4",
                          "value": "video/mp4"
                        }
                      ],
                      "x-i18n": {
                        "en-US": {
                          "description": "File MIME type."
                        }
                      }
                    }
                  },
                  "required": [
                    "mimeType",
                    "fileUri"
                  ],
                  "type": "object",
                  "x-i18n": {
                    "en-US": {
                      "description": "Media files referenced by URI, often used for reference images uploaded by GCS/File API."
                    }
                  }
                },
                "inlineData": {
                  "additionalProperties": false,
                  "description": "内联媒体数据,常用于本地图片/视频 Base64 上传。上游约束:图片每张按 1120 input tokens 计费;视频按 1fps 采样,每帧 70 tokens,音轨忽略。",
                  "properties": {
                    "data": {
                      "contentEncoding": "base64",
                      "description": "Base64 编码的媒体内容,不含 data URI 前缀。上游约束:单文件总大小 ≤500MB。",
                      "minLength": 1,
                      "type": "string",
                      "x-i18n": {
                        "en-US": {
                          "description": "Base64 encoded media content without the data URI prefix. Upstream constraints: The total size of a single file is ≤500MB."
                        }
                      }
                    },
                    "mimeType": {
                      "description": "媒体 MIME 类型。图片常用 image/png、image/jpeg;视频常用 video/mp4。上游约束:格式不合法时返回 400。",
                      "enum": [
                        "image/png",
                        "image/jpeg",
                        "image/webp",
                        "image/gif",
                        "video/mp4",
                        "video/quicktime",
                        "video/webm"
                      ],
                      "type": "string",
                      "x-apifox-enum": [
                        {
                          "description": "适合编辑、透明背景场景",
                          "name": "PNG 图片",
                          "value": "image/png"
                        },
                        {
                          "description": "适合照片类参考图",
                          "name": "JPEG 图片",
                          "value": "image/jpeg"
                        },
                        {
                          "description": "压缩图片参考",
                          "name": "WebP 图片",
                          "value": "image/webp"
                        },
                        {
                          "description": "动图参考,按静态帧处理",
                          "name": "GIF 图片",
                          "value": "image/gif"
                        },
                        {
                          "description": "视频转图输入;按 1fps 采样",
                          "name": "MP4 视频",
                          "value": "video/mp4"
                        },
                        {
                          "description": "视频转图输入",
                          "name": "MOV 视频",
                          "value": "video/quicktime"
                        },
                        {
                          "description": "视频转图输入",
                          "name": "WebM 视频",
                          "value": "video/webm"
                        }
                      ],
                      "x-i18n": {
                        "en-US": {
                          "description": "Media MIME type. Image/png, image/jpeg are commonly used for pictures; video/mp4 is commonly used for videos. Upstream constraint: Return 400 when the format is illegal."
                        }
                      }
                    }
                  },
                  "required": [
                    "mimeType",
                    "data"
                  ],
                  "type": "object",
                  "x-i18n": {
                    "en-US": {
                      "description": "Inline media data, often used for local image/video Base64 upload. Upstream constraints: Each picture is billed at 1120 input tokens; the video is sampled at 1fps, 70 tokens per frame, and the audio track is ignored."
                    }
                  }
                },
                "text": {
                  "description": "文本提示词或编辑指令。文生图时必填;图生图/编辑时与图片 part 组合使用。",
                  "minLength": 1,
                  "type": "string",
                  "x-i18n": {
                    "en-US": {
                      "description": "Text prompt words or editing instructions. Required when creating a picture by text; used in combination with the picture part when creating a picture/editing."
                    }
                  }
                }
              },
              "type": "object",
              "x-i18n": {
                "en-US": {
                  "description": "Single piece of content is fragmented. Usually only one main content type is used for the same part."
                }
              }
            },
            "maxItems": 15,
            "minItems": 1,
            "type": "array",
            "x-i18n": {
              "en-US": {
                "description": "List of message fragments. Each part contains at least one of text, inlineData, and fileData. The maximum number of reference pictures is 14, and the official recommendation is ≤3 for best consistency."
              }
            }
          },
          "role": {
            "default": "user",
            "description": "消息角色。首条通常为 user;多轮编辑时可在 user/model 间交替。",
            "enum": [
              "user",
              "model"
            ],
            "type": "string",
            "x-apifox-enum": [
              {
                "description": "用户输入,包含文本、图片、视频等",
                "name": "用户",
                "value": "user"
              },
              {
                "description": "模型历史回复,用于多轮图像编辑上下文",
                "name": "模型",
                "value": "model"
              }
            ],
            "x-i18n": {
              "en-US": {
                "description": "Message role. The first entry is usually user; you can alternate between user/model during multiple rounds of editing."
              }
            }
          }
        },
        "required": [
          "parts"
        ],
        "type": "object"
      },
      "minItems": 1,
      "type": "array",
      "x-i18n": {
        "en-US": {
          "description": "Conversation content list, required. At least 1 user message must be included when creating a graph; inlineData or fileData must be attached to parts when creating a graph/editing; historical messages must be appended in chronological order during multiple rounds of editing. Upstream constraints: The total input tokens do not exceed 65536; the single file input does not exceed 500MB."
        }
      }
    },
    "generationConfig": {
      "additionalProperties": true,
      "description": "生成配置。生图场景下 responseModalities 必须包含 IMAGE;imageConfig 控制宽高比与输出格式;thinkingConfig 可选。",
      "properties": {
        "candidateCount": {
          "const": 1,
          "default": 1,
          "description": "候选结果数量。该模型固定为 1,传入其他值可能被忽略或报错。",
          "type": "integer",
          "x-i18n": {
            "en-US": {
              "description": "Number of candidate results. This model is fixed to 1, other values ​​passed in may be ignored or an error will be reported."
            }
          }
        },
        "imageConfig": {
          "additionalProperties": false,
          "description": "图像生成配置。该模型仅支持 1K 输出;不支持 512px / 2K / 4K。",
          "properties": {
            "aspectRatio": {
              "default": "1:1",
              "description": "输出图片宽高比。默认 1:1。仅改变比例,不改变 1K 像素量级。",
              "enum": [
                "1:1",
                "3:2",
                "2:3",
                "3:4",
                "4:3",
                "1:4",
                "4:1",
                "4:5",
                "5:4",
                "1:8",
                "8:1",
                "9:16",
                "16:9",
                "21:9"
              ],
              "type": "string",
              "x-apifox-enum": [
                {
                  "description": "默认;适合社媒配图、头像",
                  "name": "1:1 正方形",
                  "value": "1:1"
                },
                {
                  "description": "标准横版照片比例",
                  "name": "3:2 横版",
                  "value": "3:2"
                },
                {
                  "description": "标准竖版照片比例",
                  "name": "2:3 竖版",
                  "value": "2:3"
                },
                {
                  "description": "竖版海报",
                  "name": "3:4 竖版",
                  "value": "3:4"
                },
                {
                  "description": "传统横屏比例",
                  "name": "4:3 横版",
                  "value": "4:3"
                },
                {
                  "description": "超长竖条图",
                  "name": "1:4 极窄竖版",
                  "value": "1:4"
                },
                {
                  "description": "超长横条图",
                  "name": "4:1 极宽横版",
                  "value": "4:1"
                },
                {
                  "description": "Instagram 竖图常用",
                  "name": "4:5 竖版",
                  "value": "4:5"
                },
                {
                  "description": "接近正方形横版",
                  "name": "5:4 横版",
                  "value": "5:4"
                },
                {
                  "description": "极端竖长图",
                  "name": "1:8 超窄竖版",
                  "value": "1:8"
                },
                {
                  "description": "极端横长图",
                  "name": "8:1 超宽横版",
                  "value": "8:1"
                },
                {
                  "description": "短视频封面、手机竖屏",
                  "name": "9:16 竖屏",
                  "value": "9:16"
                },
                {
                  "description": "横幅、缩略图、演示文稿",
                  "name": "16:9 横屏",
                  "value": "16:9"
                },
                {
                  "description": "电影宽银幕风格",
                  "name": "21:9 超宽屏",
                  "value": "21:9"
                }
              ],
              "x-i18n": {
                "en-US": {
                  "description": "Output picture aspect ratio. Default 1:1. Only the scale is changed, not the 1K pixel magnitude."
                }
              }
            },
            "imageSize": {
              "const": "1K",
              "default": "1K",
              "description": "输出分辨率。该模型仅支持 1K(约 1024×1024 像素量级)。传入 512、2K、4K 会被拒绝或忽略。必须使用大写 K。",
              "type": "string",
              "x-i18n": {
                "en-US": {
                  "description": "Output resolution. This model only supports 1K (approximately 1024×1024 pixels). Incoming 512, 2K, 4K will be rejected or ignored. A capital K is required."
                }
              }
            },
            "outputMimeType": {
              "description": "输出图片 MIME 类型。不传时由上游决定。",
              "enum": [
                "image/png",
                "image/jpeg",
                "image/webp"
              ],
              "type": "string",
              "x-apifox-enum": [
                {
                  "description": "默认推荐;适合需要透明背景的场景",
                  "name": "PNG",
                  "value": "image/png"
                },
                {
                  "description": "体积更小,适合照片风格输出",
                  "name": "JPEG",
                  "value": "image/jpeg"
                },
                {
                  "description": "高压缩比图片格式",
                  "name": "WebP",
                  "value": "image/webp"
                }
              ],
              "x-i18n": {
                "en-US": {
                  "description": "Output image MIME type. If it is not passed, it will be decided by the upstream."
                }
              }
            }
          },
          "type": "object",
          "x-i18n": {
            "en-US": {
              "description": "Image generation configuration. This model only supports 1K output; 512px / 2K / 4K is not supported."
            }
          }
        },
        "maxOutputTokens": {
          "description": "最大输出 token 数。该模型输出上限 4096。图像输出按 1120 tokens/张计费。",
          "maximum": 4096,
          "minimum": 1,
          "type": "integer",
          "x-i18n": {
            "en-US": {
              "description": "The maximum number of output tokens. The model output is capped at 4096. Image output is charged at 1120 tokens/image."
            }
          }
        },
        "responseModalities": {
          "description": "输出模态列表。生图时必须包含 IMAGE;若同时需要文字说明,可传 [\"IMAGE\",\"TEXT\"]。仅传 TEXT 时不会返回图片。",
          "items": {
            "enum": [
              "IMAGE",
              "TEXT"
            ],
            "type": "string",
            "x-apifox-enum": [
              {
                "description": "返回生成图片,生图场景必填",
                "name": "图片",
                "value": "IMAGE"
              },
              {
                "description": "可同时返回文本说明;单独使用时不会生成图片",
                "name": "文本",
                "value": "TEXT"
              }
            ]
          },
          "minItems": 1,
          "type": "array",
          "uniqueItems": true,
          "x-i18n": {
            "en-US": {
              "description": "Output modal list. IMAGE must be included when generating a picture; if text description is also required, [\"IMAGE\", \"TEXT\"] can be passed. No image will be returned when only TEXT is passed."
            }
          }
        },
        "temperature": {
          "default": 1,
          "description": "采样温度。值越高结果越多样。上游默认值 1.0。",
          "maximum": 2,
          "minimum": 0,
          "type": "number",
          "x-i18n": {
            "en-US": {
              "description": "Sampling temperature. The higher the value, the more diverse the results. The upstream default is 1.0."
            }
          }
        },
        "thinkingConfig": {
          "additionalProperties": false,
          "description": "思考模式配置,可选。用于复杂构图前先做内部推理。MINIMAL 适合低延迟;HIGH 适合复杂 prompt。思考 token 计入输出计费。",
          "properties": {
            "includeThoughts": {
              "default": false,
              "description": "是否在响应中返回思考过程。默认 false。返回的 thought part 不应作为最终图片展示。",
              "type": "boolean",
              "x-i18n": {
                "en-US": {
                  "description": "Whether to return the thought process in the response. Default false. The returned thought part should not be displayed as the final image."
                }
              }
            },
            "thinkingLevel": {
              "description": "思考强度。不能与 thinkingBudget 同时使用。",
              "enum": [
                "MINIMAL",
                "HIGH"
              ],
              "type": "string",
              "x-apifox-enum": [
                {
                  "description": "尽量少的思考 token;适合简单生图、低延迟场景",
                  "name": "最小思考",
                  "value": "MINIMAL"
                },
                {
                  "description": "更多内部推理;适合复杂构图、多细节 prompt",
                  "name": "高思考",
                  "value": "HIGH"
                }
              ],
              "x-i18n": {
                "en-US": {
                  "description": "Think intensity. Cannot be used together with thinkingBudget."
                }
              }
            }
          },
          "type": "object",
          "x-i18n": {
            "en-US": {
              "description": "Thinking mode configuration, optional. Do internal reasoning before using it in complex compositions. MINIMAL is suitable for low latency; HIGH is suitable for complex prompts. Think tokens count towards output billing."
            }
          }
        },
        "topP": {
          "default": 0.95,
          "description": "核采样阈值。上游默认值 0.95。",
          "maximum": 1,
          "minimum": 0,
          "type": "number",
          "x-i18n": {
            "en-US": {
              "description": "Kernel sampling threshold. Upstream default value 0.95."
            }
          }
        }
      },
      "type": "object",
      "x-i18n": {
        "en-US": {
          "description": "Generate configuration. In raw image scenarios, responseModalities must contain IMAGE; imageConfig controls the aspect ratio and output format; thinkingConfig is optional."
        }
      }
    },
    "response_format": {
      "description": "填url返回url,不填默认base64",
      "type": "string",
      "x-i18n": {
        "en-US": {
          "description": "Fill in the url and return the url, if not fill in the default base64"
        }
      }
    },
    "safetySettings": {
      "description": "安全设置,可选。控制各类有害内容过滤阈值。",
      "items": {
        "additionalProperties": false,
        "properties": {
          "category": {
            "description": "安全类别。",
            "enum": [
              "HARM_CATEGORY_HARASSMENT",
              "HARM_CATEGORY_HATE_SPEECH",
              "HARM_CATEGORY_SEXUALLY_EXPLICIT",
              "HARM_CATEGORY_DANGEROUS_CONTENT"
            ],
            "type": "string",
            "x-i18n": {
              "en-US": {
                "description": "Security Category."
              }
            }
          },
          "threshold": {
            "description": "阻断阈值。",
            "enum": [
              "BLOCK_NONE",
              "BLOCK_ONLY_HIGH",
              "BLOCK_MEDIUM_AND_ABOVE",
              "BLOCK_LOW_AND_ABOVE"
            ],
            "type": "string",
            "x-i18n": {
              "en-US": {
                "description": "Blocking threshold."
              }
            }
          }
        },
        "required": [
          "category",
          "threshold"
        ],
        "type": "object"
      },
      "type": "array",
      "x-i18n": {
        "en-US": {
          "description": "Security settings, optional. Control the filtering thresholds for various types of harmful content."
        }
      }
    },
    "systemInstruction": {
      "additionalProperties": false,
      "description": "系统指令,可选。用于约束输出风格、语言、格式等,如图生图时要求“只输出图片相关说明”或翻译场景限制输出内容。",
      "properties": {
        "parts": {
          "items": {
            "additionalProperties": false,
            "properties": {
              "text": {
                "description": "系统指令文本。",
                "minLength": 1,
                "type": "string",
                "x-i18n": {
                  "en-US": {
                    "description": "System command text."
                  }
                }
              }
            },
            "required": [
              "text"
            ],
            "type": "object"
          },
          "minItems": 1,
          "type": "array"
        }
      },
      "required": [
        "parts"
      ],
      "type": "object",
      "x-i18n": {
        "en-US": {
          "description": "System command, optional. Used to constrain the output style, language, format, etc. When generating pictures, it is required to \"output only descriptions related to pictures\" or translation scenarios limit the output content."
        }
      }
    }
  },
  "required": [
    "contents"
  ]
}

请求示例 · 新手推荐 · 文生图 · 1:1#

{
  "contents": [
    {
      "parts": [
        {
          "text": "A cute cat sitting on a wooden table, watercolor style."
        }
      ],
      "role": "user"
    }
  ],
  "generationConfig": {
    "imageConfig": {
      "aspectRatio": "1:1"
    },
    "responseModalities": [
      "IMAGE"
    ]
  },
  "response_format": "url"
}

请求示例 · 新手推荐 · 文生图 · 9:16 竖屏#

{
  "contents": [
    {
      "parts": [
        {
          "text": "A minimalist poster for a coffee shop, warm tones, clean typography space at top."
        }
      ],
      "role": "user"
    }
  ],
  "generationConfig": {
    "imageConfig": {
      "aspectRatio": "9:16"
    },
    "responseModalities": [
      "IMAGE"
    ]
  }
}

请求示例 · 进阶推荐 · 文生图 · Thinking + PNG 输出#

{
  "contents": [
    {
      "parts": [
        {
          "text": "A professional sports logo for a fictitious Seattle basketball team called the Seattle Sasquatch. Modern athletic branding, bold clean outlines. Color palette: moss green, cedar brown, and copper. Vector art style, isolated on solid black background."
        }
      ],
      "role": "user"
    }
  ],
  "generationConfig": {
    "imageConfig": {
      "aspectRatio": "3:2",
      "outputMimeType": "image/png"
    },
    "responseModalities": [
      "IMAGE"
    ],
    "thinkingConfig": {
      "includeThoughts": false,
      "thinkingLevel": "HIGH"
    }
  }
}

请求示例 · 进阶推荐 · 单轮图像编辑#

{
  "contents": [
    {
      "parts": [
        {
          "inlineData": {
            "data": "{{test_image_base64}}",
            "mimeType": "image/png"
          }
        },
        {
          "text": "Generate a doodle style version of the red flower in this image."
        }
      ],
      "role": "user"
    }
  ],
  "generationConfig": {
    "responseModalities": [
      "IMAGE"
    ]
  }
}

请求示例 · 进阶推荐 · 多参考图合成(≤3 张)#

{
  "contents": [
    {
      "parts": [
        {
          "inlineData": {
            "data": "{{ref_image_1_base64}}",
            "mimeType": "image/jpeg"
          }
        },
        {
          "inlineData": {
            "data": "{{ref_image_2_base64}}",
            "mimeType": "image/png"
          }
        },
        {
          "text": "A 3D stylized character render of a cheerful woman and her cute dog. Vibrant colors, expressive eyes, clean solid-color background, centered avatar composition."
        }
      ],
      "role": "user"
    }
  ],
  "generationConfig": {
    "imageConfig": {
      "aspectRatio": "4:3"
    },
    "responseModalities": [
      "IMAGE"
    ]
  }
}

请求示例 · 进阶推荐 · 视频转图片#

{
  "contents": [
    {
      "parts": [
        {
          "inlineData": {
            "data": "{{test_video_base64}}",
            "mimeType": "video/mp4"
          }
        },
        {
          "text": "Generate a postcard of the setting in this video."
        }
      ],
      "role": "user"
    }
  ],
  "generationConfig": {
    "responseModalities": [
      "IMAGE"
    ]
  }
}

请求参数

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

Body 参数application/json必填

示例
{
    "response_format": "url",
    "contents": [
        {
            "role": "user",
            "parts": [
                {
                    "text": "A cute cat sitting on a wooden table, watercolor style."
                }
            ]
        }
    ],
    "generationConfig": {
        "responseModalities": [
            "IMAGE"
        ],
        "imageConfig": {
            "aspectRatio": "1:1"
        }
    }
}

请求示例代码

Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
请求示例请求示例
Shell
JavaScript
Java
Swift
cURL
curl --location '/v1beta/models/gemini-3.1-flash-lite-image:generateContent' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
    "response_format": "url",
    "contents": [
        {
            "role": "user",
            "parts": [
                {
                    "text": "A cute cat sitting on a wooden table, watercolor style."
                }
            ]
        }
    ],
    "generationConfig": {
        "responseModalities": [
            "IMAGE"
        ],
        "imageConfig": {
            "aspectRatio": "1:1"
        }
    }
}'

返回响应

🟢200成功
application/json
Bodyapplication/json

示例
{
    "candidates": [
        {
            "content": {
                "role": "string",
                "parts": [
                    {
                        "inlineData": {
                            "mimeType": "string",
                            "data": "string"
                        },
                        "thoughtSignature": "string"
                    }
                ]
            },
            "finishReason": "string"
        }
    ],
    "usageMetadata": {
        "promptTokenCount": 0,
        "candidatesTokenCount": 0,
        "totalTokenCount": 0,
        "trafficType": "string",
        "promptTokensDetails": [
            {
                "modality": "string",
                "tokenCount": 0
            }
        ],
        "candidatesTokensDetails": [
            {
                "modality": "string",
                "tokenCount": 0
            }
        ]
    },
    "modelVersion": "string",
    "createTime": "string",
    "responseId": "string"
}
🟠400请求有误
🟠401没有权限
修改于 2026-10-24 18:33:06
上一页
文本嵌入
下一页
PostV1betaModelsModeNameGenerateContentRequest
Built with