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

Download the library

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.
Don’t have a SambaNova API key? Get one from the API keys page.
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 page). Alternatively, set the environment variables:
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.

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.
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.