Claude API: what it is and how it differs from the claude.ai chat

The Claude API gives your code access to the models and is billed per token. The Messages API, caching and tools explained, with a first request.

5 min · · API keys · models

What is the Claude API and how does it differ from the claude.ai chat? The chat is a ready-made application where you type messages by hand. The API is an interface through which your program sends requests to the same model and receives answers. If you want to embed Claude into a bot, script, service or code editor, you need the API. Below we explain how it works and make a first request.

How the API differs from a chat and a subscription

Chat (claude.ai)Claude API
How you use itmanually in an interfacewith requests from code
How you payby the service's plan, see the site for current termsper token, as much as you used
What you can dohold a dialogue, upload filesautomate, embed, scale
Controlthrough app settingsrequest parameters: model, answer limit, tools

Chat subscription terms change, so check the service's own site for the current plan. The API, by contrast, is always counted in tokens: you pay for what you sent and received.

A clarification right away: an API key and a chat subscription are billed separately, and an API key does not open access to the app. That said, Anthropic's pricing page lists monthly API credits for some subscription plans, so check what your plan includes on the service's site.

How the Messages API works

The main way to work with Claude is the Messages API. It is a single HTTP request, POST /v1/messages, with JSON.

The key fields:

  • model is the model name, for example claude-sonnet-5-5;
  • max_tokens is the cap on answer length, a required field;
  • messages is a list of turns with the roles user and assistant;
  • system is the system instruction (role, rules);
  • tools are tool descriptions, if the model should call functions.

The model does not remember previous requests: you send the full dialogue history every time. This matters for cost, as described below.

Through Zukko the same format is available at https://api.zukko.pro/v1/messages. The full parameter reference is in the Messages API documentation.

The first request in curl

Create a key on the API keys page (it starts with fetch_), then:

bash
curl https://api.zukko.pro/v1/messages \
  -H "x-api-key: fetch_your_key" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-sonnet-5-5",
    "max_tokens": 300,
    "system": "Answer briefly, in English.",
    "messages": [{"role": "user", "content": "How is an API different from a chat?"}]
  }'

The response is JSON: a content array with the text and a usage block with input and output token counts. Instead of x-api-key you can pass the header Authorization: Bearer fetch_your_key; both work.

The same in Python

bash
import anthropic

client = anthropic.Anthropic(
    base_url="https://api.zukko.pro",   # no /v1: the SDK adds the path itself
    api_key="fetch_your_key",
)

message = client.messages.create(
    model="claude-sonnet-5-5",
    max_tokens=300,
    system="Answer briefly, in English.",
    messages=[{"role": "user", "content": "How is an API different from a chat?"}],
)

print(message.content[0].text)
print(message.usage.input_tokens, message.usage.output_tokens)

An address without /v1 is a common trap. The official Anthropic SDK appends /v1/messages itself, so an extra /v1 in the base URL leads to a 404. If you use the OpenAI SDK it is the other way round: https://api.zukko.pro/v1. How to choose between formats is explained in base URL with or without /v1.

Tokens and price

A token is a piece of text, roughly a syllable or a short word. The price is counted per million tokens, separately for input (everything you sent) and output (what the model wrote).

For claude-sonnet-5-5 at October 18, 2026, the Zukko price is $0.4 per 1M input and $2 per 1M output (official: $2 and $10). For a request with 1,000 input and 500 output tokens:

  • Input: 1,000 × 0.4 / 1,000,000 = $0.0004
  • Output: 500 × 2 / 1,000,000 = $0.001
  • Total: $0.0014

Current prices of all models are on the "Models" page in the dashboard and in GET https://api.zukko.pro/v1/models. How many tokens a request will take can be found in advance with POST /v1/messages/count_tokens.

Prompt caching

Since the history has to be sent every time, a long repeated chunk (instruction, document, project description) is paid for again and again. Caching solves this: you mark such a block, and in later requests it is read at a reduced price.

In the Anthropic format a block is marked with the cache_control field:

bash
{
  "system": [
    {
      "type": "text",
      "text": "…long instruction or document…",
      "cache_control": {"type": "ephemeral"}
    }
  ]
}

Cache prices for claude-sonnet-5-5: read $0.05 per 1M, write $0.5 per 1M. Suppose a 10,000-token system block is used in 100 requests:

  • Without cache: 100 × 10,000 × 0.4 / 1,000,000 = $0.40
  • With cache: write 10,000 × 0.5 / 1,000,000 = $0.005, read 99 × 10,000 × 0.05 / 1,000,000 = $0.0495, total $0.0545

The minimum block size and cache lifetime depend on Anthropic's rules: check its documentation. And remember that the gateway sees the cache discount in the Anthropic format. If you send Claude through /v1/chat/completions, all input is billed at the input price. A detailed breakdown: Claude via /v1/messages or chat/completions.

Tools (tool use)

With the tools parameter you describe functions and the model decides when to call them. It returns not text but a tool_use block with the function name and arguments; your code runs the function and sends the result back in the next request. This is how agents and bots that reach into a database or a third-party API are built. A full Python loop is shown in tool use in Claude.

Who needs the Claude API

  • Developers embedding a model into a product.
  • Teams automating text processing: classification, summarisation, data extraction.
  • People using console agents and editor extensions: Claude Code, Cline and others connect with an API key.

If you only need to ask questions now and then, a chat is simpler. There is a browser chat on the same balance for that.

How to get access from Russia

Access from Russia is through the Zukko gateway. The dollar balance is topped up from $1: SBP (the payment page adds an 8.5% fee on top), a MasterCard card or cryptocurrency. There is no subscription: you pay for tokens.

FAQ

How does the Claude API differ from a chat subscription?

A subscription is built for manual work in an app. The API is built for programs and billed per token. Whether your subscription plan includes any API credits, check on the service's site.

Is the max_tokens parameter required?

Yes, in the Messages API it is required. It limits the answer length and therefore the upper bound of the request cost.

Can I call Claude through the OpenAI SDK?

Yes, any model in the catalogue can be called in either format. But the gateway sees the cache for Claude only in the Anthropic format, so /v1/messages is better for long repeated contexts.

Where can I see usage?

In the "Usage" section of the dashboard, which shows your spending history. Balance and spending are also available through the API.

zukko

Pay 25×
less

for Claude Code & ChatGPT

One fetch_* key and base URL api.zukko.pro — for Cursor, Claude Code, Codex, and any SDK.

Get API keyDocumentation

api.zukko.pro · fetch_*

Claude API: what it is and your first request · Zukko