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

# Drop-in SDKs

> Use the OpenAI, Anthropic, or Google AI SDK against Opper. Two lines of config, your code stays the same.

The gateway speaks the protocols you already use: the OpenAI, Anthropic, and Google AI APIs, with messages, tools, and multi-turn conversation working exactly as they do natively.

If you already use one of those SDKs, keep it. Point it at Opper and swap the API key for an Opper one, and every call now flows through the gateway. You get 300+ models, fallback routing, traces, and Control Plane rules without rewriting anything.

## Setup

For all three SDKs the change is the same:

1. Set the base URL to `https://api.opper.ai/v3/compat`
2. Pass your Opper API key as the SDK's normal `api_key`

Each SDK sends auth its own way (`Authorization: Bearer` for OpenAI, `x-api-key` for Anthropic, query string for Google), and Opper accepts whichever the SDK uses.

## SDK examples

<Tabs>
  <Tab title="OpenAI">
    <CodeGroup>
      ```python Python theme={null}
      import os
      from openai import OpenAI

      client = OpenAI(
          base_url="https://api.opper.ai/v3/compat",
          api_key=os.environ["OPPER_API_KEY"],
      )

      response = client.chat.completions.create(
          model="openai/gpt-5-mini",
          messages=[{"role": "user", "content": "Hello"}],
      )
      print(response.choices[0].message.content)
      ```

      ```typescript TypeScript theme={null}
      import OpenAI from "openai";

      const client = new OpenAI({
          baseURL: "https://api.opper.ai/v3/compat",
          apiKey: process.env.OPPER_API_KEY!,
      });

      const response = await client.chat.completions.create({
          model: "openai/gpt-5-mini",
          messages: [{ role: "user", content: "Hello" }],
      });
      console.log(response.choices[0].message.content);
      ```
    </CodeGroup>

    Works with `chat.completions.create`, `embeddings.create`, and `responses.create`.
  </Tab>

  <Tab title="Anthropic">
    <CodeGroup>
      ```python Python theme={null}
      import os
      from anthropic import Anthropic

      client = Anthropic(
          base_url="https://api.opper.ai/v3/compat",
          api_key=os.environ["OPPER_API_KEY"],
      )

      message = client.messages.create(
          model="anthropic/claude-sonnet-4-6",
          max_tokens=1024,
          messages=[{"role": "user", "content": "Hello"}],
      )
      print(message.content[0].text)
      ```

      ```typescript TypeScript theme={null}
      import Anthropic from "@anthropic-ai/sdk";

      const client = new Anthropic({
          baseURL: "https://api.opper.ai/v3/compat",
          apiKey: process.env.OPPER_API_KEY!,
      });

      const message = await client.messages.create({
          model: "anthropic/claude-sonnet-4-6",
          max_tokens: 1024,
          messages: [{ role: "user", content: "Hello" }],
      });
      if (message.content[0].type === "text") console.log(message.content[0].text);
      ```
    </CodeGroup>

    `client.models.list()` also works.
  </Tab>

  <Tab title="Google AI">
    <CodeGroup>
      ```python Python theme={null}
      import os
      from google import genai

      client = genai.Client(
          api_key=os.environ["OPPER_API_KEY"],
          http_options={"base_url": "https://api.opper.ai/v3/compat"},
      )

      response = client.models.generate_content(
          model="gemini/gemini-2.5-pro",
          contents="Hello",
      )
      print(response.text)
      ```

      ```typescript TypeScript theme={null}
      import { GoogleGenAI } from "@google/genai";

      const client = new GoogleGenAI({
          apiKey: process.env.OPPER_API_KEY!,
          httpOptions: { baseUrl: "https://api.opper.ai/v3/compat" },
      });

      const response = await client.models.generateContent({
          model: "gemini/gemini-2.5-pro",
          contents: "Hello",
      });
      console.log(response.text);
      ```
    </CodeGroup>
  </Tab>
</Tabs>

## Cross-vendor models

The `model` field is provider-prefixed: `openai/gpt-5.5`, `anthropic/claude-sonnet-4-6`, `gemini/gemini-2.5-pro`. You can call any of them from any SDK. Your code calling `client.messages.create(...)` with the Anthropic SDK can still talk to a Google model.

<Tip>
  Browse the full catalog on the [Models](/capabilities/models) page.
</Tip>

## Opper extras

Each SDK lets you send Opper-specific options through an extras field. Use them to wire in fallback models, attach tags for filtering traces, or skip automatic scoring.

| Option            | Does this                                                         |
| ----------------- | ----------------------------------------------------------------- |
| `fallback_models` | A list of models to try if the first one fails.                   |
| `tags`            | A key/value object for grouping calls in traces.                  |
| `span_uuid`       | Attach this call to a parent span you created with the Opper SDK. |
| `evaluate`        | Set to `false` to skip [Observe](/control-plane/observe) scoring. |

```python Python with extras theme={null}
response = client.chat.completions.create(
    model="openai/gpt-5-mini",
    messages=[{"role": "user", "content": "Hello"}],
    extra_body={
        "fallback_models": ["anthropic/claude-haiku-4-5"],
        "tags": {"user_id": "u_123"},
        "evaluate": False,
    },
)
```

## All the URLs

You usually don't need this. Your SDK appends the right path. For reference:

| URL                                   | What it mimics                                              |
| ------------------------------------- | ----------------------------------------------------------- |
| `POST /v3/compat/chat/completions`    | OpenAI Chat Completions                                     |
| `POST /v3/compat/responses`           | OpenAI Responses API                                        |
| `POST /v3/compat/embeddings`          | OpenAI Embeddings                                           |
| `POST /v3/compat/v1/messages`         | Anthropic Messages                                          |
| `GET /v3/compat/v1/models`            | Anthropic Models list                                       |
| `POST /v3/compat/v1beta/interactions` | Google AI Interactions                                      |
| `POST /v3/compat/openresponses`       | [OpenResponses](https://openresponses.org) (vendor-neutral) |

## Frameworks

<CardGroup cols={2}>
  <Card title="Vercel AI SDK" icon="bolt" href="/overview/integrations">
    Use Opper's native provider for `streamText` and `generateObject`. No compat layer needed.
  </Card>

  <Card title="LangChain / LlamaIndex" icon="link" href="/overview/integrations">
    Point them at the `/v3/compat` base URL.
  </Card>
</CardGroup>

## What's next

<CardGroup cols={2}>
  <Card title="Tool calling" icon="screwdriver-wrench" href="/build/gateway/tools">
    Let the model invoke your tools.
  </Card>

  <Card title="Vision & PDFs" icon="image" href="/build/multimodal/vision-pdfs">
    Send images and documents in messages.
  </Card>

  <Card title="Streaming" icon="bolt-lightning" href="/build/gateway/streaming">
    Stream the response token-by-token.
  </Card>

  <Card title="Structured output" icon="braces" href="/build/gateway/structured-output">
    Get JSON back, validated against a schema.
  </Card>
</CardGroup>
