Home › Claude API course: 3 beginner lessons

Claude API course: 3 beginner lessons

Last checked

What it does

The Claude Platform (Claude API) lets your code use Claude models through the Messages API, with tools such as web search, structured outputs, code execution and files, billed per token.

Who it's for: Developers who want Claude models inside their own app, product or agent.

Made by Anthropic.

Sign up and log in
  1. Create a Claude Console account at platform.claude.com.
  2. Create an API key.
  3. Export it: export ANTHROPIC_API_KEY="your-api-key-here" (the SDKs read it automatically).
  4. Make a first request with curl to https://api.anthropic.com/v1/messages, or install the Python or TypeScript SDK.
  5. Optional: the Anthropic CLI (brew install anthropics/tap/ant, then ant auth login) for calls from the terminal.

Per million tokens on claude.com/platform/api: Haiku 5.5 US$0.10 input / US$0.50 output (prompts up to 100K), Sonnet 5.5 US$2 / US$10, Opus 5.5 US$4 / US$20, Fable 5.1 US$10 / US$50. Batch processing saves 50%.

Lesson 1: Get a key and send your first message

Every Claude API call is a POST to the Messages API with a model, a max_tokens limit and a list of messages..

  1. Create a Console account and an API key.
  2. Export ANTHROPIC_API_KEY in your terminal.
  3. Send a POST to https://api.anthropic.com/v1/messages with headers x-api-key, anthropic-version: and content-type: application/json.
  4. In the body, set "model": "claude-opus-5-5", "max_tokens": 1000 and your message.
  5. Read the reply in content[0].text, and note the token counts in usage.

Open lesson 1 →

Lesson 2: Add web search and JSON outputs

The web search tool gives Claude current web content with cited sources, and structured outputs make its reply match your JSON schema so code can use it directly..

  1. Add the web search tool to the tools list of your request (for example type web_search_20250305 for basic search).
  2. Show users the citations included in the response.
  3. Use domain controls to allow or block particular sites.
  4. For JSON, set output_config.format with your schema.
  5. For tools, add strict: true to guarantee tool names and inputs match the schema.

Open lesson 2 →

Lesson 3: Save money with batches and prompt caching

Two features lower your bill: the Message Batches API runs non-urgent requests at 50% off, and prompt caching re-uses a long, repeated prompt instead of paying full price every time..

  1. Group requests that don't need an instant answer and send them to the Message Batches API.
  2. Poll the batch; most finish in under an hour.
  3. For a long prompt you reuse (instructions, a document), add one top-level cache_control field to turn on automatic caching.
  4. Or place cache_control on specific content blocks for exact control.
  5. Compare cache read and write costs on the pricing page with your normal input cost.

Open lesson 3 →

Sources

Start Lesson 1 →

Also: All Anthropic products · Claude course · Claude features and prices · All tutorials

Report an error on this page