You know a language model runs on a server, and your program can send text there.
That server will not help everyone for free, forever. It needs to know who is asking — and who pays when the model runs.
The usual proof is an API key.
What an API key is
An API key is a long secret string the company gives your account.
It is not a short password you invent. It is usually a long random-looking value they generate. A fake example of the shape (not a real key):
sk-demo-9f3a2c…b17e
Your program sends that API key with each request. The key is not the question — it is the proof riding along. The server checks it first. If the key is valid, the server runs the model and sends a reply. If the key is missing or wrong, the server refuses.
Your program Server
┌──────────────┐ prompt + key ┌─────────────────┐
│ │ ─────────────────▶ │ check key │
│ │ │ then run model │
│ │ ◀───────────────── │ │
└──────────────┘ reply └─────────────────┘What it proves
The API key is not the model. The model is the program that writes text. The key is proof about you.
When the server accepts your API key, it is accepting three claims at once:
| What it proves | Plain meaning |
|---|---|
| Who you are | This request belongs to your account |
| Permission | Your account is allowed to use this service |
| Who pays | Usage is billed to you (or your team’s plan) |
Picture two people sending the same question, “What is 2 + 2?”, with different API keys:
- Person A’s key → bill goes to A’s account
- Person B’s key → bill goes to B’s account
Same question. Different wallets.
Why it is called an API key
Your program and the server do not chat in casual English over the wire.
They follow an agreed set of rules: send a request in a shape the server understands, get a reply in a shape your program can read. That set of rules is an API.
So the full name makes sense:
| Word | Meaning |
|---|---|
| API | The rules for asking the server and reading the reply |
| API key | The secret you send when you use that API |
You will see the exact request/reply shape (JSON fields, and so on) in the next chapter. Here you only need: there is a named door with rules (API), and a secret for that door (API key).
Where you get one
You sign up with a model company, open their account settings, and create an API key. They show it to you. You copy it so your program can use it later.
One practical warning: do not paste your API key into a public place (a public repo, a public chat, a screenshot you post online). Anyone who gets it can spend on your account.
For learning in this guide, it is fine to put the key in your local practice code so you can focus on how the call works. Just do not publish that file.
Cast so far:
| Word | Meaning |
|---|---|
| Server | Where the model runs |
| API | The rules for asking that server and reading the reply |
| API key | Proof of who you are and who pays |
Next: the exact request/answer shape on that API — then a real call.