Claude API Quickstart: Make Your First Call in Minutes
By the end of this guide you will have a working Claude API call, the right model picked for your job, and a clear path to add tool use, prompt caching, and batch processing. This is the practical setup, not the marketing tour. Everything here is current as of June 2026.
Claude is Anthropic's model family, and the API gives you direct access to it for coding agents, long-context analysis, RAG, and tool-using assistants. The setup is short. The decisions that matter most are which model you call and how you control cost. We will cover both.
Step 1: Get an API key
- Sign up at the Anthropic Console and create an account or log in.
- Open the API Keys section and generate a new key.
- Copy it once and store it in a secret manager or an environment variable, not in your code.
- Add billing. API access is separate from consumer Free, Pro, and Max plans.
Do not paste your API key into a committed file, a frontend bundle, or a public repo. Read it from an environment variable like ANTHROPIC_API_KEY at runtime. A leaked key is a billable key.
Step 2: Pick the right model
For a production starting point, use Sonnet 5. It is Anthropic's default on Claude Free and Pro and is available through Claude Code and the API. Benchmark other currently listed models only when your workload needs a different quality, latency, or cost profile.
- Sonnet 5: the current default on Claude Free and Pro and available through the API. Introductory API pricing is $2 in / $10 out per million tokens through August 31, 2026, then $3/$15.
- Opus 4.8: hardest agentic and coding tasks, long runs. 1M token context. $5 in / $25 out, Fast Mode $10 / $50.
- Haiku 4.5: high throughput, classification, simple extraction. 200K context. $1 in / $5 out.
Fable 5 was restored globally on July 1, 2026 and is available through the Claude API where your account and platform expose it. Mythos 5 is limited to approved Project Glasswing organizations. For a generally available API starting point, use Sonnet 5.
Step 3: Send your first request
Install the official SDK for your language, set ANTHROPIC_API_KEY, then call the Messages endpoint. The shape is the same in every SDK: a model id, a max_tokens limit, and a messages array of role and content. Start with a single user message like 'Summarize this changelog in five bullet points' and confirm you get a response and a token count back. Once that works, everything else is incremental.
Key request parameters
- model: the model ID; for a current default, use the Sonnet 5 ID shown in Anthropic's official model overview.
- max_tokens: a hard cap on the response length. Set it deliberately, since output tokens cost the most.
- system: a top-level system prompt that sets role and rules. Keep it stable so it can be cached later.
- messages: the conversation as alternating user and assistant turns.
- temperature: lower for deterministic extraction and code, higher for ideation.
Step 4: Add tool use and MCP
Tool use lets Claude call your functions: search a database, hit an API, run a calculation. You define each tool with a name, a description, and a JSON schema for its inputs. Claude decides when to call it, returns the call, your code runs it, and you feed the result back. Anthropic created the Model Context Protocol (MCP) and supports it first-class, so you can connect standardized tool servers instead of hand-wiring every integration. This is the path to real agents rather than one-shot prompts.
Step 5: Cut your bill before you scale
Two features pay for themselves immediately. Prompt caching reuses a stable prefix, your system prompt, schemas, or a large document, and cuts cached input cost by up to 90%. Batch processing runs non-urgent jobs at 50% off. Combine them and a high-volume pipeline gets dramatically cheaper without changing your prompts.
- Use prompt caching when you reuse the same system prompt, tool definitions, or reference documents across many calls.
- Use batch processing for anything that does not need a real-time answer: nightly summarization, bulk classification, dataset labeling.
- Trim max_tokens to what you actually need, since output tokens are the priciest.
- Start with Sonnet 5 and switch models only when task-specific evaluations show that you genuinely need to.
Step 6: Harden for production
- Stream responses for chat and long outputs so users see tokens as they arrive.
- Handle rate limits and 429s with exponential backoff and retries.
- Log token usage per request to track spend and catch runaway prompts.
- Pin a specific model id rather than a floating alias so behavior stays predictable.
Where Claude is strongest: agentic coding, long-context analysis over large codebases and document sets, production assistants, RAG, and tool-using agents. Know the limits too. There is no native image generation, voice is not a core strength, and Opus is premium-priced, so route work to the cheapest model that clears the bar.
Get the Claude playbook in your inbox.
One weekly email for Claude and Claude Code users. Real workflows, no hype. Subscribe and we send you The Claude Power-User Cheatsheet.