聚合API接口文档
  1. Gemini原生格式
聚合API接口文档
  • 常用请求
    • 获取模型
      • 获取模型
      • 获取模型 - gemini
    • 文本嵌入
      • 文本嵌入
      • 文本嵌入 - gemini
    • 令牌余额查询
      GET
    • 基本请求
      POST
    • 流式请求
      POST
    • 连续对话
      POST
    • 识图请求 - url
      POST
    • 识图请求 - base64
      POST
    • 工具(函数)调用
      POST
    • 文档重排序
      POST
    • 流式出图/视频
      POST
    • gpt-5.1开思考显示
      POST
    • codex模型请求
      POST
    • chat兼容思考显示
      POST
    • 视频识别
      POST
    • PDF识别
      POST
    • 结构化输出
      POST
  • 图片/视频生成
    • OpenAI chat格式
      • 流式出图/视频(推荐)
      • 流式出图/视频 - 带图生成
    • Google 生图 - nano banana
      • Google Gemini生图
      • Google Gemini改图
      • Google Gemini生图 流式
    • OpenAI image格式
      • 生成图像
      • 编辑图像
    • OpenAI sora格式
      • 创建视频
      • 获取视频任务状态
      • 获取视频内容
    • Midjourney绘图
      • 任务提交
        • 文生图 - Imagine
        • 关联按钮动作 - Action
        • 图生文 - Describe
        • 图像混合 - Blend
        • 局部重绘 - Modal
      • 任务查询
        • 多任务查询 - ListByCondition
        • 单任务查询 - FetchFromTask
        • Seed查询 - ImageSeed
  • 音频转录
    • 音频转录
    • 音频翻译
    • 文本转语音
    • Gemini 生成音频(TTS)
  • 高阶用法
    • Gemini原生格式
      • 普通对话
        POST
      • 开启思考
        POST
      • 流式请求
        POST
      • 结构化输出
        POST
      • 函数调用
        POST
      • PDF识别
        POST
      • 图像识别
        POST
      • 视频识别
        POST
    • Anthropic原生格式
      • 普通对话
      • 流式请求
      • 开启思考
      • 图像识别
      • 函数调用
      • 内置联网
    • 对话完整传参示例
      • OpenAI对话格式 - chat
      • OpenAI对话格式 - responses
      • Claude对话格式 - messages
      • Gemini对话格式 - v1beta
  • 在代码工具使用
    • 在codex中使用
    • 在gemini cli中使用
    • 在claudecode中使用
  • 数据模型
    • Schemas
      • ErrorResponse
      • ModelsResponse
      • GeminiModelsResponse
      • ChatCompletionRequest
      • ChatCompletionResponse
      • CompletionRequest
      • CompletionResponse
      • ResponsesRequest
      • ResponsesResponse
      • ClaudeRequest
      • ClaudeResponse
      • EmbeddingRequest
      • EmbeddingResponse
      • ImageGenerationRequest
      • ImageResponse
      • AudioTranscriptionResponse
      • SpeechRequest
      • RerankRequest
      • RerankResponse
      • VideoRequest
      • ModerationRequest
      • VideoResponse
      • ModerationResponse
      • VideoTaskResponse
      • GeminiRequest
      • GeminiResponse
      • OpenAIVideoError
      • Model
      • Message
      • MessageContent
      • ToolCall
      • Tool
      • ResponseFormat
      • Usage
      • ClaudeMessage
      • VideoTaskMetadata
      • VideoTaskError
      • ChatCompletionStreamResponse
      • ResponsesStreamResponse
      • ImageEditRequest
      • AudioTranscriptionRequest
      • AudioTranslationRequest
      • OpenAIVideo
  1. Gemini原生格式

函数调用

POST
{{url}}/v1beta/models/gemini-2.5-flash:generateContent
最后修改时间:2025-11-29 15:25:18

请求参数

Query 参数

Header 参数

Body 参数application/json

