Installation
Setup
Set your Anthropic API key as an environment variable:Usage
Streaming
API Reference
ChatAnthropic
Model name to use (e.g.,
claude-sonnet-4-5-20250929, claude-opus-4-6-20250929).Maximum number of tokens to generate. If not specified, uses the model’s
max_output_tokens from its profile.Sampling temperature. A non-negative float that controls randomness in generation.
Number of most likely tokens to consider at each step.
Total probability mass of tokens to consider at each step (nucleus sampling).
Timeout for requests to Claude API in seconds.
Number of retries allowed for requests sent to the Claude API.
Custom stop sequences to end generation.
Anthropic API key. Automatically read from
ANTHROPIC_API_KEY environment variable if not provided.Base URL for API requests. Only specify if using a proxy or service emulator. Reads from
ANTHROPIC_API_URL or ANTHROPIC_BASE_URL if not provided.List of beta features to enable (e.g.,
["token-efficient-tools-2025-02-19"]).Parameters for Claude reasoning. For Claude Opus 4.5, use
{"type": "enabled", "budget_tokens": 10_000}. For Claude Opus 4.6, use {"type": "adaptive"}.Control how many tokens Claude uses when responding. Available on Claude Opus 4.6 and 4.5. The
max effort level is only supported by Claude Opus 4.6.Whether to use streaming or not.
Whether to include usage metadata in streaming output.
Supported Models
- Claude Opus 4.6: Most capable model with advanced reasoning
- Claude Sonnet 4.5: Balanced performance and speed
- Claude Haiku 4: Fast, cost-effective model
Features
- Text generation
- Tool calling
- Vision (multimodal input)
- Streaming
- Async support
- Prompt caching
- Extended thinking/reasoning mode
- Built-in tools (computer use, bash, web search, etc.)