Anthropic SDK
The Anthropic SDK reads ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY. Set both and every call to Claude routes through TapPass.
export ANTHROPIC_BASE_URL=https://tappass.example.comexport ANTHROPIC_API_KEY=tp_...Python
Section titled “Python”import anthropic
client = anthropic.Anthropic() # picks up env varsmessage = client.messages.create( model="claude-3-5-sonnet-20241022", max_tokens=1024, messages=[{"role": "user", "content": "Hello"}],)Node / TypeScript
Section titled “Node / TypeScript”import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic(); // picks up env varsconst message = await client.messages.create({ model: "claude-3-5-sonnet-20241022", max_tokens: 1024, messages: [{ role: "user", content: "Hello" }],});Streaming
Section titled “Streaming”with client.messages.stream( model="claude-3-5-sonnet-20241022", max_tokens=1024, messages=[{"role": "user", "content": "Hi"}],) as stream: for text in stream.text_stream: print(text, end="", flush=True)What’s supported
Section titled “What’s supported”messages(sync, stream, async)- Tool use (
tool_use/tool_resultcontent blocks) - Vision (image content blocks)
- Extended thinking on Claude 3.7+
- Prompt caching —
cache_controlfields flow through untouched