How to Get an LLM API Key: A Developer's Checklist
Getting an LLM API key is a five-minute process on paper: sign up with a provider, verify your account, generate a key from a dashboard, and add billing if required. In practice, the friction comes from choosing the right provider for your use case, understanding rate limits and pricing before you're locked in, and setting up the key so it doesn't leak into a public repo six months from now.
This guide walks through the actual steps, the decisions you need to make along the way, and how to test your key once you have it.
Step 1: Decide which model provider you need
Before you create an account anywhere, figure out what you're actually optimizing for:
- Raw capability — Claude, GPT-4-class models, and Gemini all compete here, with tradeoffs in reasoning, coding, and long-context handling.
- Cost per token — smaller or open-weight models are cheaper but weaker on complex tasks.
- Tool use / function calling — if your app calls external APIs based on model output, check the provider's tool-use support before committing.
- Existing subscription — if you already pay for a Claude or ChatGPT plan, you may not need a separate developer account at all (more on this below).
Don't skip this step. Switching providers later means rewriting your request/response handling, re-testing prompts, and possibly re-architecting your streaming logic.
Step 2: Create a developer account
Most LLM providers separate their consumer product (the chat app) from their developer platform (the API). You'll typically need:
- An email address and phone number for verification.
- A payment method — pay-as-you-go billing is standard; free tiers exist but are usually rate-limited and not meant for production.
- Acceptance of usage policies, which often restrict certain content categories or require disclosure for consumer-facing apps.
Once your account is active, the API key lives in a "Keys," "API Keys," or "Credentials" section of the dashboard.
Step 3: Generate the key
The key itself is a long token string, usually prefixed to identify the provider (sk-..., sub_live_..., etc.). When you generate it:
- Name it descriptively — "prod-backend," "staging-worker," not "key1." This matters once you have five keys and need to revoke one.
- Copy it immediately — most dashboards show the full key only once. If you lose it, you'll need to regenerate.
- Scope it if possible — some platforms let you restrict a key to specific models, rate limits, or IP ranges. Use this for anything customer-facing.
Step 4: Store it securely
This is the step most tutorials skip and most incidents come from. A leaked LLM API key means someone else runs up your bill or, worse, uses your account for something that violates the provider's terms.
Basic rules:
# Never hardcode the key
const client = new LLMClient({ apiKey: "sk-abc123..." }); // don't do this
# Use environment variables instead
const client = new LLMClient({ apiKey: process.env.LLM_API_KEY });
- Add
.envto.gitignorebefore your first commit, not after. - Use your host's secret manager (Vercel, Railway, AWS Secrets Manager) in production rather than plaintext env files.
- Rotate keys periodically and immediately if one is exposed — check commit history and CI logs, not just the current codebase.
Step 5: Make your first request
Once the key is set, confirm it works with a minimal request before wiring it into your app. A basic curl test looks like this:
curl https://api.example.com/v1/messages \
-H "Authorization: Bearer $LLM_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "your-model-id",
"max_tokens": 100,
"messages": [{"role": "user", "content": "Say hello in one sentence."}]
}'
If you get a 200 response with model output, your key and billing setup are working. If you get a 401, the key or header format is wrong. A 429 usually means you've hit a rate limit on a free tier.
If you already have a Claude subscription
Here's a wrinkle most guides don't mention: if you're already paying for Claude as a subscriber (not a developer account), you don't automatically get an API key — the consumer plan and the developer API are billed and provisioned separately. Setting up a full API account means a separate signup, a separate billing relationship, and often minimum spend commitments depending on the provider.
SubToAPI exists specifically for this gap. It turns your existing Claude access into a standard HTTPS API without opening a second developer account: you get an application key (sub_live_...), full support for streaming responses, tool use, and usage metadata, all managed from one dashboard. If you're a solo developer or a small team that wants to build against Claude without navigating enterprise billing, it's usually faster to get running:
curl https://api.subtoapi.app/v1/messages \
-H "Authorization: Bearer $SUBTOAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-3-5-sonnet-latest",
"max_tokens": 200,
"messages": [{"role": "user", "content": "Summarize this in two sentences: ..."}]
}'
Plans start at €9/month for solo use, with team pricing at €19/seat and scale pricing at €49/seat, and there's a free trial at /signup. Full request/response formats are documented at /docs/messages, and streaming setup is covered at /docs/streaming.
Common mistakes to avoid
- Using a personal key in a shared codebase. Give each environment (dev, staging, prod) and each team member their own key so you can track usage and revoke individually.
- Skipping rate limit handling. Even a working key will throw 429s under load — implement exponential backoff from day one.
- Ignoring usage dashboards. Most providers show token usage and cost in near real time. Check it weekly until you have a sense of your baseline spend.
- Not testing tool use early. If your app depends on function calling, test it during your first integration pass, not after the rest of the app is built. See /docs/tools for a working example if you're using SubToAPI.
FAQ
Do I need a credit card to get an LLM API key? Most providers require a payment method to unlock production rate limits, even if they offer a limited free tier. Pay-as-you-go billing is standard, so you're only charged for tokens you actually use.
Can I use the same API key across multiple apps? Technically yes, but it's bad practice. Separate keys per app or environment make it easier to track costs, set limits, and revoke access if one key is compromised without affecting everything else.
What's the fastest way to get a working key if I already pay for Claude? Rather than opening a separate enterprise developer account, a service like SubToAPI lets you generate an API key from your existing Claude access in minutes — see /docs/quickstart for the setup steps.