← Blog

Claude API Getting Started: Hello World Guide

2026-10-22 · 4 min read · SubToAPI Team

Getting started with the Claude API

If you're searching for "claude api getting started hello world," you want the fastest path from zero to a working request: get credentials, install whatever you need, send one message, and see Claude respond. This guide walks through that exact path using plain HTTP calls, so it works regardless of which language or framework you end up using.

By the end, you'll have a working script that sends a prompt to Claude and prints the response — the minimum viable "hello world" for any LLM integration.

What you actually need

Before writing any code, you need three things:

  1. An API key — a credential that authenticates your requests.
  2. An HTTP client — curl, fetch, axios, or whatever your language ships with. No SDK is strictly required.
  3. A model name — the identifier for the Claude model you want to call.

You do not need a framework, an SDK, or a backend server to send your first request. A single terminal command is enough to prove the connection works.

Step 1: Get an API key

Anthropic issues keys through its own console if you want direct access. If you'd rather skip infrastructure setup — rate limit handling, billing dashboards, team key management — you can also get an HTTPS API key through SubToAPI, which turns your existing Claude access into a sub_live_... key with streaming, usage metadata, and team seats built in. Either way, the request shape below is the same: a bearer token in the Authorization header.

Sign up at /signup if you want a key in under a minute, or check /pricing for plan details (Solo, Team, Scale, all with a free trial).

Step 2: Send your first request with curl

This is the actual "hello world." Open a terminal and run:

curl https://api.subtoapi.app/v1/messages \
  -H "Authorization: Bearer $SUBTOAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4",
    "max_tokens": 100,
    "messages": [
      { "role": "user", "content": "Say hello world and explain what you are in one sentence." }
    ]
  }'

If everything's wired correctly, you'll get back a JSON object with a content array containing Claude's reply, plus usage metadata (input/output token counts). That response is your proof the pipeline works end to end: auth, request, model, response.

Full parameter details live at /docs/messages, and a broader walkthrough covering setup and first calls is at /docs/quickstart.

Step 3: Do the same thing in JavaScript

Most real projects won't use raw curl, so here's the equivalent in Node.js using fetch:

const response = 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",
    max_tokens: 100,
    messages: [
      { role: "user", content: "Say hello world and explain what you are in one sentence." }
    ]
  })
});

const data = await response.json();
console.log(data.content[0].text);

Run this with node hello.js after setting SUBTOAPI_KEY in your environment. That's the entire "hello world" — no SDK installation, no boilerplate client classes, just a POST request and a JSON response.

Understanding the response shape

A typical response looks roughly like this:

{
  "id": "msg_01...",
  "model": "claude-sonnet-4",
  "role": "assistant",
  "content": [
    { "type": "text", "text": "Hello world! I'm Claude, an AI assistant made by Anthropic." }
  ],
  "usage": {
    "input_tokens": 18,
    "output_tokens": 22
  }
}

Three things worth noting as a beginner:

Common mistakes when starting out

A few things trip up almost everyone on their first Claude API call:

Where to go after hello world

Once a single request works, the natural next steps are:

None of these require throwing away your hello-world script — they're additions to the same request/response pattern you just built.

questions

Do I need Anthropic's SDK to get started? No. Any HTTP client works — curl, fetch, axios, requests in Python. SDKs are convenience wrappers around the same JSON API calls shown above.

Why does my request fail with a 401 error? Almost always an invalid or missing API key, or the key placed in the wrong header. Double-check you're sending Authorization: Bearer <your-key> exactly, with no extra whitespace or quotes.

What's the cheapest way to test the Claude API without committing to infrastructure? Start with a free trial — both Anthropic directly and gateways like SubToAPI offer one at /signup — and run a handful of curl requests before writing any application code. That's enough to validate the integration before you invest in SDKs, retries, or streaming logic.

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 →