Skip to the programs
startupcredits.fyi

How to get an OpenAI API key (2026): steps, billing and free credits

Create an OpenAI API key in 6 steps: sign up, pick a project, add $5 of credit, create the key. Plus usage tiers, rate limits and the real routes to free credits.

To get an OpenAI API key, sign up on the OpenAI API platform, add at least $5 of prepaid credit, then open your project's API Keys page and select Create new secret key. The key is shown only once, so copy it into an environment variable called OPENAI_API_KEY straight away.

There is no such thing as a free OpenAI API key, but there are legitimate ways to get free API credit. Both are covered below, after the steps.

How to create an OpenAI API key, step by step

1. Create an API platform account

Go to platform.openai.com and sign up with a Google account, a Microsoft account, or an email and password. Your account gets an API organization, which is what billing, limits and keys belong to.

Check that you are in one of OpenAI's supported countries. OpenAI says that using the API from elsewhere may get your account blocked or suspended.

2. Choose or create a project

Every key belongs to a project. Projects keep keys, usage, spend limits and model access separate, so it is worth creating one per app or environment (for example myapp-dev and myapp-prod) before you make keys.

Organization owners can create projects and set spend limits. Project members can create keys inside the projects they belong to.

3. Add billing and buy credits

New API accounts use prepaid billing: you buy credits first and usage draws them down. In your organization's billing overview:

  1. Select Add payment details and enter a card.
  2. Choose your first credit purchase. The minimum is $5 and the default is $10.
  3. Decide on auto-reload. It is on by default during setup and buys more credit when your balance falls below a threshold. Turn it off if you want a hard stop, or set a monthly reload limit.
  4. Confirm the purchase. The balance can take a few minutes to appear.

Purchased credits expire after one year and are generally non-refundable.

The one exception to buying credits: if you have a paid ChatGPT Pro or Business subscription, you can link it to an API organization you own and use its monthly API credits with no payment method on the API side. See the free credits section below.

4. Create the secret key

  1. Open Organization settings and select your project.
  2. Open API Keys and select + Create new secret key.
  3. Pick permissions: All (the default), Restricted (choose scopes per resource, such as read-only Files), or Read only.
  4. Set an expiration date if you can. OpenAI recommends expiring keys and rotating them.
  5. Copy the key. OpenAI shows the full secret only at creation. If you lose it, you have to create a new one.

For an app running in production, CI or a scheduled job, OpenAI recommends a service account in the project rather than a key tied to your personal user. Service accounts are created from the project's Members settings and their keys only work inside that project.

5. Store the key in an environment variable

On macOS or Linux:

export OPENAI_API_KEY="your_api_key_here"

On Windows (PowerShell or cmd):

setx OPENAI_API_KEY "your_api_key_here"

The official OpenAI SDKs read OPENAI_API_KEY automatically, so the key never needs to appear in your code.

6. Make a test request

Install the SDK with pip install openai (or npm install openai) and run:

from openai import OpenAI

client = OpenAI()

response = client.responses.create(
    model="gpt-6-luna",
    input="Say hello in five words.",
)
print(response.output_text)

GPT-6 Luna is the cheapest current model at $0.10 per million input tokens and $0.50 per million output tokens, so a test like this costs a fraction of a cent. OpenAI's own quickstart uses GPT-6.2 Astra, which costs 80 times more per token. Full prices are in our OpenAI API pricing guide.

OpenAI usage tiers and rate limits

Your organization's tier rises automatically with your total credit purchases. Higher tiers get a higher monthly usage limit and higher rate limits.

TierHow you qualifyMonthly usage limit
FreeBe in an allowed geography$100
Build$5 in total credit purchases$500
Launch$100 in total credit purchases$5,000
Grow$500 in total credit purchases$200,000

Standard rate limits per tier, in requests per minute (RPM) and tokens per minute (TPM):

TierAstra, Sol and Terra modelsLuna models
Build5,000 RPM, 1M TPM5,000 RPM, 2M TPM
Launch10,000 RPM, 4M TPM10,000 RPM, 10M TPM
Grow15,000 RPM, 40M TPM30,000 RPM, 180M TPM

Limits apply per organization and per project, not per user. Your exact numbers are under Settings > Organization > Limits. A tier is not a guarantee of access to every model: if a model is missing, check the project's model permissions.

Set a spend limit before you ship

The usage limit above is OpenAI's cap. You should set your own. OpenAI offers two controls:

  • Spend alert: emails you at an amount; traffic keeps flowing.
  • Hard spend limit: requests return a 429 error once the limit is hit. You can set one per organization, per project, or per API key.

Enforcement is not instant, so spend can slightly exceed the limit. A prepaid balance is not an instant cutoff either: usage processed after the balance hits zero shows up as a negative balance, which is deducted from your next purchase. When the balance is fully exhausted, requests fail with the error code credit_balance_exhausted.

Is there a free OpenAI API key?

