Anthropic
Anthropic provides access to Claude models including Claude 4 Sonnet, Claude 4.1 Opus, and other cutting-edge language models. Braintrust integrates seamlessly with Anthropic through direct API access, wrapAnthropic wrapper functions for automatic tracing, and proxy support.
Setup
To use Anthropic with Braintrust, you'll need an Anthropic API key.
- Visit Anthropic's Console and create a new API key
- Add the Anthropic API key to your organization's AI providers
- Set the Anthropic API key and your Braintrust API key as environment variables
API keys are encrypted using 256-bit AES-GCM encryption and are not stored or logged by Braintrust.
Install the braintrust and @anthropic-ai/sdk packages.
pnpm add braintrust @anthropic-ai/sdkTrace with Anthropic
Trace your Anthropic LLM calls for observability and monitoring.
Trace automatically with wrapAnthropic
Braintrust provides wrapAnthropic (TypeScript) and wrap_anthropic (Python) functions that automatically log Anthropic API calls. Braintrust handles streaming, metric collection (including cached tokens), and other details.
Initialize the logger and pass the Anthropic client to the wrapAnthropic function.
wrapAnthropic is a convenience function that wraps the Anthropic client with the Braintrust logger. For more control, learn how to customize traces.
Evaluate with Anthropic
Evaluations distill the non-deterministic outputs of Anthropic models into an effective feedback loop that enables you to ship more reliable, higher quality products. The Braintrust Eval function is composed of a dataset of user inputs, a task, and a set of scorers. To learn more about evaluations, see the Experiments guide.
Basic Anthropic eval setup
Evaluate the outputs of Anthropic models with Braintrust.
Use Anthropic as an LLM judge
You can use Anthropic models to score the outputs of other AI systems. This example uses the LLMClassifierFromSpec scorer to score the relevance of the outputs of an AI system.
Install the autoevals package to use the LLMClassifierFromSpec scorer.
pnpm add autoevalsCreate a scorer that uses the LLMClassifierFromSpec scorer to score the relevance of the output. You can then include relevanceScorer as a scorer in your Eval function (see above).
Additional features
Tool use
Anthropic's tool use (function calling) is fully supported:
System prompts
Anthropic models support system prompts for better instruction following.
Cached tokens
Anthropic supports prompt caching to reduce costs and latency for repeated content.
Multimodal content, attachments, errors, and masking sensitive data
To learn more about these topics, check out the customize traces guide.
Use Anthropic with Braintrust AI proxy
You can also access Anthropic models through the Braintrust AI Proxy, which provides a unified, OpenAI-compatible interface for multiple providers.
Models and capabilities
| Model | Multimodal | Reasoning | Max input | Max output | Input $/1M | Output $/1M |
|---|---|---|---|---|---|---|
| claude-sonnet-4-20250514 | 200,000 | 64,000 | $3.00 | $15.00 | ||
| claude-4-sonnet-20250514 | 200,000 | 64,000 | $3.00 | $15.00 | ||
| claude-3-7-sonnet-latest | 200,000 | 128,000 | $3.00 | $15.00 | ||
| claude-3-7-sonnet-20250219 | 200,000 | 128,000 | $3.00 | $15.00 | ||
| claude-3-5-haiku-latest | 200,000 | 8,192 | $1.00 | $5.00 | ||
| claude-3-5-haiku-20241022 | 200,000 | 8,192 | $0.80 | $4.00 | ||
| claude-3-5-sonnet-latest | 200,000 | 8,192 | $3.00 | $15.00 | ||
| claude-3-5-sonnet-20241022 | 200,000 | 8,192 | $3.00 | $15.00 | ||
| claude-3-5-sonnet-20240620 | 200,000 | 8,192 | $3.00 | $15.00 | ||
| claude-opus-4-1-20250805 | 200,000 | 32,000 | $15.00 | $75.00 | ||
| claude-opus-4-20250514 | 200,000 | 32,000 | $15.00 | $75.00 | ||
| claude-4-opus-20250514 | 200,000 | 32,000 | $15.00 | $75.00 | ||
| claude-3-opus-latest | 200,000 | 4,096 | $15.00 | $75.00 | ||
| claude-3-opus-20240229 | 200,000 | 4,096 | $15.00 | $75.00 | ||
| claude-3-sonnet-20240229 | 200,000 | 4,096 | $3.00 | $15.00 | ||
| claude-3-haiku-20240307 | 200,000 | 4,096 | $0.25 | $1.25 | ||
| claude-instant-1.2 | 100,000 | 8,191 | $0.163 | $0.551 | ||
| claude-instant-1 | 100,000 | 8,191 | $1.63 | $5.51 | ||
| claude-2.1 | 200,000 | 8,191 | $8.00 | $24.00 | ||
| claude-2.0 | ﹣ | ﹣ | $8.00 | $24.00 | ||
| claude-2 | 100,000 | 8,191 | $8.00 | $24.00 |