← Blog

Anthropic API: A Practical Getting-Started Guide

2026-09-02 · 5 min read · SubToAPI Team

The Anthropic API is the HTTPS interface Anthropic provides for developers to call Claude models programmatically — sending messages, streaming responses, and using tools — from your own code instead of the Claude chat UI. You authenticate with an API key, send JSON requests to an endpoint like /v1/messages, and get back structured responses you can build products around.

If you're trying to figure out how to actually start using it, this article covers what the API does, how access and billing work, a working code example, and the tradeoffs to know about before you commit to a workflow.

What the Anthropic API Actually Gives You

At its core, the API exposes Claude's chat completion functionality (the Messages API) plus a few supporting pieces:

This is different from the Claude consumer app. The API is stateless per request (you resend conversation history each time), has no UI, and is billed by token usage rather than a flat monthly subscription — though the difference between "buy API credits directly" and "use a subscription-based access route" matters more than most people realize, and we'll get to that.

Getting Access

To use the Anthropic API directly, you create an account on Anthropic's developer console, generate an API key, and add billing (prepaid credits or a linked payment method). From there you're charged per token, with separate rates for input tokens, output tokens, and model tier (Haiku, Sonnet, Opus).

A basic request looks like this:

curl 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": "claude-sonnet-4-5",
    "max_tokens": 1024,
    "messages": [
      {"role": "user", "content": "Summarize this changelog in three bullets."}
    ]
  }'

The response includes the generated text, a stop reason, and token usage — everything you need to log, bill, or chain into the next step of a pipeline.

Where This Gets Complicated

Two things trip people up once they move past a first prototype:

Cost tracking at the team level. Anthropic's console gives you usage numbers, but attributing spend to specific apps, features, or team members inside one shared API key takes manual work — separate keys, separate logging, or homegrown dashboards.

Individual subscriptions vs. programmatic access. A lot of developers and small teams already pay for Claude Pro or Max as individuals. That subscription doesn't give you an API key — it's built for the chat interface, not for calling from your own code. If your actual usage pattern is "a few people on a team, each with their own Claude access, who need that access available as an API for internal tools," the direct Anthropic API route means separately provisioning and paying for API credits on top of what you're already paying for seats.

This is the gap SubToAPI is built to close. It turns Claude access your team already has into a standard HTTPS API — you get an application key (sub_live_...), a /v1/messages-style endpoint, streaming, tool use, and usage metadata per key, all from one dashboard. If you want API-style integration without standing up separate Anthropic billing and key management for every team member, it's worth a look.

const res = await fetch("https://api.subtoapi.app/v1/messages", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.SUBTOAPI_KEY}`,
    "content-type": "application/json"
  },
  body: JSON.stringify({
    model: "claude-sonnet-4-5",
    max_tokens: 1024,
    messages: [
      { role: "user", content: "Draft a release note for a bug fix in auth middleware." }
    ]
  })
});

const data = await res.json();
console.log(data);

The request shape mirrors what you'd send to Anthropic directly, so migrating existing integration code is mostly a matter of swapping the base URL and auth header — see the quickstart and Messages API docs for details.

Streaming and Tool Use

Both the direct Anthropic API and SubToAPI support streaming responses (server-sent events, token by token) and tool use, where the model returns a structured call to a function you defined instead of plain text — useful for agents that need to query a database, hit an internal API, or execute code based on the model's decision. If you're building anything interactive (a chat UI, a coding assistant, a support bot), streaming is what keeps perceived latency low, since users see output as it's generated rather than staring at a spinner. See /docs/streaming and /docs/tools for implementation details on the SubToAPI side.

Choosing How You Access It

If you're a solo developer with API credits and no team coordination overhead, calling the Anthropic API directly is the simplest path — one key, one bill, full control over model versions and parameters.

If you're managing Claude access for a team — multiple people, multiple projects, and a need for per-key usage visibility without juggling separate Anthropic accounts — a layer like SubToAPI that turns existing access into scoped API keys with usage metadata is usually less overhead than provisioning everyone individually. Plans start at €9/month for a solo key and scale to €19–€49 per seat for teams, with a free trial at /signup. Full plan details are on /pricing.

Either way, the request format you write against — messages, roles, streaming, tools — stays consistent, so the code you write today isn't wasted if your access model changes later.

questions

Do I need a separate account to use the Anthropic API, or does my Claude subscription cover it? A Claude Pro or Max subscription does not include API access. The API is billed separately, by token, through Anthropic's developer console — or through a service like SubToAPI that exposes existing Claude access as an API.

What's the difference between the Messages API and older completion endpoints? The Messages API is Anthropic's current interface — it takes a list of role-tagged messages (user/assistant) and an optional system prompt, and supports streaming and tool use. Earlier text-completion-style endpoints have been deprecated in favor of this format.

Can I use the Anthropic API for production apps with multiple team members? Yes, but you'll need to handle key management and per-user usage tracking yourself, or use a platform that provides team seats and scoped keys out of the box — see /pricing for how SubToAPI structures this for Solo, Team, and Scale plans.

Turn your Claude access into an HTTPS API

SubToAPI gives you application API keys, streaming, tool use and usage insights on top of your existing Claude access — set up in minutes.

Start free  Read the quickstart →