← Blog

LLM API Key Explained: What It Is and How It Works

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

An LLM API key is a secret string of characters that a language model provider issues to identify who is making a request and what they're allowed to do with it. When your code sends a prompt to a model like GPT-4, Claude, or Gemini, it includes this key in the request headers. The provider checks the key against its records, confirms it's valid and has enough quota or credit, then processes the request and bills the account tied to that key.

In practical terms, an API key is what turns a chat interface into something your software can call programmatically. Without one, you can only talk to a model through a website or app. With one, you can build a script, a backend service, or an entire product on top of that model's capabilities — sending text, receiving completions, streaming tokens, or invoking tools, all through HTTPS requests instead of a browser window.

What an LLM API key actually looks like

Most providers format their keys as a prefixed random string, something like:

sk-ant-api03-XXXXXXXXXXXXXXXXXXXXXXXX

The prefix (sk-, sk-ant-, sub_live_, etc.) tells you which service issued it and sometimes which environment (live vs. test). The rest is a high-entropy secret that's effectively impossible to guess. This isn't a username-and-password combo — it's a single credential that does both jobs at once: it identifies the account and authorizes the request.

How the key gets used in a request

Almost every LLM API expects the key in an HTTP header, usually Authorization: Bearer <key> or a custom header like x-api-key. A basic call looks like this:

curl https://api.example.com/v1/messages \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "example-model",
    "messages": [{"role": "user", "content": "Explain recursion in one sentence"}]
  }'

The provider's server reads the header, validates the key, checks rate limits and remaining quota, then routes the request to the model. The response comes back as JSON (or a stream of chunks if you've asked for streaming), and the provider logs the usage against your account for billing.

Why keys exist instead of just logging in

APIs are designed for machine-to-machine communication, not humans clicking buttons. A session login with a password and cookies makes sense in a browser, but it's a poor fit for a script that runs unattended on a server, in a cron job, or inside another application. API keys solve that by giving software a long-lived, revocable credential it can present on every request without a human present to type a password or click through a login flow.

This also makes keys easier to manage at scale. You can issue a different key per application, per environment (staging vs. production), or per team member, then revoke any single one without touching the others.

Where LLM API keys come from

There are two common paths:

Either way, once you have a key, the mechanics of using it are the same: put it in a header, send a request, get a response.

Keeping an LLM API key secure

A leaked key is a real liability — anyone who has it can make requests billed to your account. A few practices that matter in production:

// Good: key stays server-side, read from environment
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",
    messages: [{ role: "user", content: "Summarize this in two sentences" }]
  })
});

What you can do once you have one

An LLM API key is the entry point to everything the API surface offers: sending messages and getting completions, streaming responses token by token for responsive UIs, giving the model tools it can call to fetch data or take actions, and pulling usage metadata so you know exactly what a feature is costing per request. If you're evaluating a provider, check their docs for how quickly you can get from signup to a working request — SubToAPI's quickstart is built to get a first authenticated call working in a few minutes, with full references for messages, streaming, and tool use.

If you're weighing plans, most providers structure pricing around usage volume or seats — SubToAPI's pricing runs from a Solo plan for individual projects up through Team and Scale tiers for multi-seat use, and a free trial is available at signup so you can generate a key and test it before committing.

Is an LLM API key the same as a password?

No. A password authenticates a human logging into an account, usually alongside other factors like MFA. An API key authenticates a piece of software making automated requests, and it typically carries both identity and authorization in a single secret string.

Can I use one LLM API key across multiple apps?

Technically yes, but it's not recommended. Using separate keys per application makes it easier to track usage, apply different rate limits, and revoke access to one app without breaking the others.

What happens if my LLM API key is exposed?

Revoke it immediately from the provider's dashboard and issue a new one. Check usage logs for any unexpected activity billed during the exposure window, and update every service that referenced the old key.

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 →