No. OpenAI does not hand out free keys, and its current billing documentation describes no signup credit for new accounts. New accounts start on prepaid billing. The "Free" usage tier in the table above is a monthly limit, not free money: you still need a positive balance or a credit grant for requests to run.

What does exist is free credit, through these routes:

RouteWhat you getWho qualifies
ChatGPT Pro subscription$100, $200 or $500 a month in API creditsPro 100, Pro 200 and Pro 500 subscribers, subscription at least 7 days old
ChatGPT Business subscription$20 per Standard seat, $100 per Premium seat, capped at $500 a monthBusiness workspace owners
Data-sharing complimentary tokensUp to 1M and 10M tokens a day on two model groups (250K and 2.5M on the Build tier)Organizations OpenAI marks as eligible that opt in to share API inputs and outputs
Researcher Access ProgramUp to $1,000, valid 12 monthsResearchers studying responsible AI deployment, risks or societal impact, at an academic institution, research organization or research nonprofit
OpenAI for StartupsAmount not publishedStartups backed by a VC in OpenAI's partner network

Some notes on each:

  • ChatGPT subscriber credits expire at the end of each billing cycle and do not roll over. They cover the Responses API, Agents API, Realtime, Images and built-in tools, but not Codex used through an API key.
  • Complimentary tokens still require a positive account balance, and they only apply to traffic you share with OpenAI, so do not enable sharing on projects with customer data you cannot share. You can check eligibility on your organization's data sharing settings page; if you do not see the offer, you are not eligible. OpenAI says it will give 30 days' notice before ending the program.
  • Startup credits also come from outside OpenAI. Microsoft for Startups Azure credits cover Azure OpenAI models, and AWS Activate credits cover third-party models on Amazon Bedrock, including OpenAI's. Our OpenAI credits guide covers every route in detail.

Beware of "free OpenAI API key" lists

Search results, GitHub repos, Discord servers and Telegram channels regularly offer "free" or "working" OpenAI keys. Any key you did not create belongs to someone else's paid account. It is either leaked, stolen, or shared against OpenAI's rules: OpenAI's Terms of Use prohibit sharing API keys, and OpenAI says it does not support it. Expect such keys to be revoked without warning, and do not build anything on one.

The reverse risk is bigger. Never paste your own key into a website, browser extension or bot that promises free credits, cheaper access or a "key checker". Anyone holding your key can spend your balance.

How to keep your OpenAI API key safe

OpenAI's API key safety guide recommends:

  1. One key per person. Invite teammates to the organization so each creates their own key.
  2. Expiry and rotation. Create the replacement key, deploy it, confirm it works, then revoke the old one.
  3. Never in client-side code. Do not ship a key in a browser app or mobile app. Route requests through your own backend.
  4. Never in a repository. Use environment variables or a secret manager, and add .env files to .gitignore.
  5. Hard spend limits on every project and production key, so a leak has a ceiling.
  6. IP allowlisting to accept requests only from your servers.
  7. Rotate immediately from the API Keys page if you suspect a leak, then contact OpenAI support.

OpenAI API key vs ChatGPT subscription

An API key is for building software that calls OpenAI models, billed per token. A ChatGPT subscription is for people using ChatGPT and Codex through OpenAI's own apps, billed per month or per seat. The two have separate billing and separate limits. If your team mainly needs ChatGPT seats, see ChatGPT Business pricing; if you want a coding agent, see Codex pricing.

Questions

Is an OpenAI API key free?

Creating a key is free, but using it is not. New API accounts use prepaid billing, so you need to buy at least $5 of credit before requests succeed, unless your organization already has a credit grant such as the monthly API credits included with ChatGPT Pro or Business.

How much do I need to pay to start using the OpenAI API?

The minimum first credit purchase is $5 and the default is $10. Paying $5 also moves your organization into the Build usage tier, which raises its monthly usage limit to $500.

I lost my OpenAI API key. Can I see it again?

No. OpenAI shows the full secret key only once, when you create it. Create a new key, update your application to use it, and delete the old one.

Can I use my ChatGPT Plus subscription with the API?

No. ChatGPT Plus and the API are billed separately and Plus includes no API credits. ChatGPT Pro and Business subscribers can link their subscription to an API organization they own and receive monthly API credits.

Do OpenAI API keys expire?

Project keys can be created with an expiration date, and administrators can enforce a maximum key lifetime for an organization or project. OpenAI recommends setting an expiry and rotating keys on a regular schedule.

Programs in this guide

  1. OpenAIOpenAI for StartupsFree API credits, rate limit upgrades and time with solutions engineers for startups backed by an OpenAI VC partner (amount not published)Needs an investorUnpublished
  2. MicrosoftMicrosoft for StartupsUp to $150,000 in Azure Startup creditsApply directly$150K
  3. Amazon Web ServicesAWS ActivateUp to $200,000 in AWS Activate CreditsNeeds an investor$200K

Sources