How to Get an AI API Key: A Developer's Checklist
Getting an AI API key is a five-minute task once you know the steps: pick a provider, create an account, verify billing, generate a key from a dashboard, and store it as an environment variable instead of hardcoding it. The part that trips people up isn't the signup form — it's picking the right provider for how you plan to use the key, and setting it up so it doesn't leak or get rate-limited the first week.
This guide walks through the whole process, from choosing where to get the key to making your first authenticated request, plus the mistakes that cost people time and money later.
Step 1: Decide what you actually need the key for
Before signing up anywhere, answer three questions:
- Which model or capability do you need? Text generation, tool/function calling, vision, embeddings, or a mix.
- How much traffic will this handle? A side project calling the API a few times a day has very different needs than a production app serving thousands of users.
- Do you need a raw model API, or a wrapped one? Some providers give you direct access to their model; others (like SubToAPI) sit on top of an existing subscription and expose it as a standard HTTPS API with keys, streaming, and usage tracking built in — useful if you already pay for Claude access and don't want to manage a second billing relationship.
This decision determines where you sign up next.
Step 2: Create an account with the provider
Every provider follows roughly the same pattern:
- Go to the provider's signup page.
- Verify your email address.
- Add a payment method (most API access requires billing on file, even if you get free trial credit).
- Accept usage policies — some providers ask for identity verification for higher-tier access.
If you're setting up SubToAPI specifically, the flow is the same: create an account at /signup, and you get a free trial before any billing kicks in.
Step 3: Generate the API key from your dashboard
Once your account exists, look for a section usually labeled API Keys, Developer Settings, or Credentials. Generating a key typically looks like:
- Click "Create new key."
- Give it a name that describes its purpose (
prod-backend,local-dev,ci-pipeline) — this matters once you have more than one key. - Copy the key immediately. Most providers only show the full key once and store a masked version afterward.
With SubToAPI, keys follow the sub_live_... format and are generated from your dashboard after signup. You can create separate keys per application or per team member, which keeps usage and billing traceable without sharing one key across a whole team.
Step 4: Store the key correctly
This is the step people skip and regret. Never commit an API key to source control, never paste it into a frontend JavaScript file, and never share it in a Slack message that stays in history forever.
The standard practice:
# .env (add this file to .gitignore)
SUBTOAPI_KEY=sub_live_xxxxxxxxxxxxxxxx
Then read it from environment variables in your code:
const apiKey = process.env.SUBTOAPI_KEY;
if (!apiKey) {
throw new Error("Missing SUBTOAPI_KEY environment variable");
}
If you're deploying to a hosting platform (Vercel, Railway, a Docker container, etc.), set the environment variable in that platform's dashboard or secrets manager — not in the codebase.
Step 5: Make your first authenticated request
Once the key is generated and stored, test it with a simple call before wiring it into your application. Here's what that looks like against SubToAPI's Messages endpoint:
curl https://api.subtoapi.app/v1/messages \
-H "Authorization: Bearer $SUBTOAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-3-5-sonnet",
"max_tokens": 256,
"messages": [
{ "role": "user", "content": "Say hello in one sentence." }
]
}'
If you get a 200 response with generated text, your key works and you're ready to build. Full request/response details are in the docs and a step-by-step walkthrough is in the quickstart.
Step 6: Plan for growth before you need it
A key that works for a prototype often needs adjustments before production:
- Streaming — if your app shows responses token by token, check the provider supports it and read their streaming docs before building the UI around it.
- Tool use / function calling — if your app needs the model to call external functions or APIs, confirm the provider supports structured tool calling; see tool use docs for the request format.
- Usage visibility — you'll want per-key or per-team usage metadata so you can see who's consuming what before a bill surprises you.
- Seats and team access — if more than one person on your team needs a key, look for a plan structure that supports per-seat billing instead of sharing a single key. SubToAPI's pricing is structured this way: Solo at €9 for individual use, Team at €19/seat, and Scale at €49/seat for larger usage with more headroom.
Getting the key is the easy part. Structuring your keys, environment variables, and billing so they scale with your team is what actually matters six months in.
questions
Do I need a credit card to get an AI API key? Usually yes, even for free trials — most providers require a payment method on file before issuing a key, though you won't be charged until the trial ends or you exceed free usage limits.
Can I use the same API key across multiple projects? Technically yes, but it's not recommended. Separate keys per project or environment make it easier to track usage, revoke access if one key leaks, and see which app is driving your bill.
What's the difference between an API key from a model provider and one from a service like SubToAPI? A model provider's key gives direct access to their model and billing system. SubToAPI issues a key that wraps your existing Claude access into a standard HTTPS API with streaming, tool use, and usage tracking, so you get an API key without setting up separate provider billing.