How do I get an API key for ChatGPT? The short answer is that you create one on OpenAI’s developer platform at platform.openai.com — it takes about five minutes, the key itself costs nothing to create, and you only pay for what you use. This guide walks through each step: setting up your account, generating your first secret key, adding billing so the key actually works, and keeping it safe once you start building.

What is in this guide
- What is a ChatGPT API key?
- Before you start: what you need
- Step 1: Create an OpenAI platform account
- Step 2: Add billing and set a spending limit
- Step 3: Create your API key
- Step 4: Make your first API call
- How to keep your API key safe
- What does the ChatGPT API cost?
- Fixing common API key problems
- Frequently asked questions
What is a ChatGPT API key?
An API key is a secret string of characters that lets your own code talk to OpenAI’s models. When your app, script, or website sends a request to the OpenAI API, the key identifies your account, and OpenAI bills the usage to you. Without a key, your code has no way to prove who is making the request, and OpenAI has no account to charge.
It helps to understand what the key is not. It is not your ChatGPT login password, and it is not the same as a ChatGPT Plus subscription. The ChatGPT app you chat with at chatgpt.com and the developer API at platform.openai.com are two separate products with separate billing. A Plus subscription does not include API credit, and API usage does not require a Plus subscription. You can use one, both, or neither.
People use API keys for all kinds of projects: chatbots on their own websites, tools that summarise documents, scripts that sort email, and apps that generate content at scale. If you only want to chat with ChatGPT in a browser, you do not need a key at all — our guide to whether ChatGPT is free explains the chat plans. The key only matters when you want your own software to call the models directly.
Before you start: what you need
Getting a key is straightforward, but a little preparation saves you from hitting a wall halfway through. You need an email address you can access, since OpenAI sends a verification message during sign-up. You can also sign up with a Google, Microsoft, or Apple account if you prefer.
You will also need a payment method. OpenAI runs the API on pay-as-you-go billing, and a card on file is required before your key will work for paid models. New accounts sometimes receive a small amount of free credit to try things out, but that credit is limited and expires, so plan on adding a card. Have one ready before you start.
Finally, decide where the key will live. The best home for it is a password manager or a secure environment variable on your own computer or server — never a shared document, a chat message, or a public code repository. If you are new to working with keys, the safety section later in this guide explains exactly how to store one.
Step 1: Create an OpenAI platform account
- Go to platform.openai.com in your browser.
- Click Sign up. You can register with an email address, or sign in with Google, Microsoft, or Apple.
- If you sign up by email, check your inbox for the verification message and confirm your address.
- Complete your profile. OpenAI may ask for your name and, in some regions, a phone number for verification.
- Once you are in, you will see the developer dashboard. This is your home base for keys, billing, and usage.
If you already have a ChatGPT account, you can use the same login for the platform — the accounts are linked. You will still need to set up billing separately on the platform side, because chat and API billing are kept apart. You may also be asked to create an organisation, which is simply the billing container your keys belong to. For a personal project, a single organisation with your own name is all you need.

Step 2: Add billing and set a spending limit
This is the step most beginners skip — and then wonder why their key returns an error. OpenAI requires a payment method on file before API calls will work. Adding billing takes a couple of minutes, and setting a limit at the same time protects you from surprise charges.
- In the platform dashboard, open Settings, then Billing.
- Click Add payment method and enter your card details.
- Look for the usage limits section and set a monthly spending limit. For a personal project, a modest cap such as $10 to $50 a month is a sensible starting point. API access stops when you hit the cap, so a bug in your code can never run up a large bill.
- Consider turning on auto-recharge only if you want your balance to top up automatically. For a first project, leave it off and top up by hand until you know your real usage.
One reassurance: creating the key itself costs nothing, and you are only charged for the tokens your requests actually use. A token is roughly a word fragment — about 750 words per 1,000 tokens — and prices vary by model. Small experiments cost pennies, which is why a low monthly cap is such good protection while you learn.
Step 3: Create your API key
With your account ready and billing in place, generating the key takes less than a minute. Here is the exact route.
- Go to platform.openai.com/api-keys, or open Settings in the dashboard and click API keys in the sidebar.
- Click Create new secret key.
- Give the key a clear name, such as “my-blog-chatbot” or “personal-testing”. A good name tells you at a glance which project each key belongs to when you have several.
- Choose the permissions for the key. The default settings suit most first projects; you can tighten them later if a key only needs to do one job.
- Click Create secret key. Your key will appear on screen, starting with something like
sk-proj-. - Copy it immediately and paste it into your password manager or a secure note. OpenAI shows the full key only once. If you close the window without copying it, there is no way to see it again — you will have to delete it and create a new one.
That “shown once” rule catches almost everyone the first time. Treat the moment the key appears as the moment to save it. Do not paste it into a chat window, an email draft, or a shared document while you decide where it belongs — put it straight into your password manager.
Step 4: Make your first API call
A key sitting in a password manager does nothing on its own. The simplest way to check it works is a small test request from your own computer. Store the key as an environment variable rather than typing it into your code — on most systems that looks like export OPENAI_API_KEY="your-key-here" in a terminal, or a line in a .env file that your project loads at run time.
Once the key is set, send a short test prompt through your preferred tool or a small script: a simple “Hello” message to a current model is enough. If you get a sensible reply back, your key, billing, and setup are all working. If you get an error about billing or authentication, the troubleshooting section below covers the usual causes.
From here, the API opens up a wide range of uses. Developers wire it into chatbots, content tools, and automation scripts, while writers and marketers use it through apps that call the API on their behalf. If you are still deciding which AI tool fits your workflow, our AI writing tool guide compares the main options, and our ChatGPT detector guide explains how to check whether text looks AI-generated.

