Gemini 3 Pro

Google Gemini 3 Pro 旗舰多模态模型,通过 OpenAI 兼容 /v1/chat/completions 接口提供。支持文本、图片、视频、音频、PDF 输入,内置 Google 搜索增强、函数调用和结构化 JSON 输出。

模型

模型名称上下文窗口推理
gemini-3-pro100 万 tokens是(默认开启)

定价

按 token 计费:

类型积分 / 百万 tokens价格 / 百万 tokens
输入 (Input)160 credits$0.80
输出 (Output)960 credits$4.80

接口地址

POST https://api.aivideoapi.ai/v1/chat/completions

兼容 OpenAI Chat Completions 协议。可直接使用 openai SDK,将 baseURL 指向 https://api.aivideoapi.ai/v1

创建对话

curl -X POST https://api.aivideoapi.ai/v1/chat/completions \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-3-pro",
    "messages": [
      { "role": "user", "content": "用简单的语言解释相对论" }
    ]
  }'

请求体

字段类型必填说明
modelstring必须为 gemini-3-pro
messagesarray对话消息
streamboolean是否流式输出(默认 true
toolsarray工具定义(googleSearch 或函数)
include_thoughtsboolean是否包含思考(默认 true
reasoning_effortstringlowhigh(默认 high
response_formatobjectJSON Schema 结构化输出

限制toolsresponse_format 不能同时使用;Google 搜索与函数调用也不能同时使用。

多模态消息

所有媒体类型(图片/视频/音频/PDF)都使用同一 image_url 结构:

{
  "role": "user",
  "content": [
    { "type": "text", "text": "这个文档讲了什么?" },
    { "type": "image_url", "image_url": { "url": "https://example.com/doc.pdf" } }
  ]
}

响应

{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1677652288,
  "model": "gemini-3-pro",
  "choices": [
    {
      "index": 0,
      "message": { "role": "assistant", "content": "相对论分为狭义和广义..." },
      "finish_reason": "stop"
    }
  ],
  "usage": { "prompt_tokens": 12, "completion_tokens": 86, "total_tokens": 98 }
}

示例

Google 搜索增强

curl -X POST https://api.aivideoapi.ai/v1/chat/completions \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-3-pro",
    "messages": [
      { "role": "user", "content": "今天 Bitcoin 价格" }
    ],
    "tools": [{ "type": "function", "function": { "name": "googleSearch" } }]
  }'

结构化输出

curl -X POST https://api.aivideoapi.ai/v1/chat/completions \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-3-pro",
    "messages": [
      { "role": "user", "content": "列出 3 位著名科学家" }
    ],
    "response_format": {
      "type": "json_schema",
      "json_schema": {
        "name": "scientists",
        "strict": true,
        "schema": {
          "type": "object",
          "properties": {
            "list": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "name": { "type": "string" },
                  "field": { "type": "string" }
                },
                "required": ["name", "field"]
              }
            }
          },
          "required": ["list"]
        }
      }
    }
  }'

常见错误码

请求失败时,API 返回 JSON 格式的错误响应:

{
  "error": {
    "code": "insufficient_credits",
    "message": "Your credit balance is too low. Please top up.",
    "type": "billing_error"
  }
}

错误码一览

HTTP 状态码错误码类型说明
400invalid_requestinvalid_request_error缺少必填参数或参数无效
401invalid_api_keyauthentication_errorAPI Key 无效、已禁用或已删除
402insufficient_creditsbilling_error积分余额不足,请充值
403ip_not_allowedpermission_error请求 IP 不在 Key 的白名单中
404model_not_foundinvalid_request_error模型不存在或已停用
404task_not_foundinvalid_request_error任务 ID 不存在
429rate_limit_exceededrate_limit_error请求过于频繁,请降低频率
429spend_limit_exceededbilling_error达到 Key 的消费限额(每小时/每天/总量)
500internal_errorapi_error服务器内部错误
503upstream_errorupstream_error上游 AI 服务返回错误

常见场景

invalid_request (400)

缺少必填字段或参数格式错误时返回。

{
  "error": {
    "code": "invalid_request",
    "message": "'model' is required.",
    "type": "invalid_request_error"
  }
}

insufficient_credits (402)

积分不足。可通过 GET /v1/credits 查询余额,前往 Dashboard > Billing 充值。

invalid_api_key (401)

可能原因:

  • Key 不以 sk- 开头
  • Key 已被禁用或删除
  • 用户账户已被封禁

upstream_error (503)

上游 AI 服务返回错误,可能原因:

  • 输入内容包含敏感或违规信息
  • 上游服务暂时不可用
  • 请求参数不被上游支持

因上游错误导致任务失败时,预扣积分会自动退还。