Guides · AI coding agents
How to use your own API key with an AI coding tool
By Lalla Asmaa Alaoui, founder of Mel · Updated
Create an API key in your model provider's console, paste it into your coding tool's settings, and set a budget alert at the provider. The provider then bills your AI usage directly, at its own price.
This is often called BYOK, bring your own key. It suits people who already have a provider account, want to see exactly what they spend, or need a specific provider for work. The steps are the same idea for every provider; only the console differs.
Steps
- Pick a provider. Coding tools usually support several, such as Anthropic (Claude), OpenAI (GPT), Google (Gemini), DeepSeek and Alibaba Cloud (Qwen). Check which ones your tool supports before you sign up.
- Create an account and add billing. Most providers need a payment method before a key can call their paid models. Some offer a free tier with tight rate limits. Google AI Studio and Groq both give keys at no cost, with limits set by the provider.
- Create a key. In the provider's console, find the API keys page and create a new key. Name it after the tool, for example "mel-laptop", so you know where it is used. Copy it right away; many consoles show the full key only once.
- Add it to the tool, not to your code. Paste the key into the tool's settings screen. If the tool reads keys from an environment variable instead, set it in your shell (see how to set an environment variable), and never in a file you commit.
- Set a budget alert. In the provider's billing settings, set a monthly budget or alert so a long agent run cannot surprise you. Agents re-read your project and conversation many times, so usage adds up faster than with a chat.
- Test with a small task. Ask one short question and check the usage page in the provider's console. You should see the request appear.
- Keep it safe. - Use a separate key for each tool and each machine. - Revoke a key at once if it appears in a commit, a screenshot or a chat. - Rotate keys when a laptop is lost or someone leaves the team.
If a key was committed by mistake
Revoke it in the provider's console first, then create a new one. Removing it from your latest commit is not enough: the key stays in your git history and may already have been copied. To check your files for a key before you push, search for its first few characters:
git grep -n "sk-"Prefixes differ by provider; use the start of your own key.
Doing it with Mel
Mel is free with your own API key. You pay your provider directly, at its price, and pay Mel nothing for those turns.
- Download Mel for Mac, Windows or Linux and sign in with a free Mel account. The terminal works without an account; Mel's AI agent needs one.
- Click your avatar in the top-right, choose Settings, open AI and scroll to Provider API keys.
- Paste your key into its provider's row and click Save.
- Press ctrl+enter (cmd+enter on macOS) to start a conversation.
You can leave the model on Auto. When your own key is in use, Auto chooses among that provider's models only. Or pin a model yourself from the model chip.
Mel stores the key on your device: in the system keychain on Mac and Windows, and in a file only your user account can read on Linux. It travels with each agent request to Mel's relay, which uses it for that request and does not store it. Signing out of Mel removes the saved keys, so you paste them again after signing back in.
Mel works with Claude, GPT, Gemini, DeepSeek and Qwen, with 10 providers in the app. If you would rather not manage keys, Pro ($20/month) and Max ($200/month) include hosted credits, and Business gives a team shared credits and one invoice. You can add your own key on any plan; a turn on your key uses no Mel credits.
FAQ
What does BYOK mean? Bring your own key. You connect your own provider API key, and the provider bills you for the AI usage directly.
Is my API key safe in a coding tool? It depends on the tool. Look for keys stored in the system keychain, not in plain files, and never paste a key into a chat. Use a separate key per tool so you can revoke one alone.
Why did my key stop working? Common reasons: the provider account has no billing, a free-tier rate limit was reached, or the key was revoked. The provider's console shows which.
Can I use a free API key? Yes. Google AI Studio and Groq offer free keys with rate limits. Read their terms; Google's free tier, for example, may use what you send to improve its products.
Do I still pay Mel if I use my own key? No. Mel is free with your own API key. Your provider charges you for usage.
- How to set an environment variable on Mac, Linux and Windows
- How to compare two AI models on the same coding task
- What is a BYOK AI terminal?
- What is a multi-model coding agent?
Facts checked on Oct 25, 2026.
Google AI Studio and Groq are trademarks of their owners. Mel is not affiliated with or endorsed by Google AI Studio, Groq or their makers.
Mel – the agentic terminal · openmel.dev. A multi-agent, multi-model AI terminal for Mac, Windows, Linux and VS Code. Free with your own API key.

Lalla is a hands-on tech founder, agentic infrastructure architect and the vision behind Mel.
Follow on LinkedIn