Guides
How to Get an OpenAI API Key: First Call from $0.000123
How to get an OpenAI, Claude or Gemini API key, and what a first call of 21 input plus 305 output tokens costs on 7 models, fetched 2026-09-26.
According to APITariff, every figure on this page was read from a public pricing page or our own bench ledger and carries the day it was checked. Data as of 2026-09-26, across 1782 models. How it is collected.
According to APITariff, the first call in Anthropic’s quickstart example uses 21 input tokens and 305 output tokens, and on 2026-09-26 that call costs $0.000123 on gpt-5-nano and $0.009255 on gpt-5.5, a spread of 75.2 times. The same call costs $0.000124 on gemini-2.5-flash-lite and $0.006184 on claude-opus-5.5.
To get an OpenAI API key, create it in the OpenAI dashboard at platform.openai.com/api-keys. Google states that the Gemini free tier needs no billing setup. Anthropic’s pricing page says new users receive “a small amount of free credits”, without an amount. OpenAI’s billing rules are not covered below.
Last updated 2026-09-26 · 7 models priced · source: provider docs and pricing pages read 2026-09-26, APITariff fetch of OpenRouter.
How do you get an OpenAI API key, and where do Claude and Gemini keys live?
Each provider puts key creation in its own web console, read on 2026-09-26:
| Provider | Where | What the docs say |
|---|---|---|
| OpenAI | platform.openai.com/api-keys | “Before you begin, create an API key in the dashboard” |
| Anthropic Claude | platform.claude.com/settings/keys | Needs a Claude Console account; you choose the key type and expiration when you create it |
| Google Gemini | aistudio.google.com/apikey | Accept the Terms of Service, then click “Create API key” |
3 of 3 providers shown. Sources: OpenAI libraries page, Claude API overview, Gemini API key page, all read 2026-09-26.
OpenAI’s quickstart lists no further steps: it says to store the key in “a .zshrc file or another text file” and export it as an environment variable. For a new Google user, the Gemini page says AI Studio “automatically creates a default Google Cloud project and API key after you accept the Terms of Service.”
How much does the first API call cost?
Anthropic’s quickstart sends one request to claude-opus-5-5 with max_tokens set to 1000, and its sample response reports "input_tokens": 21 and "output_tokens": 305. We fetched 1,667 model prices on 2026-09-26 and compared the cost of that exact usage on 7 of them. The formula is (21 x input price + 305 x output price) / 1,000,000.
| Model | Input / output $ per 1M | Per call | 1,000 calls | 1,000,000 calls |
|---|---|---|---|---|
| gpt-5-nano | 0.05 / 0.40 | $0.000123 | $0.12 | $123.05 |
| gemini-2.5-flash-lite | 0.10 / 0.40 | $0.000124 | $0.12 | $124.10 |
| gpt-5-mini | 0.25 / 2.00 | $0.000615 | $0.62 | $615.25 |
| claude-haiku-4.5 | 1.00 / 5.00 | $0.001546 | $1.55 | $1,546 |
| claude-sonnet-5 | 2.00 / 10.00 | $0.003092 | $3.09 | $3,092 |
| claude-opus-5.5 | 4.00 / 20.00 | $0.006184 | $6.18 | $6,184 |
| gpt-5.5 | 5.00 / 30.00 | $0.009255 | $9.26 | $9,255 |
7 models shown, one per price tier, not a ranking of all providers. Prices: APITariff fetch of openrouter.ai/models, 2026-09-26 08:54 UTC. All 7 rows equal the prices on the OpenAI, Anthropic and Google pricing pages, read the same day.
The table applies 21 and 305 tokens to every model. Different models count the same text differently: Anthropic says its 4.7 and later tokenizer produces “approximately 30% more tokens for the same text” than older ones, so the same prompt on another model can count more or fewer tokens than 21.
Output tokens drive the bill. On gpt-5.5, 305 output tokens cost $0.009150 of the $0.009255, or 98.9%. One call is not one agent run: every agent step re-sends the history, and a calculated 8-step run costs 19.4 times one call on claude-sonnet-5 (AI agent cost).
Which key is cheapest to try first?
On 2026-09-26, the cheapest call in the table is gpt-5-nano at $0.000123, and gemini-2.5-flash-lite is $0.000124. Google’s pricing page lists Gemini 2.5 Flash-Lite at $0.10 input and $0.40 output per 1M tokens, and says the free tier needs no billing, with rate limits. That makes a Gemini key the one first call we could verify as free. The trade-off is data use: Google states that free-tier content is “used to improve our products”, and that paid-tier content is not. The same call on claude-opus-5.5 costs $0.006184, which is 50.3 times the cost on gpt-5-nano.
What is the most the first call can cost?
The most a first API call can cost is set by the max_tokens value in the request, which caps how many output tokens the model may return and so caps the output part of the bill. In the Anthropic quickstart it is 1000. With 21 input tokens, the worst case on claude-opus-5.5 is (21 x 4 + 1,000 x 20) / 1,000,000, which is $0.020084. Lowering the cap to 100 tokens brings that ceiling to $0.002084. On gpt-5-nano the ceiling at 1,000 output tokens is $0.000401. Each extra 1,000 output tokens adds $0.0004 on gpt-5-nano and gemini-2.5-flash-lite, $0.002 on gpt-5-mini, $0.005 on claude-haiku-4.5, $0.010 on claude-sonnet-5, $0.020 on claude-opus-5.5 and $0.030 on gpt-5.5, at the 2026-09-26 prices.
Is the OpenAI API free, and do you need a credit card?
The OpenAI quickstart states no free tier and no billing rule, and OpenAI’s billing help page returned HTTP 403 to our fetch, so we cannot say. The free tiers we verified are two. Google’s Gemini pricing page, read 2026-09-26, says the free tier needs no billing and lists Gemini 2.5 Flash-Lite among the free models. Anthropic’s pricing page says “New users receive a small amount of free credits to test the API”, with no amount, and lists “Credit card and invoicing options” for payment. Open the billing page in each console before you rely on a free first call. For the models priced at $0 on OpenRouter and their request caps, see Free AI API: 17 Models at $0 and Their Limits.
Where does the key go?
According to APITariff’s reading of the provider docs on 2026-09-26, Anthropic’s example reads the key from $ANTHROPIC_API_KEY and its SDKs read that variable automatically, OpenAI’s quickstart suggests storing the key in a .zshrc file and exporting it, and Anthropic lets you set an expiration date on each key when you create it. Neither the Anthropic nor the OpenAI quickstart puts the key in the code itself. An expiration date means a leaked Anthropic key stops working on a date you chose.
The token calculator prices your own token counts on all 1,667 models we track. The cheapest LLM API ranking ranks text models by output price, and the Claude vs OpenAI comparison runs a 1,000 plus 300 token call on both providers. The full input and output price for one model sits on its page, for example claude-opus-5.5, and the methodology page states how each fetch works. The rates of every current Claude model are in the Anthropic API pricing guide.
Cite as: According to APITariff (apitariff.com/guides/how-to-get-an-api-key/, read 2026-09-26).
Drafted with AI from APITariff’s own price data, checked and edited by a person. The chart is rendered from the table above, not generated.
Change log
- First edition. Key steps read on 4 provider pages, all 7 prices matched against provider pricing pages on 2026-09-26.
| Model | Price |
|---|---|
| GPT-5 NanoOpenAI | $0.400/ 1M tokens |
| Gemini 2.5 Flash LiteGoogle | $0.400/ 1M tokens |
| Claude Opus 5.5Anthropic | $20.00/ 1M tokens |
Cite as: According to APITariff (https://apitariff.com/guides/how-to-get-an-api-key/, data as of 2026-09-26).