跳转到主要内容

适合什么场景

  • 你要透传 Gemini 的 generationConfigthinkingConfig 或响应模态设置
  • 统一模型层需要保留 Google 专有能力

最小请求

{
  "model": "gemini-2.5-flash",
  "messages": [
    { "role": "user", "content": "总结这份报告。" }
  ],
  "model_extra": {
    "generationConfig": {
      "thinkingConfig": { "thinkingBudget": 512 },
      "responseMimeType": "application/json"
    }
  }
}

cURL 示例

curl https://mass.apigo.ai/v1/chat/completions \
  -H "Authorization: Bearer $TIDEMIND_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-2.5-flash",
    "messages": [
      { "role": "user", "content": "总结这份报告。" }
    ],
    "model_extra": {
      "generationConfig": {
        "thinkingConfig": { "thinkingBudget": 512 },
        "responseMimeType": "application/json"
      }
    }
  }'

Python 示例

import requests

response = requests.post(
    "https://mass.apigo.ai/v1/chat/completions",
    headers={
        "Authorization": "Bearer <TIDEMIND_API_KEY>",
        "Content-Type": "application/json",
    },
    json={
        "model": "gemini-2.5-flash",
        "messages": [
            {"role": "user", "content": "总结这份报告。"}
        ],
        "model_extra": {
            "generationConfig": {
                "thinkingConfig": {"thinkingBudget": 512},
                "responseMimeType": "application/json",
            }
        },
    },
    timeout=60,
)
response.raise_for_status()

print(response.json()["choices"][0]["message"]["content"])

Node.js 示例

const response = await fetch("https://mass.apigo.ai/v1/chat/completions", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.TIDEMIND_API_KEY}`,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    model: "gemini-2.5-flash",
    messages: [
      { role: "user", content: "总结这份报告。" }
    ],
    model_extra: {
      generationConfig: {
        thinkingConfig: { thinkingBudget: 512 },
        responseMimeType: "application/json"
      }
    }
  })
});

const data = await response.json();
console.log(data.choices[0].message.content);

最佳实践

  • generationConfig 这类嵌套字段先做 schema 校验再透传
  • 同时记录模型名和扩展参数,便于回归测试