What the Claude API gives you
The Anthropic API exposes Claude through a single primary endpoint — /v1/messages — that takes a list of conversation turns and returns the model’s next message. It is plain HTTPS with JSON, so you can call it from any language with no SDK at all. This guide covers the four things every beginner needs: authenticating, shaping a request, streaming responses, and controlling cost with prompt caching.
How a request is structured
Every call sends three headers — x-api-key with your secret key,
anthropic-version pinning the API version, and content-type: application/json.
The JSON body needs a model, a max_tokens cap, and a messages array where
each item has a role of user or assistant and content. Persistent
instructions go in the top-level system field rather than a user turn. Set
stream: true to receive the answer as server-sent events instead of one blob.
Use the builder below to choose a model, write a system prompt and a user message, toggle streaming and caching, and copy a ready-to-run curl or JavaScript fetch snippet.
Tips for going further
Never ship your key in client-side code — proxy calls through your own backend.
Turn on prompt caching for any large prefix you reuse, such as a long instruction
set or a reference document, to cut both cost and latency dramatically. Watch the
usage object in every response to track input and output tokens for billing.
When you need structured output, ask for JSON in the system prompt and validate
it on your side, or use tool definitions to force a typed shape.