Anthropic (Claude)
The Anthropic adapter connects opentine to Claude models via the Anthropic API. It exposes Claude tool schemas and reports a supports_thinkingcapability flag for model names containing opus or sonnet. Cloud live validation requires your Anthropic credentials.
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) # "claude-sonnet-4-20250514"
6print(model.supports_tools) # True
7print(model.supports_thinking) # True
name— Returns the model identifier passed to the constructor.supports_tools—Truein the adapter. Provider and model-specific tool behavior should be validated in your live gate.supports_thinking—Trueif the model name contains"opus"or"sonnet",Falseotherwise.
Supported Models
| Model | Tool Schema | Thinking Flag | Notes |
|---|---|---|---|
claude-opus-4-20250514 | Exposed | Exposed | Most capable, best for complex tasks |
claude-sonnet-4-20250514 | Exposed | 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
The adapter converts opentine tool schemas to Anthropic tool definitions. Pass your tools to the Agent and validate the selected Claude model in your environment.
1from opentine import Agent
2from opentine.models.anthropic import Anthropic
3from opentine.tools.search import search
4from opentine.tools.web import fetch
5
6model = Anthropic("claude-sonnet-4-20250514")
7
8# The adapter converts these tools to Anthropic's tool schema.
9agent = Agent(
10 model=model,
11 tools=[search, fetch],
12 system="Search the web to answer questions accurately.",
13)
14
15run = agent.run_sync("What is the current population of Tokyo?")
Extended Thinking
supports_thinking is a capability flag today. It does not automatically add provider-specific extended-thinking request parameters. Pass only model names and settings you have validated with Anthropic.
1from opentine.models.anthropic import Anthropic
2
3# supports_thinking is a capability flag derived from the model name.
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