Fundamentals

What is an API key?

An API key is a string of characters that identifies who is making a request to a service. That is genuinely the whole concept — but the practical details around it (how it differs from a token, why it must never sit in your frontend, what to do when it leaks) are where people get hurt.

Plain explanation Real examples Updated for 2026
Quick answer

An API key answers one question: who is calling?

When your code calls a service, the service needs to know which account to bill, which limits to apply, and whether you are allowed in at all. The API key is the string that answers that. It is not encryption, it does not hide anything, and it does not prove a human is present — which is exactly why it belongs on a server and never in a browser or a mobile app.

Promo code AI10 — 10% off your first top-up
See how AI APIs are accessed

The concept, in one paragraph

Imagine a service that anyone on the internet can call. It needs some way to tell one caller from another — to know whose account to charge, whose rate limit to count against, and whose permissions apply. An API key is the simplest possible answer: a long random string the service gives you, which you attach to every request. The service looks it up, finds your account, and proceeds.

That is the entire idea. Everything else on this page is consequences of that simplicity.

What one looks like, and where it goes

Keys are usually long, random, and prefixed so you can recognise the service at a glance — OpenAI keys begin sk-, and most providers use a similar convention. You attach it to a request in one of three places:

PlacementLooks likeNotes
Authorization headerAuthorization: Bearer YOUR_KEYThe modern default; used by OpenAI, Anthropic and most AI APIs
Custom headerx-api-key: YOUR_KEYCommon on older and self-hosted services
Query string?api_key=YOUR_KEYConvenient and the worst option — keys end up in server logs and browser history

If a service offers a header and a query parameter, use the header. Query strings get logged by every proxy, load balancer and analytics tool between you and the destination.

API key vs password vs token — the difference that matters

These three get used interchangeably in tutorials, and they are not the same thing:

IdentifiesExpiresUsed by
PasswordA humanRarely, by policyA person logging in
API keyAn application or accountUsually never, until you revoke itCode calling a service
Access token (OAuth)A user, via an app they authorisedYes — minutes or hoursApps acting on someone's behalf

The practical implication: because an API key normally does not expire and identifies an account rather than a person, a leaked key is usable by anyone who finds it, indefinitely, until you notice and revoke it. Tokens limit the damage window by design; keys do not.

How to get one — the AI APIs specifically

The flow is nearly identical everywhere: create an account, open the developer or API section, click to create a key, and copy it immediately — most providers show the full value exactly once and only store a hash afterwards. If you lose it, you create a new one; nobody can recover the original.

  • OpenAI — keys in the platform dashboard, prefixed sk-, billed per token against your account.
  • Google Gemini — keys from AI Studio, with a genuinely usable free tier, which is why access rather than payment is the main obstacle for many developers.
  • Anthropic Claude — keys from the console; see our Claude API guide.
  • DeepSeek — keys from its own platform at commodity per-token prices, covered on the DeepSeek page.

One thing worth knowing before you start: several of these providers gate account creation and API calls by region, not by payment. If signup fails from where you are, the key is not the problem — the origin of your connection is.

The five security rules that actually matter

  1. Never put a key in frontend code. Anything in a browser or a mobile app can be read by the user, no matter how it is minified or obfuscated. If your web page calls an AI API directly, your key is public — route the call through your own backend instead.
  2. Never commit a key to git. Automated scanners crawl public repositories constantly and abuse found keys within minutes. Use environment variables and a .gitignored config file.
  3. Set spending limits. Every serious provider offers a hard monthly cap. This is the difference between a leaked key costing you twenty dollars and costing you thousands.
  4. Use one key per application. When something goes wrong you want to revoke one thing, not everything you own.
  5. Rotate on suspicion, not on certainty. Creating a new key takes seconds; keys are cheap and unbounded liability is not.

What to do if a key leaks

In order, immediately: revoke the key in the provider dashboard — this kills it instantly and nothing else you do matters until it is done. Then create a replacement and deploy it. Then check your usage and billing history for calls you did not make, and if there is unexpected spend, contact the provider before paying, since most will discuss abuse charges. Finally, find how it escaped: a public repository, a client-side bundle, a log file, or a screenshot in a support ticket are the four usual answers.

Do not attempt to “delete” a key from git history and consider it handled. If it was ever pushed to a public remote, treat it as compromised permanently — the scanners were faster than you.

A note on relays and shared keys

Because keys are simply strings, a whole industry exists around reselling access to somebody else's: relay services that hand you an endpoint and a key of their own, charging a markup on tokens. It is convenient and the trade is real — you are giving an unidentified operator every prompt you send, depending on them to add new models, and holding a balance that dies with their business. That is not theoretical; it is what happened to the service this domain used to be.

The alternative is your own account and your own key, with a clean IP handling the region question. Slightly more setup, and nobody else holds the string that identifies you.

FAQ

API key questions

What is an API key in simple terms?

A long random string a service gives you, which your code sends with every request so the service knows which account is calling. It answers “who is this?” — nothing more. It does not encrypt anything and does not prove a human is involved.

Is an API key the same as a password?

No. A password identifies a person and is typed by them; an API key identifies an application or account and is used by code. Keys also typically never expire, which is why a leaked key stays dangerous until you revoke it.

Where should I store my API key?

In an environment variable or a secrets manager on the server side, never in frontend code and never committed to git. If a browser or mobile app can read it, so can your users.

Are API keys free?

The key itself is always free to create. Whether calls made with it cost money depends on the service — Google Gemini has a substantial free tier, while OpenAI and Anthropic bill per token from the first request.

What happens if someone steals my API key?

They can make requests billed to your account until you revoke it. Revoke first, then rotate, then check usage. A hard spending limit set in advance is what keeps that incident small.

Why does my API key not work in my country?

Several providers restrict account creation and API calls by region, independently of whether the key is valid. The key is fine; the origin of the request is being refused. A static residential IP in a supported country resolves it.

Can two applications share one API key?

Technically yes, practically don't. Separate keys let you revoke or rotate one application without breaking the others, and usage attribution stops being guesswork.

Proxy deals & AI-service outage news on Telegram

25,000+ subscribers get provider-outage alerts and discounts first — and you can buy proxies right inside Telegram via the mini-app shop.