# Anthropic SDK Compatibility

Infron AI AI provides a compatibility API that allows you to use the Anthropic SDK with Infron AI AI models. This is useful if you are already using the Anthropic SDK and want to switch to Infron AI AI models.

## Quick Start Guide <a href="#quick-start-guide" id="quick-start-guide"></a>

This guide demonstrates how to use the Anthropic SDK with the Infron AI AI models step by step.

### 1. Install the Anthropic SDK <a href="#id-1-install-the-anthropic-sdk" id="id-1-install-the-anthropic-sdk"></a>

```sh
pip install anthropic
```

### 2. Initialize the Client <a href="#id-2-initialize-the-client" id="id-2-initialize-the-client"></a>

The Anthropic SDKs are designed to pull the API key and base URL from the environmental variables: `ANTHROPIC_API_KEY` and `ANTHROPIC_BASE_URL`. Also, you can supply the parameters to the Anthropic client when initializing it.

* Using Environment Variables

```sh
export ANTHROPIC_BASE_URL="https://llm.onerouter.pro"
export ANTHROPIC_API_KEY="<<Your API Key>>"
```

* Set the parameters while initializing the Anthropic client

{% tabs %}
{% tab title="Python" %}

```python
import anthropic

client = anthropic.Anthropic(
    base_url="https://llm.onerouter.pro",
    api_key="<<Your API Key>>"
)

message = client.messages.create(
    model="anthropic/claude-sonnet-4.5",
    max_tokens=1000,
    temperature=1,
    system=[
        {
            "type": "text",
            "text": "You are a world-class poet. Respond only with short poems."
        }
    ],
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": "Why is the ocean salty?"
                }
            ]
        }
    ]
)

print(message.content)
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://infronai.gitbook.io/docs/frameworks-and-integrations/anthropic-sdk-compatibility.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
