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

# Anthropic compatibility

SambaNova inference APIs are compatible with the Anthropic client libraries, so existing Anthropic-based applications can target SambaNova with minimal changes.

## Download the library

```bash theme={null}
pip install anthropic
```

## Use SambaNova APIs with the Anthropic client library

Configure the Anthropic client to use SambaNova by setting `base_url` and `api_key`.

<Note>
  Don't have a SambaNova API key? Get one from the [API keys page](https://cloud.sambanova.ai/apis).
</Note>

```python theme={null}
import anthropic

client = anthropic.Anthropic(
    base_url="https://api.sambanova.ai/v1",
    api_key="your-sambanova-api-key"
)
```

You also need to set `model` to a SambaNova model identifier when calling the API (see the [supported models](/en/models/sambacloud-models) page).

Alternatively, set the environment variables:

```bash theme={null}
export ANTHROPIC_BASE_URL="https://api.sambanova.ai/v1"
export ANTHROPIC_API_KEY="your-sambanova-api-key"
```

## Messages API

SambaNova exposes a `POST /v1/messages` endpoint compatible with the Anthropic Messages API standard, in addition to the Chat Completions and Responses endpoints. For full request/response details, examples for tool calling, streaming, thinking, and multi-turn conversations, see the [Messages API page](/en/features/messages).

## Count tokens

SambaNova also exposes a `POST /v1/messages/count_tokens` endpoint compatible with the Anthropic token-counting API. Use it to estimate the token cost of a request before sending it.

```python theme={null}
response = client.messages.count_tokens(
    model="gpt-oss-120b",
    system="You are a helpful assistant.",
    messages=[
        {"role": "user", "content": "What is the weather like in Paris?"}
    ]
)

print(response.input_tokens)
```

For the full parameter list, see the [API reference](/en/api-reference).
