> ## 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` | 受益於專業級的複雜推理和多模式工作 | \$1.2 | \$7.2 | \$0 | \$0.12 | 40% |
| Gemini 3 Flash Preview | `gemini-3-flash-preview` | 現有 Gemini 3 Flash 預覽集成 | \$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` |
| 模型位置 | URL 路徑 `{model}` 為 REST；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 情況下，請將模型 ID 更換為 URL 路徑中的值；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` 以進行產生內容合約，或傳送至 `get_integration_guide` 以進行伺服器端 SDK 設定。 [APIXO MCP](https://apixo.ai/docs/zh-hant/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 型號

使用這些精確模型 ID 之一以及上面顯示的兼容 API 格式。

* `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-hant/llm)
* [支援的型號](https://apixo.ai/docs/zh-hant/llm/supported-models.md)
* [LLM 身分驗證](https://apixo.ai/docs/zh-hant/llm/authentication.md)
* [LLM 串流](https://apixo.ai/docs/zh-hant/llm/streaming.md)
* [LLM 錯誤並重試](https://apixo.ai/docs/zh-hant/llm/errors-retry.md)
* [安裝APIXO MCP](https://apixo.ai/docs/zh-hant/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.