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

# Gemini 原生协议接入

> 使用 generateContent 请求格式调用 APIONE。

已有应用使用 Gemini 原生格式时，可连接 APIONE 的 `https://api.apione.ai/v1beta`。先确认所选模型支持此协议；如果应用使用 OpenAI 格式，请按 [Chat Completions](https://apione.ai/docs/models/chat.md) 配置。

## 发送最小请求

先按[快速开始](https://apione.ai/docs/quickstart.md)设置 `APIONE_API_KEY` 和 `APIONE_MODEL`，后者填[当前 Key 可用的模型 ID](https://apione.ai/docs/models/catalog.md)。下面采用 Gemini 的基础文本格式：

```bash theme={null}
curl --fail-with-body --max-time 120 \
  "https://api.apione.ai/v1beta/models/${APIONE_MODEL:?请先设置 APIONE_MODEL}:generateContent" \
  -H "x-goog-api-key: ${APIONE_API_KEY:?请先设置 APIONE_API_KEY}" \
  -H "Content-Type: application/json" \
  --data '{"contents":[{"role":"user","parts":[{"text":"Hello"}]}]}'
```

模型放在 URL 中；对话放在 `contents[]`，文本放在 `parts[].text`。按原始模型 ID 填写，不要重复加 `models/`。

成功响应按 Gemini 格式读取 `candidates[].content.parts[].text`。候选可能没有文本；同时检查结束原因与错误信息。不要套用 OpenAI 的 `choices` 字段。

## 地址与兼容范围

| 客户端设置 | 地址 |
| - | - |
| 需要 Gemini Base URL | `https://api.apione.ai/v1beta` |
| 需要域名与版本分别配置 | 域名 `https://api.apione.ai`，版本 `v1beta` |

确认最终路径中的 `/v1beta` 只出现一次。APIONE 端点表还列有 `:streamGenerateContent`；先通过非流式文本测试，再按客户端及模型能力配置流式和其他参数。

Gemini CLI 的配置见[客户端教程](https://apione.ai/docs/guides/gemini-cli.md)。遇到问题时，记录实际返回的请求标识及字段名，并按[错误排查](https://apione.ai/docs/support/errors.md)处理。

接口依据：[APIONE 端点说明](https://apione.ai/zh/api-docs/docs/endpoints)。基础格式参考：[Google generateContent](https://ai.google.dev/api/generate-content)。


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