Gemini
通过 Aiflow 的 OpenAI 兼容端点调用 Gemini 模型。
Aiflow 通过 Antigravity 提供 Gemini。调用方式与其他模型相同:使用 OpenAI 兼容 API
和同一个 sk-... 密钥。Aiflow 会把请求转换为 Gemini 格式,再把结果转换回来,
因此不需要 Google SDK,也不需要 Google API 密钥。
模型
| 模型 ID | 模型 |
|---|---|
ag/gemini-pro-agent | Gemini 3.1 Pro |
ag/gemini-3.6-flash-high | Gemini 3.6 Flash |
ag/gemini-3.7-flash-high | Gemini 3.7 Flash |
ag/gemini-3.8-flash-high | Gemini 3.8 Flash |
所有 ag/ 模型都会出现在 /v1/models 中。旧的
antigravity-gemini-... ID 仍可供已有客户端使用。
端点
Gemini 模型可用于以下两个端点:
| 方法 | 路径 |
|---|---|
POST | /v1/chat/completions |
POST | /v1/responses |
它们不能通过 /v1/messages 调用,Aiflow 也不提供原生 Gemini generateContent 端点。
Chat Completions
curl https://api.tryaiflow.io/v1/chat/completions \
-H "Authorization: Bearer $AIFLOW_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "ag/gemini-3.8-flash-high",
"messages": [
{ "role": "system", "content": "用一句话回答。" },
{ "role": "user", "content": "什么是互斥锁?" }
]
}'Responses
curl https://api.tryaiflow.io/v1/responses \
-H "Authorization: Bearer $AIFLOW_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "ag/gemini-pro-agent",
"instructions": "用一句话回答。",
"input": "什么是互斥锁?"
}'OpenAI SDK
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: process.env.AIFLOW_API_KEY,
baseURL: 'https://api.tryaiflow.io/v1',
});
const completion = await client.chat.completions.create({
model: 'ag/gemini-3.8-flash-high',
messages: [{ role: 'user', content: 'Reply with ok' }],
});
console.log(completion.choices[0].message.content);支持的输入
| 功能 | Chat Completions | Responses |
|---|---|---|
| 文本 | system、developer、user、assistant | instructions 和 input 消息 |
| 图片 | image_url,base64 data URL | input_image,base64 data URL |
| 函数工具 | type: "function" 的 tools | type: "function" 的 tools |
| 工具结果 | tool 消息 | function_call_output 项 |
| 输出上限 | max_tokens 或 max_completion_tokens | max_output_tokens |
| Temperature | temperature | 不转发 |
限制
- 仅支持函数工具。 网页搜索、文件搜索等内置工具会被拒绝。
- 不支持
previous_response_id。 每次请求都要在input中发送完整对话。 - 缓冲式流。
stream: true会返回合法的 SSE,但事件会在 Gemini 生成完毕后一起到达, 不会逐 token 推送。 - 仅限启用账号路由的密钥。 仅限上游路由的密钥会收到
403。如需在密钥上启用 Gemini,请联系支持。
Gemini 用量与其他模型共用同一个密钥预算,可通过 Usage API 查询。