> ## 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 Format Converter

> Use OpenAI and Anthropic models with Gemini SDK

## Overview

The Gemini Format Converter allows you to call **OpenAI** and **Anthropic** models using the Gemini SDK and API format. This is useful when you have existing code using the Gemini SDK but want to access other providers' models.

## Configuration

### SDK Configuration

Set your base URL to:

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

<Note>
  The SDK automatically appends the model path, so you only need to set the base
  URL to `/gemini`.
</Note>

### cURL / Direct API

For direct API calls, use the full endpoint:

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

## Usage Examples

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

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

    # Use OpenAI or Anthropic models
    model = genai.GenerativeModel("gpt-4o")  # or "claude-sonnet-4-20250514"

    response = model.generate_content("Hello, how are you?")
    print(response.text)
    ```
  </Tab>

  <Tab title="cURL">
    ```bash theme={null}
    curl "https://api.pipellm.ai/gemini/v1beta/models/gpt-4o:generateContent" \
      -H "Content-Type: application/json" \
      -H "x-goog-api-key: your-pipellm-api-key" \
      -d '{
        "contents": [
          {"role": "user", "parts": [{"text": "Hello, how are you?"}]}
        ]
      }'
    ```
  </Tab>

  <Tab title="Streaming (cURL)">
    ```bash theme={null}
    curl "https://api.pipellm.ai/gemini/v1beta/models/claude-sonnet-4-20250514:streamGenerateContent?alt=sse" \
      -H "Content-Type: application/json" \
      -H "x-goog-api-key: your-pipellm-api-key" \
      -d '{
        "contents": [
          {"role": "user", "parts": [{"text": "Tell me a story"}]}
        ]
      }'
    ```
  </Tab>
</Tabs>

## Supported Models

You can use any OpenAI or Anthropic model available on PipeLLM with the Gemini format:

| Provider  | Example Models                                        |
| --------- | ----------------------------------------------------- |
| OpenAI    | `gpt-4o`, `gpt-4o-mini`, `o1`                         |
| Anthropic | `claude-sonnet-4-20250514`, `claude-3-5-haiku-latest` |

## Feature Support

| Feature        | Status      |
| -------------- | ----------- |
| Streaming      | ✅ Supported |
| Tool Use       | ✅ Supported |
| Vision         | ✅ Supported |
| System Prompts | ✅ Supported |
| Thinking       | ✅ Supported |
