Anthropic

Anthropic Provider

The MultiRoute Anthropic wrapper provides high-availability for Claude models via the MultiRoute smart LLM/AI router.

Installation

pip install multiroute["anthropic"]

Basic Usage

Switching to MultiRoute requires only a change to your import statement.

import os
import anthropic
from multiroute.anthropic import Anthropic

# Set your keys
os.environ["MULTIROUTE_API_KEY"] = "your-multiroute-key"
os.environ["ANTHROPIC_API_KEY"] = "your-anthropic-key"

client = Anthropic()

message = client.messages.create(
    model="claude-3-5-sonnet-latest",
    max_tokens=1024,
    messages=[
        {"role": "user", "content": "Explain failover in one sentence."}
    ]
)

print(message.content[0].text)

On router unavailability, the SDK falls back to Anthropic's API using your ANTHROPIC_API_KEY.