Claude API: How to Make Your First Call

The API puts Claude inside your own system. See how to create a key, make your first call and avoid cost surprises.

Updated · 2 min read

Models and example checked against the official documentation on November 1, 2026. See platform.claude.com/docs before going to production.

App or API?

In the app, you talk to Claude. With the API, your system talks to it. Use the API to put Claude in a website, an app or an automation. It's billed by usage, in tokens, separately from a regular subscription.

What you need

  1. An account at platform.claude.com.
  2. Credits or a payment method.
  3. An API key.

Treat the key like a password. Never put it in public code or send it in a chat.

First call in Python

Install the official SDK:

pip install anthropic

Store your key in an environment variable named ANTHROPIC_API_KEY. Then run:

import anthropic

client = anthropic.Anthropic()

response = client.messages.create(
    model="claude-opus-5-5",
    max_tokens=16000,
    messages=[{"role": "user", "content": "Explain what an API is in one sentence."}],
)

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

The response is a list of blocks because it can carry more than text. That's why the code checks the type before printing.

Manage the cost

Model Input ($/million tokens) Output ($/million tokens)
Fable 5.1 10 50
Opus 5.5 4 20
Sonnet 5.5 2 10
Haiku 5.5 from 0.10 from 0.50

To save money:

  • use the right model for the task;
  • cap response length;
  • use prompt caching for repeated text;
  • use the Batch API, at 50% off, when you can wait;
  • set spending limits in the console.

Before going to production

  • Keep the key on the server, never in the browser.
  • Handle errors and rate limits.
  • Log costs.
  • Test with real cases.
  • Be careful with user input, which may try to manipulate the model.

Next steps

With the API, you can give Claude tools and build agents. If you don't code, Claude Code can write the integration for you.

Frequently asked questions

Is the API free?

It's pay-as-you-go. Check the platform for any starter credit available.

Does a Pro subscription include the API?

Regular Pro doesn't. Max and Ultra include monthly credits, according to the official pricing page.

Do I have to use Python?

No. There are official SDKs for other languages, including TypeScript, Java and Go.

Keep reading

Independent content. Claude is a trademark of Anthropic. This article is not affiliated with Anthropic.