The Claude API is the Messages API. One endpoint, one key, one request shape; every client library wraps that single POST.

Two things make the first hour harder than they should be: the model id moves as models ship, and the numbers developers want first are not published.

What the Claude API gives you

One request does more than return text. The Messages API carries a conversation, calls tools you define, streams tokens as they are produced, and can be queued as a batch. Prompt caching lets a long, stable prefix be reused instead of re-billed at the full input rate.

Claude Fable 5.1 is the current frontier model, released on 2026-09-01 and reachable as claude-fable-5-1. If you have never used Claude as a product, read how to use Claude first. Prompting habits move over unchanged.

Getting a key and choosing a model

Where the key lives

Keys come from the Claude Console. Put yours in an environment variable, not in source: a key committed to a repository is a key you have to rotate. API key security is worth ten minutes before your first deploy.

Which model id to pass

Anthropic’s product page for Fable 5.1 gives the id as claude-fable-5-1 and publishes the price: $10 per million input tokens, $50 per million output tokens, and $0.25 per million tokens for cache reads. Claude Mythos 5.1 is the same underlying model with different safeguards.

The published line-up matters too: Claude Opus 5 at $5 and $25, Claude Sonnet 5 at $2 and $10, Claude Haiku 4.5 at $1 and $5, all per million tokens. Treat the id as configuration, so a rename is an environment change rather than a deployment.

Your first request: curl

Official Claude Fable product card: an orange-red radial starburst mark on the left of a light beige background, with the dark serif wordmark Claude Fable on the right
Anthropic

Start with the smallest request that proves the path end to end. Export ANTHROPIC_API_KEY and ANTHROPIC_MODEL in your shell first.

curl -s 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\": \"${ANTHROPIC_MODEL}\",
    \"max_tokens\": 512,
    \"messages\": [
      { \"role\": \"user\", \"content\": \"Explain what a message block is in two sentences.\" }
    ]
  }"

Three details are easy to miss. The key travels in a header, not in a URL, so it stays out of shell history and proxy logs. max_tokens is required, and it caps the output. And messages is a list of role and content pairs, which is also the shape of a multi-turn conversation: append a user turn, resend, and you have chat.

The response is JSON. Read the content array, which holds typed blocks; the text sits on the block whose type is text. A stop_reason field explains why generation ended.

The official SDK in Python

Install with pip install anthropic, then let the client read the key from the environment.

import os

from anthropic import Anthropic

client = Anthropic()  # reads ANTHROPIC_API_KEY from the environment

message = client.messages.create(
    model=os.environ.get("ANTHROPIC_MODEL", "claude-fable-5-1"),
    max_tokens=512,
    messages=[
        {"role": "user", "content": "Summarise this changelog in three bullets."}
    ],
)

for block in message.content:
    if block.type == "text":
        print(block.text)

The SDK changes the ergonomics, not the contract. The model id, the token cap and the message list are the same three required fields you sent with curl. Official SDKs exist for Python and TypeScript.

Streaming and tool use

stream=True returns an iterator of events instead of one finished response, and text arrives as deltas.

stream = client.messages.create(
    model=os.environ.get("ANTHROPIC_MODEL", "claude-fable-5-1"),
    max_tokens=1024,
    messages=[{"role": "user", "content": "Write a short release note."}],
    stream=True,
)

for event in stream:
    if event.type == "content_block_delta":
        print(event.delta.text, end="", flush=True)

Tool use adds a tools array, where each entry carries a name, a description and an input schema. The model can answer with a tool-use block instead of text, and your code runs the tool and sends the result back as a new turn.

One caveat: the API reference did not open during verification, so this article makes no claim about which tool_choice values a model accepts.

Cost: what is published and what is not

Published on Anthropic’s pricing page: Fable 5.1 at $10 and $50 per million tokens, cache reads at $0.25, cache writes at $12.50, a 50% discount for batch processing, and 1.1x pricing for US-only inference.

Not published on the pages we verified: a free quota, rate limits, and the context window for Fable 5.1. Those are the numbers a budget wants most, so this article prints none of them.

Prompt caching is the biggest cost lever after model choice: a stable system prompt is cached once and read back at a fraction of the input rate. Context caching covers the same mechanic on another API.

Common errors and what to check first

A 401 means the key is missing, mistyped or revoked. Check the header name: Authorization is the muscle-memory mistake, and Anthropic uses x-api-key.

A 400 is usually the model id or a missing field. max_tokens is the one people forget; a stale id from a tutorial is the other.

A 429 means you are sending faster than your quota allows. Since the published limits are not available to us, measure instead: log every response and stay under the rate that worked.

A 529 means an overloaded server; retry with exponential backoff, not a tight loop.

Never put the key in client-side code: a browser-visible key is a public key.

Frequently asked questions

Do I need a separate account for the API? Keys come from the Claude Console. Whether your plan covers API usage is a billing question, so treat the API and the subscription as separate budgets until you confirm.

Is there a free trial credit? Anthropic has not published a fixed amount on the pages we verified; a figure quoted elsewhere belongs to the site quoting it.

Does the SDK replace the HTTP call? No. It wraps the same endpoint, and the required fields are identical.

How do I keep the model id current? Keep it in configuration and check the Claude guide when you upgrade.

Can I stream and use tools in one request? Both are request-level options; the examples above are separate for clarity, not because they conflict.

Wire up one request, log the full response, and keep the model id in configuration. That tells you whether the Claude API fits your pipeline.