Anthropic (Claude)
The Anthropic adapter connects opentine to Claude models via the Anthropic API. It supports tool use, extended thinking, and all Claude model variants including Opus, Sonnet, and Haiku.
Installation
Install opentine with the Anthropic extra to pull in the required SDK.
pip install "opentine[anthropic]"Quick Start
1from opentine import Agent
2from opentine.models.anthropic import Anthropic
3
4# Uses ANTHROPIC_API_KEY env var by default
5model = Anthropic("claude-sonnet-4-20250514")
6
7agent = Agent(model=model, tools=[...])
8run = agent.run_sync("Summarize the latest AI research papers")
Constructor
Anthropic(
model: str = "claude-sonnet-4-20250514",
api_key: str | None = None, # Falls back to ANTHROPIC_API_KEY env var
)model— The Claude model identifier. Defaults to"claude-sonnet-4-20250514".api_key— Your Anthropic API key. If not provided, the adapter falls back to theANTHROPIC_API_KEYenvironment variable.
Authentication
You can provide your API key either directly in the constructor or via an environment variable. The environment variable approach is recommended for production use.
1from opentine.models.anthropic import Anthropic
2
3# Explicit API key (overrides env var)
4model = Anthropic("claude-sonnet-4-20250514", api_key="sk-ant-...")
5
6# Or set the environment variable
7# export ANTHROPIC_API_KEY="sk-ant-..."
Properties
1from opentine.models.anthropic import Anthropic
2
3model = Anthropic("claude-sonnet-4-20250514")
4
5print(model.name) # "anthropic/claude-sonnet-4-20250514"
6print(model.supports_tools) # True
7print(model.supports_thinking) # True
name— Returns"anthropic/{model}".supports_tools— AlwaysTrue. All Claude models support native tool use.supports_thinking—Trueif the model name contains"opus"or"sonnet",Falseotherwise.
Supported Models
| Model | Tools | Thinking | Notes |
|---|---|---|---|
claude-opus-4-20250514 | Yes | Yes | Most capable, best for complex tasks |
claude-sonnet-4-20250514 | Yes | Yes | Best balance of speed and capability |
claude-haiku-3-20240307 | Yes | No | Fastest and most cost-effective |
Any valid Claude model identifier can be passed to the constructor. The table above lists the most commonly used models.
Tool Use
Claude models have native tool use support. Pass your tools to the Agent and Claude will decide when and how to call them.
1from opentine import Agent
2from opentine.models.anthropic import Anthropic
3from opentine.tools.web import search, fetch
4
5model = Anthropic("claude-sonnet-4-20250514")
6
7# Claude models have native tool use support
8agent = Agent(
9 model=model,
10 tools=[search, fetch],
11 system="Search the web to answer questions accurately.",
12)
13
14run = agent.run_sync("What is the current population of Tokyo?")
Extended Thinking
Opus and Sonnet models support extended thinking, which allows the model to reason through complex problems step-by-step before responding. Whensupports_thinking is True, opentine automatically enables this capability.
1from opentine.models.anthropic import Anthropic
2
3# Extended thinking is automatically enabled for Opus and Sonnet models
4opus = Anthropic("claude-opus-4-20250514")
5print(opus.supports_thinking) # True
6
7sonnet = Anthropic("claude-sonnet-4-20250514")
8print(sonnet.supports_thinking) # True
9
10haiku = Anthropic("claude-haiku-3-20240307")
11print(haiku.supports_thinking) # False
Next Steps
- Model Adapters — Overview of all available adapters
- OpenAI (GPT) — Use GPT-4o or o-series reasoning models
- Tools — Built-in tools for web, filesystem, and more