How to keep your API key safe
An API key is as sensitive as a password — anyone holding it can spend your money. A few habits keep that risk small.
Never hard-code a key into your source code
Store keys in environment variables or a secrets manager, never as plain text in a script. Code has a habit of being shared, copied, or uploaded somewhere public, and a key buried in it goes along for the ride.
Never commit a key to a public repository
GitHub and similar services are scanned constantly for leaked keys. If you use a .env file, add it to .gitignore before your first commit, and check that it is actually ignored before you push.
Use one key per project
Separate keys let you revoke one without breaking everything else. If a key for a side project leaks, you can delete just that key while your main app keeps running.
Rotate keys when someone leaves or a project ends
Delete keys you no longer need from the API keys page. A key that does not exist cannot be misused, and a tidy key list makes it obvious when something unfamiliar appears.
Watch your usage dashboard
Check the usage page in the platform dashboard from time to time. A sudden spike you cannot explain is worth investigating right away — it can mean a bug, or a key that has leaked. Set up usage alerts if your plan offers them, so you hear about unusual spending early rather than at the end of the month.
What does the ChatGPT API cost?
There is no monthly subscription fee for API access. OpenAI charges per token, and the price depends on which model you use — newer and more capable models cost more per token than smaller, faster ones. Short test prompts cost a fraction of a cent, while heavy use with the most capable models adds up, which is why the spending limit from step 2 matters.
Two points confuse beginners most. First, as noted above, a ChatGPT Plus subscription does not include API credit — chat and API are billed separately, and paying for one does not pay for the other. Second, prices change over time as OpenAI retires older models and introduces new ones, so check the current pricing page on OpenAI’s site before budgeting a project, rather than relying on figures in a guide written months ago. Start new projects with a current model from OpenAI’s models page, and keep your monthly cap low until you know your real usage.
Fixing common API key problems
“Incorrect API key provided”
This usually means the key was copied wrong or has been deleted. Copy it again from your password manager, checking for missing characters or extra spaces. If the key was deleted in the dashboard, create a fresh one — deleted keys cannot be restored.
“You exceeded your current quota”
This is almost always a billing issue. Check that a payment method is on file and that you have not hit your monthly spending limit. New accounts with no card on file will see this error even with a valid key.
“Rate limit reached”
You are sending requests faster than your account tier allows. Slow down, add a short pause between calls, or spread heavy work over time. If your project genuinely needs more throughput, the platform dashboard explains how higher usage tiers are unlocked.
The key worked yesterday and stopped today
Check the API keys page first — the key may have been deleted or rotated by someone with access to the account. Then check billing: an expired card or a reached spending cap produces the same silence. Finally, confirm the key in your code or environment variable still matches the one in the dashboard.
You think your key has leaked
Do not wait to be sure. Go to the API keys page, delete the compromised key at once, and create a replacement. Then find where it leaked — a public repository, a shared screenshot, a pasted log — and remove it from there too. Check the usage dashboard for any spending you do not recognise.

Frequently asked questions
Is a ChatGPT API key free?
Creating a key is free, and new accounts sometimes receive a small amount of trial credit. Real usage is billed per token on a pay-as-you-go basis, so you need a payment method on file before the key will work for paid models.
How do I get an API key for ChatGPT without a credit card?
You can create the key without a card, but the key will not work for paid models until billing is set up. Any free trial credit attached to a new account can cover small tests, but once it runs out, a card is required.
Does a ChatGPT Plus subscription include an API key?
No. Plus is a subscription for the ChatGPT app, while the API is billed separately per token. You need an OpenAI platform account with its own billing to use the API, whether or not you pay for Plus.
Can I share my API key with someone else?
You should not share a key directly. If a teammate or a tool needs access, create a separate key with a clear name for that person or project, and delete it when it is no longer needed. Shared keys are much harder to revoke cleanly.
What should I do if I lose my API key?
Nothing is lost — the key itself cannot be recovered, but you can simply delete it from the API keys page and create a new one. Update the new key wherever the old one was stored, and your project will be running again in minutes.
Getting an API key for ChatGPT is a five-minute job once you know the route: an account at platform.openai.com, billing and a spending limit in place, then a new secret key copied straight into a password manager. Keep it secret, keep one key per project, and check your usage now and then — and the key will quietly power whatever you build next.

