How to get a Claude, ChatGPT and Gemini API key, and check pricing and free limits
Get an API key from each company's console with «Create key», and put it in an environment variable instead of writing it in code. Only Gemini has a free tier; ChatGPT and Claude charge for what you use.
Where to goaistudio.google.com/apikeyplatform.openai.com/api-keysplatform.claude.com/settings/keys
Steps
- If this is your first time, get just one key. You can follow Part 3 with a single Gemini key. For Gemini, sign in at https://aistudio.google.com/apikey and click «Create key».

Entrance to the Google AI Studio API key screen 
Entrance to the Claude Console API keys screen 
List of API keys made in Google AI Studio (key text hidden) 
Entrance to the OpenAI API keys screen - Many places show the long string only once, when you create it, so put it in right away as in the next step.

Gemini API pricing table 
OpenAI API pricing table 
Claude API pricing table - Mac: open Terminal (Applications › Utilities › Terminal), put the key you got in place of
YOUR_KEY_HERE, and enter it one line at a time.echo 'export GEMINI_API_KEY="YOUR_KEY_HERE"' >> ~/.zshrc source ~/.zshrc echo ${GEMINI_API_KEY:0:6}
Claude Console spend limit screen (amount hidden) - Windows: enter it in Command Prompt (cmd), then close the window, open a new one, and check.
setx GEMINI_API_KEY "YOUR_KEY_HERE" echo %GEMINI_API_KEY% - Get a first answer with one line in Terminal (Mac/Linux). It worked if the answer is inside the long block of text.
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \ -H "x-goog-api-key: $GEMINI_API_KEY" \ -H 'Content-Type: application/json' \ -H "Api-Revision: 2026-05-20" \ -d '{"model": "gemini-4-hydrogen", "input": "Say hello in French, one word only"}'
Screen after getting the first Gemini answer in Terminal - For ChatGPT and Claude keys, only change the name to
OPENAI_API_KEYorANTHROPIC_API_KEYand set it the same way.
Where to get keys and the names programs read
- Gemini: https://aistudio.google.com/apikey ·
GEMINI_API_KEY - ChatGPT (OpenAI): https://platform.openai.com/api-keys ·
OPENAI_API_KEY - Claude: https://platform.claude.com/settings/keys ·
ANTHROPIC_API_KEY
Is it free?
- Gemini: there is a free tier. The models you can use and the daily limits are listed per model on the pricing page. The free tier is marked «content used to improve Google products», and the paid tier «not used».
- ChatGPT (OpenAI): we could not find a free tier description on the pricing page. You pay for what you use.
- Claude: we could not find a free tier description on the pricing page. You pay for what you use.
- Practice on Gemini's free tier; do work that involves customer text or personal data on a paid tier or another API.
Adding a card and checking pricing
API pricing is by the «token». A token is a small piece of text, and pricing pages usually list a price «per million tokens». Text you send (input) and text you get back (output) are priced differently.
Prices change often, so this guide gives no amounts, only links to each company's pricing page. Check that day's price at the link before paying.
On the billing screen, first look for a field that sets a monthly spending cap. Setting it low at the start keeps you from spending a lot by mistake.
In the Claude Console, open the spend limit menu under spend and usage; the monthly spend limit there can be changed with the adjust limit button.
If a key leaks
- Go back to where you got the key, delete it, and make a new one. A deleted key stops working right away.
- Put the new key in again by the steps above.
- Check that the key does not appear in code files, screenshots or blog posts. When posting, show only a stand-in like
YOUR_KEY_HERE.
Troubleshooting
Permission denied on the service.(403): the request went out without the key. On a Mac, check that you ransource ~/.zshrc; on Windows, check that you opened a new window.API key not valid. Please pass a valid API key.: the key was entered wrong, or spaces or quotes got in before or after it. Copy the key again and paste it in.echoprints nothing: on a Mac, check that you ransource ~/.zshrc; on Windows, check that you opened a new window.- You entered the key line twice: on a Mac the same line goes into
~/.zshrctwice. The lower line is the one used, so you can tidy it up later. - You hit the free tier limit: the daily limit differs by model. Check the row for your model in the pricing table.
Source
Related posts
- AI automationGetting started with AI automation: Claude vs ChatGPT vs Gemini — which one fits your workAll three have two routes: the chat window and the API. Work a person can paste in each time goes in the chat window; work that must run by itself at a set time or condition goes through the API.4 stepsclaude.ai › chatgpt.com › gemini.google.comRead
- AI automationGet a daily morning news summary email with the Gemini API: your first Python automationBuild one Python file that collects news headlines, has Gemini summarize them in five lines, and sends the summary to your Gmail. Ask an AI to write the code; this guide only covers how to put it in place and run it.8 stepspython.org › Terminal › myaccount.google.com/apppasswordsRead
- AI automationHow to make a Telegram AI bot: from a BotFather token to connecting AISend /newbot to @BotFather on Telegram to get a bot and a token, then use one Python file so Gemini answers whatever you send your bot. The same bot can also alert you when a web page you watch changes.9 stepsTelegram @BotFather › Terminal › news folder from part 3Read