Playbook
Bringing your own API keys is the single best money move in AI coding — you pay the labs' raw per-token rates instead of a reseller's markup, and you can point any tool at any model. We made the full financial case in Stop Paying Token Markup; this is the companion piece: the actual setup, lab by lab, done safely, in about ten minutes per key.
The universal four steps
Every lab's console differs cosmetically; the procedure never does. For each provider you use:
- Create the key. Sign up, add a payment method, generate an API key. Name it for where it will live (
macbook-claude-code, notkey-2) so you can revoke precisely later. The full key is shown once — copy it now. - Set a monthly spend cap immediately. Before the key touches any tool. This is the one non-negotiable step in this guide. Every console below has a spend limit or budget setting; find it, set a number you'd shrug at losing, and raise it later if real usage justifies it. An agent stuck in a loop, a leaked key, a misconfigured script — with a cap, all of these are boring. Without one, they're the horror stories you've read.
- Store it properly. The key goes in a password manager or the macOS Keychain — a secrets store, not a sticky note. Never in code. Never in a dotfile that gets committed:
.envbelongs in.gitignorebefore the key goes in it, and shell exports belong in your local profile, not the repo. Git history is forever, and bots scrape public commits for keys within minutes. - Rotate on any exposure. Pasted it in a chat, a screenshot, a gist, a bug report — even briefly? It's burned. Revoke it in the console, generate a fresh one, move on. Rotation takes ninety seconds; assuming nobody saw it is how incidents start.
Now the labs. Do the ones you'll actually use; you can always add more later.
Anthropic (Claude)
Console: console.anthropic.com. Sign in, add billing under the billing settings, then create a key under API Keys. Spend limits live in the billing section — set the monthly cap before you leave the page. Claude models are the default choice for a primary coding agent for a lot of people, so this is usually key number one.
OpenAI (GPT / Codex)
Console: platform.openai.com — note this is the API platform, a separate account and balance from a ChatGPT subscription; a ChatGPT plan does not include API usage. Create the key under API Keys, then go straight to the usage limits page and set the monthly budget. OpenAI supports project-scoped keys — use them, one per machine or tool.
Google (Gemini)
Console: aistudio.google.com. AI Studio is the fastest path: sign in with a Google account and generate an API key from the key page. There's a free tier with rate limits that's genuinely useful for evaluation; paid usage runs through a Google Cloud billing account, where you should set a budget alert at the same time you enable billing.
xAI (Grok)
Console: console.x.ai. Create a team, add billing, generate a key. xAI's console lets you scope keys to specific endpoints and models — take the thirty seconds to restrict the key to what your coding tool needs, and set the spending limit while you're there.
DeepSeek
Console: platform.deepseek.com. Sign up, top up a small prepaid balance, create the key. DeepSeek is prepaid-style — the balance itself is a natural spend cap, which makes it a low-risk first key. Prices are startlingly low (see the table), so a small top-up lasts a long time of real use.
Moonshot (Kimi)
Console: platform.moonshot.ai. Same prepaid pattern: register, add balance, create a key under API Keys. Kimi's coding models have become a serious budget option, and several agnostic CLIs support the endpoint directly.
Budget reality: what an evening actually costs
People fear API pricing because it's unbounded in theory. In practice, coding sessions are cheap. Current per-million-token rates (input / output) for the models we see people actually run:
| Model | Input / M tokens | Output / M tokens |
|---|---|---|
| Claude Sonnet 5 | $3.00 | $15.00 |
| GPT-5.3 Codex | $1.75 | $14.00 |
| Gemini Flash | $1.50 | $9.00 |
| Grok 4.5 | $2.00 | $6.00 |
| DeepSeek | $0.435 | $0.87 |
Run the mental math: a typical evening session — a few hundred thousand input tokens as the agent reads your codebase, a few tens of thousands of output tokens of actual code — lands between cents and a few dollars depending on the model. A heavy multi-agent day costs more, and a DeepSeek-powered session costs almost nothing. The distribution has a long tail (that's what runaway loops are), which is exactly what the spend cap amputates. With caps set, your worst case is a boring email saying you hit your limit. That's the entire risk profile.
If minimizing the bill is the goal, model choice matters far more than usage discipline — our cheapest AI coding models roundup ranks the price-performance field properly.
Wiring keys into your tools
Most CLIs read keys from an environment variable (each documents its name — typically along the lines of ANTHROPIC_API_KEY) or a one-time login command. Set the variable in your shell profile or the tool's own config, run one small prompt as a smoke test, and check the provider's usage dashboard shows the request. In our own setup, keys live in the macOS Keychain and The Vibe Father hands them to whichever CLI needs them — but nothing in this guide requires that; a password manager and a shell profile do the job.
Ten minutes a lab, caps on everything, secrets in a real store. Do it once, and every tool you try for the next year is a config line away.