Anthropic — quickstart
Best-in-class for agentic coding loops and reasoning over long contexts. The 1M-context tier on Opus 4.7 collapses an entire class of context-windowing plumbing for production agent systems. Pick Anthropic when you need both depth and document-scale.
claude-opus-4-7 Get a key
- Create an API key at console.anthropic.com
- Set it as `ANTHROPIC_API_KEY` env var (or pass to the SDK explicitly)
Make a request
Three equivalent ways to call the recommended model. Pick the one that matches your stack.
curl
curl https://api.anthropic.com/v1/messages \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{
"model": "claude-opus-4-7",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "Summarize the last week of AI model releases."}
]
}' python
pip install anthropic from anthropic import Anthropic
client = Anthropic()
msg = client.messages.create(
model="claude-opus-4-7",
max_tokens=1024,
messages=[{"role": "user", "content": "Summarize the last week of AI model releases."}],
)
print(msg.content[0].text) node
npm install @anthropic-ai/sdk import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic();
const msg = await client.messages.create({
model: "claude-opus-4-7",
max_tokens: 1024,
messages: [{ role: "user", content: "Summarize the last week of AI model releases." }],
});
console.log(msg.content[0].type === "text" ? msg.content[0].text : ""); Pricing
Opus 4.7: $5/M input, $25/M output. Prompt caching cuts repeat-context cost ~90%; turn it on for any multi-turn agent loop.
Alternatives in this lineup
- Claude Sonnet 4.6 — Lower cost, slightly weaker reasoning. Good default for high-volume work.
- Claude Haiku 4.5 — Cheapest tier. Good for classification + retrieval-augmented chat.
Gotchas
- max_tokens is required. Unlike OpenAI's chat completions, Anthropic's `max_tokens` is required on every request. Set it to the response cap you want; the request fails otherwise.
- Prompt caching is opt-in. Without `cache_control` blocks on cacheable prefix segments, you're paying full input cost on every turn. Wire caching whenever the system prompt + tool definitions + long history are stable across calls.
- Streaming tools work differently. Tool use in streaming mode emits `content_block_delta` events; SDKs handle this but raw HTTP integrations often miss it.
Official docs: https://docs.claude.com/en/docs/intro