示例
{
    "system_instruction": {
        "parts": [
            {
                "text": "You are a helpful lighting system bot. You can turn lights on and off, and you can set the color. Do not perform any other tasks."
            }
        ]
    },
    "tools": [
        {
            "function_declarations": [
                {
                    "name": "enable_lights",
                    "description": "Turn on the lighting system."
                },
                {
                    "name": "set_light_color",
                    "description": "Set the light color. Lights must be enabled for this to work.",
                    "parameters": {
                        "type": "object",
                        "properties": {
                            "rgb_hex": {
                                "type": "string",
                                "description": "The light color as a 6-digit hex string, e.g. ff0000 for red."
                            }
                        },
                        "required": [
                            "rgb_hex"
                        ]
                    }
                },
                {
                    "name": "stop_lights",
                    "description": "Turn off the lighting system."
                }
            ]
        }
    ],
    "tool_config": {
        "function_calling_config": {
            "mode": "auto"
        }
    },
    "contents": [
        {
            "role": "user",
            "parts": [
                {
                    "text": "Turn on the lights please."
                }
            ]
        }
    ]
}

请求示例代码

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 'http://api.example.com/v1beta/models/gemini-2.5-flash:generateContent?key=sk-xxx' \
--header 'Content-Type: application/json' \
--data-raw '{
    "system_instruction": {
        "parts": [
            {
                "text": "You are a helpful lighting system bot. You can turn lights on and off, and you can set the color. Do not perform any other tasks."
            }
        ]
    },
    "tools": [
        {
            "function_declarations": [
                {
                    "name": "enable_lights",
                    "description": "Turn on the lighting system."
                },
                {
                    "name": "set_light_color",
                    "description": "Set the light color. Lights must be enabled for this to work.",
                    "parameters": {
                        "type": "object",
                        "properties": {
                            "rgb_hex": {
                                "type": "string",
                                "description": "The light color as a 6-digit hex string, e.g. ff0000 for red."
                            }
                        },
                        "required": [
                            "rgb_hex"
                        ]
                    }
                },
                {
                    "name": "stop_lights",
                    "description": "Turn off the lighting system."
                }
            ]
        }
    ],
    "tool_config": {
        "function_calling_config": {
            "mode": "auto"
        }
    },
    "contents": [
        {
            "role": "user",
            "parts": [
                {
                    "text": "Turn on the lights please."
                }
            ]
        }
    ]
}'

返回响应

🟢200成功
application/json
Body

示例
{
    "candidates": [
        {
            "content": {
                "role": "model",
                "parts": [
                    {
                        "functionCall": {
                            "name": "enable_lights",
                            "args": {}
                        },
                        "thoughtSignature": "CpwBAePx/177Vlhuj0psYC3riGeT4MRwg9aaKRfmOneE43rc5mTuqPD+2fNoSde04iMifAICMuW8GUyLgH8Yh2Bf0lGty9N3kafJgAwHE4oH05/tqHEw8kqHmEOb825Ktz7MIh9n+aYJzLuyGdel3PRUcM6Fd58wBoowBHDJtVFIHyZTYArxWWqK/9KkpKL+VGh4HZCn/ngXckVQK3na"
                    }
                ]
            },
            "finishReason": "STOP",
            "avgLogprobs": -0.78177380561828613
        }
    ],
    "usageMetadata": {
        "promptTokenCount": 75,
        "candidatesTokenCount": 3,
        "totalTokenCount": 107,
        "trafficType": "ON_DEMAND",
        "promptTokensDetails": [
            {
                "modality": "TEXT",
                "tokenCount": 75
            }
        ],
        "candidatesTokensDetails": [
            {
                "modality": "TEXT",
                "tokenCount": 3
            }
        ],
        "thoughtsTokenCount": 29
    },
    "modelVersion": "gemini-2.5-flash",
    "createTime": "2025-11-29T15:25:23.292666Z",
    "responseId": "YxArabruEfO24_UP9PW30QQ"
}
修改于 2025-11-29 15:25:18
上一页
结构化输出
下一页
PDF识别
Built with