How to Get an OpenAI API Key in 2026: Platform Account, Project Key, and Billing
What "how to get an OpenAI API Key" actually means
People who search how to get an OpenAI API key, or the common Chinese query openai api key 怎么获取, are usually asking for a usable secret they can put in a client, not for a ChatGPT login. Those are two different products, with two different bills.
An OpenAI API key is a secret credential issued in the API platform. It authenticates HTTP requests to the API. A ChatGPT Plus or Pro subscription does not include API usage and does not give you an API key. OpenAI's billing help is explicit: ChatGPT and the API platform have separate billing systems, and API credits sit on an API organization, not on your ChatGPT plan.
This guide stays on the first question: create an account on the API platform, issue a project key, add prepaid credits, store the secret, and make a first call. It does not cover API key rotation or quotas and expiry; those come after you already have a working key.
Before you start: account, organization, and whether the API is available
You need an OpenAI account and access to an API organization. New accounts get an organization and a Default project automatically. Keys are scoped to a project. If you were invited to a company org, switch to that organization in the platform selector before you create a key, or you will be billing the wrong place.
The API is not available everywhere. OpenAI publishes a list of supported countries and territories. Locations that are not on that list are not supported. The company also states that accessing or offering access to the API from an unsupported location can lead to the account being blocked or suspended. If a first request returns 403 with "Country, region, or territory not supported," that is a location restriction, not a typo in the key. This guide does not cover workarounds.
Step 1: Create a project API key
OpenAI's help article Where do I find my OpenAI API Key? and the developer quickstart both point to the same action: create the key in the API dashboard.
- Sign in at platform.openai.com, not chatgpt.com.
- Confirm the organization and project in the selector at the top. Use the Default project for a first personal key, or create a dedicated project if you already know you will isolate an app or environment.
- Open the API keys page for that project and choose Create new secret key.
- Give the key a name you will recognize later, such as
local-devorstaging-web. Copy the secret immediately and store it somewhere only you can read.
The full secret is shown only at creation. If you close the dialog without saving it, you cannot look it up again. Create a new key and update your app. Deleting a key from the same page stops every client that still uses it.
OpenAI's API keys and service accounts guide distinguishes three credentials. Pick the one that matches the job:
|
What you are doing |
Credential to create |
|---|---|
|
Your own local development or exploration |
A user-owned project API key |
|
A deployed app, cron job, or CI pipeline |
A project service account, then a key owned by that service account |
|
Automation that creates projects or manages keys for others |
An Admin API key, used only for Admin APIs, never for model calls |
A user-owned key acts with your access. Do not share one developer's key across a team, and do not make one person's laptop key the permanent identity of a production service.
Step 2: Add prepaid credits (a key alone is not enough)
New API accounts use prepaid billing. Creating a key does not put money on the organization. Until a payment method is on file and credits are purchased, calls typically fail even if the key is valid. A common later error is 429 with credit_balance_exhausted.
If you can manage billing for the organization:
- Open the organization's API billing overview.
- Add payment details.
- Choose an initial credit purchase. The minimum is $5; the default amount during setup is $10.
- Review Use auto-reload before you confirm. It is turned on by default during setup. Turn it off if you do not want automatic purchases, or set a threshold, a restore-to amount, and an optional monthly reload limit.
- Confirm the purchase, then wait a few minutes for the balance to update.
Purchased credits expire after one year. OpenAI documents a shorter 180-day expiry for credits purchased in Japan after 13 November 2026. Credits are generally non-refundable except where law, contract, or an approved exception applies. Your trust tier, based on usage and payment history, caps the maximum balance the account can hold.
ChatGPT promotional credits, if any, are still API-organization credits. They are not a substitute for a ChatGPT subscription, and a Plus invoice is not a substitute for API prepaid credits.
Step 3: Store the key, then make a first call
The official quickstart expects the key in an environment variable named OPENAI_API_KEY. The official SDKs read that variable automatically.
On macOS or Linux:
export OPENAI_API_KEY="your_api_key_here"In Windows PowerShell:
setx OPENAI_API_KEY "your_api_key_here"Do not commit the secret to git, paste it into a shared chat, or bake it into a frontend bundle. If it leaks, revoke it on the API keys page and issue a new one; the rotation guide covers the overlap window.
A minimal Python check, from the quickstart, looks like this. Use a current model name from the official model list; names change.
from openai import OpenAI
client = OpenAI()
response = client.responses.create(
model="gpt-6.2-astra",
input="Reply with the single word pong.",
)
print(response.output_text)If this prints a short reply, the key, billing, and network path are working. You do not need a compatible third-party endpoint to get a first-party OpenAI key working. Compatible APIs are a different product: you change the base URL and often use a different vendor's key.
If the first call fails
Read the status code before you create another key. OpenAI's error codes map the usual cases:
|
Symptom |
What it usually means |
What to do first |
|---|---|---|
|
401, incorrect API key |
The secret is typo'd, truncated, from the wrong project, or already revoked |
Compare the key prefix and project, or create a new key and replace the env var |
|
401, not a member of an organization |
The account is not in an API organization |
Ask an org owner to invite you, then create the key in that org |
|
403, country or territory not supported |
The request is coming from a location that is not on the supported list |
Check the official list; this is not a key-format problem |
|
429, |
The organization has no prepaid credits left |
Add credits on the API billing page, then retry |
|
429, spend or usage limit |
An organization or project limit was hit |
Raise or remove the limit if you are allowed to, or wait for the period to reset |
If you wanted Claude's key flow instead, that is a different console: see how to use the Claude API. For a broader map of labs, clouds, hosts, and routers, see LLM API providers.
FAQ
Is a ChatGPT Plus subscription an OpenAI API key?
No. Plus is a ChatGPT product subscription. API usage is billed separately on the API platform. You still have to create a key and fund the API organization.
Where do I create the key, ChatGPT or the API platform?
Create it in the API platform at platform.openai.com, on the API keys page of the project you want the key to belong to. ChatGPT settings do not issue API keys.
Can I view an existing key again?
No. OpenAI only shows the full secret when you create it. If you lost it, create a new key and update every client that used the old one.
Do I have to buy credits before the key works?
On a new API account, yes in practice. New organizations use prepaid billing. A key without a credit balance will not get you very far; fund the organization from the API billing overview (minimum purchase $5).
Should I use a personal key in production?
No. Use a project service account and a key owned by that account for a deployed app or CI job, so the workload has its own identity and can be revoked without disabling a person's local development.
I already have an OpenAI-compatible key from another vendor. Is that the same thing?
No. An OpenAI-compatible API speaks a similar request format. It is not an OpenAI platform key, and it will not authenticate against api.openai.com unless that vendor is OpenAI.
Get the key, then fund it and store it
Getting an OpenAI API key is three short official steps: sign in to the API platform, create a project secret key and save it once, then add prepaid credits on the API billing page. Keep the secret in an environment variable, test one call, and only then wire it into an app. If a call fails, trust the status code — especially 401, 403, and 429 — before you assume the key itself is wrong.