Gemini generateContent
Gemini REST 形态的兼容接口,支持流式(alt=sse)。
端点
POST/gemini/v1beta/models/{model}:generateContent
流式使用 :streamGenerateContent?alt=sse。请求体为 Gemini 标准 {contents:[{role, parts:[{text}]}], systemInstruction?, generationConfig?, tools?}。
curl "https://www.link42.ai/gemini/v1beta/models/gemini-3-pro:generateContent" \
-H "x-goog-api-key: $LINK42_API_KEY" \
-H "Content-Type: application/json" \
-d '{"contents": [{"role": "user", "parts": [{"text": "Summarise the benefits of an AI gateway."}]}]}'- usageMetadata 中的 promptTokenCount / candidatesTokenCount 是计费依据。
- 旧路径 /v1beta/models/... 继续兼容。/gemini 是 REST Base URL;Google GenAI SDK 自定义端点能力视版本与运行模式而定。
按模型对照
Gemini 请求体不做跨协议改写,contents[] 原样送到上游。
| 模型 ID | 名称 | 上游 | 计费 | 差异字段 | 限制与注意 |
|---|---|---|---|---|---|
| gemini-3-pro-preview | Gemini3-pro | Vertex AI | 按 token | generationConfig 支持 thinkingConfig(thinkingLevel 或 thinkingBudget)、temperature、topP、maxOutputTokens,另可带 safetySettings;响应 candidates[].content.parts[] 里可能带 thoughtSignature | 计费取 usageMetadata.promptTokenCount 与 candidatesTokenCount;thoughtsTokenCount 作为推理子集上报,但两种兼容档案下都不计费 |