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

# Gemini 格式转换器

> 使用 Gemini SDK 调用 OpenAI 和 Anthropic 模型

## 概述

Gemini 格式转换器允许您使用 Gemini SDK 和 API 格式调用 **OpenAI** 和 **Anthropic** 模型。当您已有使用 Gemini SDK 的代码，但想访问其他供应商的模型时，这非常有用。

## 配置

### SDK 配置

将 base URL 设置为：

```
https://api.pipellm.ai/gemini
```

<Note>SDK 会自动附加模型路径，因此您只需将 base URL 设置为 `/gemini`。</Note>

### cURL / 直接 API 调用

对于直接 API 调用，使用完整端点：

```
https://api.pipellm.ai/gemini/v1beta/models/{model}:generateContent
```

## 使用示例

<Tabs>
  <Tab title="Python SDK">
    ```python theme={"dark"}
    import google.generativeai as genai
    from google.generativeai import types

    # 使用 PipeLLM 配置
    genai.configure(
        api_key="your-pipellm-api-key",
        transport="rest",
        client_options={"api_endpoint": "api.pipellm.ai/gemini"}
    )

    # 使用 OpenAI 或 Anthropic 模型
    model = genai.GenerativeModel("gpt-5")  # 或 "claude-sonnet-4-6"

    response = model.generate_content("你好，最近怎么样？")
    print(response.text)
    ```
  </Tab>

  <Tab title="cURL">
    ```bash theme={"dark"}
    curl "https://api.pipellm.ai/gemini/v1beta/models/gpt-5:generateContent" \
      -H "Content-Type: application/json" \
      -H "x-goog-api-key: your-pipellm-api-key" \
      -d '{
        "contents": [
          {"role": "user", "parts": [{"text": "你好，最近怎么样？"}]}
        ]
      }'
    ```
  </Tab>
</Tabs>

## 支持的模型

您可以使用 PipeLLM 上所有可用的 OpenAI 或 Anthropic 模型：

| 供应商 | 示例模型 |
| - | - |
| OpenAI | `gpt-5` |
| Anthropic | `claude-sonnet-4-6` |

## 功能支持

| 功能 | 状态 |
| - | - |
| 流式输出 | ⚠️ 跨协议输出到 Gemini 客户端尚未实现 |
| 工具调用 | ✅ 支持 |
| 视觉 | ✅ 支持 |
| 系统提示 | ✅ 支持 |
| 思考 | ✅ 支持 |

## Gemini 3 模型

本转换器的目标是 OpenAI 和 Anthropic 模型，因此 Gemini 的
[thought signature](https://ai.google.dev/gemini-api/docs/generate-content/thought-signatures) 规则不适用于它。要用 Gemini SDK 调用 Gemini 3 模型，请使用
[Gemini 原生路由](/zh/api-reference/gemini/overview)。

<Warning>
  Gemini 格式的跨协议流式输出尚未实现。此转换入口请使用 `generateContent`；Gemini 模型的原生流式输出请使用[原生 Gemini 接口](/zh/api-reference/gemini/overview)。
</Warning>


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