What Is an API Key?

Updated April 28, 2026 · Data as of 2026-04-26

An API key is a unique credential — a long string of characters — that identifies your account when you send requests to an AI provider like Anthropic, OpenAI, or Google.

When you use a bring-your-own-key (BYO-key) AI coding tool like Cline or Roo Code, the tool connects directly to an AI provider's API using your account credentials. The API key is how the provider knows the request is coming from you, which model to use, and where to send the bill. Without it, the tool has no way to access the model.

Most AI coding tools fall into one of two categories on this point. Subscription tools — Cursor, Windsurf, Replit, GitHub Copilot — handle the model connection for you. You pay them a monthly fee and they manage the API relationship. You never see an API key. BYO-key tools — Cline, Roo Code, and direct API access for Claude Code — require you to set up your own account with the AI provider and manage costs directly. The tradeoff is control versus convenience.

How to get one

Getting an API key takes a few minutes. For Anthropic (Claude): go to console.anthropic.com, create an account, add a payment method, and navigate to API Keys to generate a key. For OpenAI (GPT): go to platform.openai.com and follow the same steps. For Google (Gemini): go to aistudio.google.com. In each case, the key appears only once when you generate it — copy it and store it somewhere secure before closing the window. You cannot retrieve it again; you can only generate a new one.

Frequently asked questions

Is it safe to enter my API key into a coding tool?

For established open-source tools like Cline (a VS Code extension), yes. The key is stored locally in VS Code's settings and is never transmitted to a third party — requests go directly from your machine to the API provider. For less-known tools, check their documentation and privacy policy before entering a key. As a rule: never paste an API key into a chat window, never commit it to a git repository, and never share it.

What does API key usage cost?

It depends on which model you use and how much. Pricing is per million tokens of input and output. For typical active coding use with Claude Sonnet, expect $10 to $30 per month. Lighter use might cost $2 to $5. Heavier agentic use with large codebase context can run higher. The tokens glossary page has more detail on what typical sessions cost.

Can I use multiple API keys with the same tool?

Most BYO-key tools support one active key at a time per provider, but you can configure different providers for different tasks. Cline, for example, lets you set a primary model from any supported provider and switch between them in settings. You can have an Anthropic key and an OpenAI key configured simultaneously. Check your specific tool's documentation for how multi-provider configuration works.

Back to WhichAI · How we score tools