> ## Documentation Index
> Fetch the complete documentation index at: https://apixo.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Gemini API Gateway：可用模型、定价与代码示例

> 通过 APIXO 接入当前的 Gemini 模型，了解兼容的 HTTP 请求和 SDK 用法、流式响应以及已核实的标准 token 费率。

为以下列出的 8 个 Gemini 模型 ID 选择一种兼容的集成方式。配置 APIXO 基础 URL 和 API 密钥，然后选择精确的模型 ID。

> [!NOTE]
>
> Google 现在建议使用较新的交互 API 进行新的直接 Gemini 集成，并将生成内容标记为旧版。APIXO 当前发布的 Gemini 网关仍使用此处文档中的 `generateContent` 请求格式。除非 APIXO 明确添加支持，否则不要将交互 API 有效负载发送至该端点。

> [!NOTE]
>
> 模型可用性和标准价格核实于 2026 年 11 月 18 日。最新费率及账号适用价格见 [API 价目表](https://apixo.ai/pricing/api)。

> [!TIP]
>
> **选择您的集成方式：** [使用快速入门](#quickstart) 手动集成，或 [让 AI 自动实现](#let-an-ai-implement-it) 通过复制本页内容。

## 对比 Gemini 各型号及定价

| 模型 | 模型 ID | 推荐用于 | 输入 | 输出 | 缓存写入 | 缓存读取 | 节省比例 |
| - | - | - | -: | -: | -: | -: | -: |
| Gemini 4 Argon | `gemini-4-argon` | 特定模型的生成内容集成 | \$2.4 | \$12 | \$0 | \$0.12 | 40% |
| Gemini 4 Hydrogen | `gemini-4-hydrogen` | 特定模型的生成内容集成 | \$0.9 | \$4.5 | \$0 | \$0.045 | 40% |
| gemini-3.8-flash | `gemini-3.8-flash` | 特定模型的生成内容集成 | \$0.9 | \$4.5 | \$0 | \$0.09 | 40% |
| gemini-3.7-flash | `gemini-3.7-flash` | 特定模型的生成内容集成 | \$0.9 | \$4.5 | \$0 | \$0.09 | 40% |
| gemini-3.6-flash | `gemini-3.6-flash` | 特定模型的生成内容集成 | \$0.9 | \$4.5 | \$0 | \$0.09 | 40% |
| Gemini 3.5 Flash | `gemini-3.5-flash` | 适用于通用场景、多模态任务及高吞吐量工作负载的闪存模型 | \$0.9 | \$5.4 | \$0.09 | \$0.6 | 40% |
| Gemini 3.1 Pro Preview | `gemini-3.1-pro-preview` | 受益于专业 tier 的复杂推理与多模态任务 | \$1.2 | \$7.2 | \$0 | \$0.12 | 40% |
| Gemini 3 Flash Preview | `gemini-3-flash-preview` | 现有的 Gemini 3 闪存预览集成 | \$0.3 | \$1.8 | \$0 | \$0.03 | 40% |

价格以每 100 万 token 美元计。核价日期：2026-11-18。节省比例为标准输入价格与常规市场参考价格的对比。实际价格可能因账户而异。费率为 \$0 表示该价格表中对应缓存类别不另计费用。详情请见[API 定价](https://apixo.ai/pricing/api)。

## 需要修改的内容

| 设置 | APIXO 值 |
| - | - |
| SDK Base URL | `https://llm.apixo.ai` |
| 原始 HTTP 路径 | `POST /v1beta/models/{model}:generateContent` |
| 请求 URL | `https://llm.apixo.ai/v1beta/models/{model}:generateContent` |
| API密钥 | `APIXO_API_KEY` 来自 [APIXO API 密钥](https://apixo.ai/dashboard/api-keys) |
| API 密钥头 | `x-goog-api-key` |
| API 密钥值 | `$APIXO_API_KEY` |
| 模型位置 | REST 的 URL 路径为 `{model}`；SDK 中对应参数为 `model` |

## 快速入门

```bash theme={null}
export APIXO_API_KEY="your_apixo_api_key"
```

> [tab] cURL
>
> ```bash theme={null}
> curl -X POST "https://llm.apixo.ai/v1beta/models/gemini-3.8-flash:generateContent" \
>   -H "x-goog-api-key: $APIXO_API_KEY" \
>   -H "Content-Type: application/json" \
>   -d '{
>     "contents": [
>       {
>         "role": "user",
>         "parts": [{"text": "Say hello in one sentence."}]
>       }
>     ]
>   }'
> ```

> [tab] JavaScript
>
> ```javascript theme={null}
> import { GoogleGenAI } from "@google/genai";
>
> const ai = new GoogleGenAI({
>   apiKey: process.env.APIXO_API_KEY,
>   httpOptions: { baseUrl: "https://llm.apixo.ai" }
> });
>
> const response = await ai.models.generateContent({
>   model: "gemini-3.8-flash",
>   contents: "Say hello in one sentence."
> });
>
> console.log(response.text);
> ```

> [tab] Python
>
> ```python theme={null}
> import os
> from google import genai
> from google.genai import types
>
> client = genai.Client(
>     api_key=os.environ["APIXO_API_KEY"],
>     http_options=types.HttpOptions(base_url="https://llm.apixo.ai"),
> )
>
> response = client.models.generate_content(
>     model="gemini-3.8-flash",
>     contents="Say hello in one sentence.",
> )
>
> print(response.text)
> ```

> [!TIP]
>
> 示例使用 `gemini-3.8-flash`。在 REST 接口中，替换 URL 路径中的模型 ID；在 SDK 中，修改 `model` 参数。

## 让AI来实现它

### 将此页复制到 AI

使用页面菜单中的 **复制页面** 按钮，将复制的文档粘贴到 AI 编码工具中，并添加以下提示：

```text theme={null}
Integrate the APIXO Gemini-compatible Generate Content API into my existing
project using the documentation below.

Requirements:
- Use model gemini-3.8-flash unless my project already specifies another supported model.
- Read APIXO_API_KEY from an environment variable and keep it server-side.
- Preserve my current language, framework, and project structure.
- Add the smallest working integration and one minimal verification request.
- Do not invent endpoints, model IDs, or request fields that are not documented.
```

将提示中的 `gemini-3.8-flash` 替换为比较表中的任意模型 ID。

### 远程 MCP 可用性

将 `list_models` 与 `integration_type: llm_gateway` 结合使用来发现 Gemini 模型 ID。将选定的 ID 传递到 `get_model_schema` 以获取生成内容合约的 schema，或传递到 `get_integration_guide` 以完成服务器端 SDK 配置。[APIXO MCP](https://apixo.ai/docs/zh/integrations/mcp)

## 流式传输

```bash theme={null}
curl --no-buffer -X POST "https://llm.apixo.ai/v1beta/models/gemini-3.8-flash:streamGenerateContent?alt=sse" \
  -H "x-goog-api-key: $APIXO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [
      {
        "role": "user",
        "parts": [{"text": "Stream a short hello message."}]
      }
    ]
  }'
```

`alt=sse` 查询参数请求 Server-Sent Events，以便每个响应块在到达时可被逐个处理。

## 支持的 Gemini 模型

使用上述所示兼容 API 格式中的一个精确模型 ID。

* `gemini-4-argon`
* `gemini-4-hydrogen`
* `gemini-3.8-flash`
* `gemini-3.7-flash`
* `gemini-3.6-flash`
* `gemini-3.5-flash`
* `gemini-3.1-pro-preview`
* `gemini-3-flash-preview`

要切换型号，请保留端点系列、API密钥和请求格式，然后更改型号ID。

## 故障排除

* `401`：API密钥缺失或无效
* `400`：无效的 Gemini 请求体、端点或不受支持的模型 ID
* `429`：速率限制或临时容量限制
* `502`/`504`：服务错误或超时

对`429`、`502`和`504`使用退避重试；在重试前先修复`400`和`401`。

## 相关链接

* [Chat API概述](https://apixo.ai/docs/zh/llm)
* [支持的型号](https://apixo.ai/docs/zh/llm/supported-models.md)
* [LLM 身份验证](https://apixo.ai/docs/zh/llm/authentication.md)
* [LLM 流媒体](https://apixo.ai/docs/zh/llm/streaming.md)
* [LLM 错误并重试](https://apixo.ai/docs/zh/llm/errors-retry.md)
* [安装APIXO MCP](https://apixo.ai/docs/zh/integrations/mcp/installation.md)
* [Gemini API 参考](https://ai.google.dev/api)
* [在 APIXO 探索 Gemini 模型](https://apixo.ai/models/llm/gemini)
* [API定价](https://apixo.ai/pricing/api)

## 在 APIXO 上调用模型

使用 [API 定价](https://apixo.ai/pricing/api) 了解当前模型的可用性和价格。即使 Playground 选择器尚未添加模型，也可直接使用上述 API 模型 ID。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.