# How to get an OpenAI API key, add credits and make a first call

> Create a key on the API keys page, buy at least $5 in prepaid credits, store the key as OPENAI_API_KEY and fix the 401 and 429 errors.

URL: https://claudegpt.si/news/openai-api-key-how-to-get  
Published: 2026-11-25T02:58:59.564Z  
Author: ClaudeGPT Si Newsroom  
Section: Guides  
Topics: OpenAI, OpenAI API, API keys, How to, Developer tools  
Publisher: ClaudeGPT Si

## Key takeaways

- You create an OpenAI API key on the API keys page of a project, and OpenAI shows the full key only once, when you create it.
- New API accounts use prepaid billing: the minimum credit purchase is $5, and purchased credits expire after one year, as of November 25, 2026.
- A 429 error with insufficient_quota is a billing problem, so retrying won't help: add credits or raise your spend limit.

To get an OpenAI API key, sign in to the OpenAI API Platform, open the [API keys page](https://platform.openai.com/api-keys), create a new secret key in a project and copy it at once, because OpenAI shows the full key only when you create it. To use the key beyond a free test request, add prepaid credits in billing; the minimum purchase is $5, as of November 25, 2026.

This guide takes you from no account to a stored key, credits and a first curl request, with fixes for the 401 and 429 errors. Every step comes from OpenAI's [API quickstart](https://developers.openai.com/api/docs/quickstart), its API docs and its [help center](https://help.openai.com/en/articles/4936850-where-do-i-find-my-openai-api-key).

## What you need first

- An account on the OpenAI API Platform at platform.openai.com. A ChatGPT Plus subscription comes with no API credits; only eligible Pro and Business plans do.
- A payment card, unless you only want to send a test request or you have free credits from a ChatGPT Pro or Business plan (more on that below).
- A terminal with curl, or Python or Node.js if you prefer an SDK.
- You must be in a country OpenAI supports. Requests from elsewhere fail with a 403 error, according to OpenAI's [error codes guide](https://developers.openai.com/api/docs/guides/error-codes).

## How organizations and projects work

Every API account sits in an organization, and every organization has projects. OpenAI's help article on [managing projects](https://help.openai.com/en/articles/9186755-managing-projects-in-the-api-platform) says each organization comes with a Default project that can't be deleted, and that "each project has its own API keys". Projects also carry their own rate limits, model permissions and spend limits.

For a first key, the Default project is fine. Only organization owners can create new projects: open the project selector, choose to create a project, give it a name and pick a data residency option. OpenAI's [production best practices](https://developers.openai.com/api/docs/guides/production-best-practices) suggest separate projects for staging and production once you ship something.

## How to get an OpenAI API key, step by step

1. Sign in at platform.openai.com and pick the organization and project you want the key to belong to.
2. Open the [API keys page](https://platform.openai.com/api-keys). You can also reach it from the project's settings under **API Keys**.
3. Select **+ Create new secret key**.
4. Choose the key's permissions (see the next section). The default is **All**.
5. Set an expiration date. OpenAI "strongly recommend[s]" one in its production guide, along with a regular rotation schedule.
6. Create the key and copy it immediately. OpenAI's help center says: "For security, a full secret key is only shown when you create it." If you lose it, you can't view it again. Create a new one and update your code.

To delete a key, select the trash icon next to it on the same page. Anything that uses that key stops working. OpenAI's [authentication docs](https://developers.openai.com/api/docs/api-reference/authentication) say a revoked key stops working within a few seconds.

## Choose key permissions: All, Restricted or Read Only

OpenAI's help article on [API key permissions](https://help.openai.com/en/articles/8867743-assign-api-key-permissions) lists three levels for a project key:

| Permission | What the key can do |
| --- | --- |
| All | Full access to the project's API resources. This is the default. |
| Restricted | Only the resources and endpoints you pick, each set to None, Read, Write or a request-specific permission. |
| Read Only | Read access to every endpoint, and nothing else. |

A restricted key suits an app that needs only one or two endpoints. Scopes never grant more than the key's owner has: OpenAI's [API keys and service accounts guide](https://developers.openai.com/api/docs/guides/api-keys) says an unrestricted key "still operates within its owner's effective permissions".

The same guide says to use your own project key for local development and a service account key for a deployed app or CI job, so the app doesn't depend on one developer's account.

## How to add billing and credits

New API accounts pay in advance. OpenAI's help article on [prepaid billing](https://help.openai.com/en/articles/8264778-what-is-prepaid-billing) says you buy credits first and your balance goes down as you use the API. As of November 25, 2026:

1. Go to your organization's [billing overview](https://platform.openai.com/account/billing/overview).
2. Select **Add payment details**, enter a card and choose a starting amount. The minimum is $5 and the default is $10.
3. Decide whether to keep **auto-reload** on. It is on by default. It tops up your balance when it drops below a threshold you set, by at least $5 a time, with an optional monthly cap.
4. Confirm. The balance can take a few minutes to update.

Purchased credits expire after one year. OpenAI's help center adds that credits bought in Japan after November 13, 2026 expire after 180 days.

Your total purchases also set your usage tier, which sets your rate limits and the most you can spend in a month. From OpenAI's [rate limits guide](https://developers.openai.com/api/docs/guides/rate-limits), as of November 25, 2026:

| Tier | How you qualify | Monthly usage limit |
| --- | --- | --- |
| Free | Be 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 |

The tier upgrades on its own as your purchases cross each threshold. You can see your per-model limits under Settings > Organization > Limits. To see what each model costs per token, check OpenAI's [pricing page](https://developers.openai.com/api/docs/pricing) or the side-by-side [AI API pricing](https://claudegpt.si/news/ai-api-pricing) table.

It is worth setting a hard spend limit before you start. OpenAI's [spend limits guide](https://developers.openai.com/api/docs/guides/spend-limits) explains how: under Organization limits or a project's Limits, select **Edit spend limit**, enter a monthly amount and turn on **Enforce a hard limit**. Without that switch, a spend limit only sends alerts.

## Is there a free OpenAI API key

There is no special free key. Every key comes from the same API keys page, and what a key can do depends on the credits and tier of its organization. OpenAI's own docs mention these free options, as of November 25, 2026:

- **A free test request.** The quickstart calls a first call a "free test API request" and points to billing for "higher limits". The rate limits guide lists a Free tier with a $100 monthly usage limit for users in an allowed geography. The docs do not say how much free usage a new account gets, so plan on buying the $5 minimum for any real work.
- **ChatGPT Pro and Business credits.** OpenAI's guide to [API credits for ChatGPT subscribers](https://developers.openai.com/api/docs/guides/chatgpt-api-credits) says eligible Pro plans get $100, $200 or $500 a month in API credits, and Business workspaces get $20 per Standard seat or $100 per Premium seat, capped at $500 a month. The subscription must be paid and at least seven days old, and you must own both it and the API organization. Plus, Go and Free plans don't qualify, and unused credits expire at the end of each billing cycle.
- **Researcher grants.** OpenAI's [Researcher Access Program](https://help.openai.com/en/articles/10139500-researcher-access-program-faq) lets researchers with an academic or research affiliation apply for up to $1,000 in API credits, valid for 12 months. Applications are reviewed each quarter.

OpenAI's docs list no student API key. A "free key" posted on another site belongs to someone else's account, and OpenAI's key safety rules say each person should use their own key and never share it.

## Store the key in an environment variable

Don't paste the key into your code. OpenAI's help article on [API key safety](https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety) recommends an environment variable named `OPENAI_API_KEY`, which every OpenAI SDK reads on its own.

On macOS or Linux:

```bash
export OPENAI_API_KEY="your_api_key_here"
```

On Windows, in PowerShell:

```powershell
setx OPENAI_API_KEY "your_api_key_here"
```

The quickstart suggests keeping the key somewhere safe, such as your `.zshrc` file, before you export it.

The same help article sets the other rules: never put the key in a browser or mobile app, never commit it to a repository, give each team member their own key, and rotate a key at once if you think it leaked.

## Make a first test call with curl

This request comes from OpenAI's [text generation guide](https://developers.openai.com/api/docs/guides/text). It was not run for this article, because no API key was available:

```bash
curl "https://api.openai.com/v1/responses" \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer $OPENAI_API_KEY" \
    -d '{
        "model": "gpt-6.2-astra",
        "input": "Write a one-sentence bedtime story about a unicorn."
    }'
```

The key goes in the `Authorization: Bearer` header. If it works, the reply is JSON with the model's text inside its `output` field. If you belong to more than one organization, add `OpenAI-Organization` and `OpenAI-Project` headers so the request is billed to the right place; the authentication docs say you can find both IDs in your dashboard settings.

## Common errors and how to fix them

OpenAI's [error codes guide](https://developers.openai.com/api/docs/guides/error-codes) lists what each one means:

| Error | What it means | Fix |
| --- | --- | --- |
| 401 Incorrect API key provided | The key has a typo or an extra space, belongs to another organization or project, was deleted, or an old key is cached | Check the variable, copy the key again, or create a new one |
| 401 Invalid Authentication | The key and the organization in the request don't match | Send the right key, and the right `OpenAI-Organization` header if you use one |
| 401 You must be a member of an organization | Your account isn't in any organization | Ask an organization owner to invite you, or request a new one through help.openai.com |
| 429 with `insufficient_quota` | A billing problem, not traffic | Read `error.code`: `credit_balance_exhausted` means add credits; a spend limit code means raise the limit |
| 429 Rate limit reached | Too many requests or tokens per minute | Slow down and follow the `Retry-After` header |
| 403 Country not supported | You are calling from an unsupported region | Call from a supported country |

The 429 `insufficient_quota` error is the one most new users hit. The error guide says the broad `error.type` can still be `insufficient_quota`, and the specific `error.code` tells you why: `credit_balance_exhausted`, `organization_spend_limit_exceeded`, `project_spend_limit_exceeded` or `organization_usage_limit_exceeded`. OpenAI is blunt about retries: "Retrying billing, spend, or quota errors won't restore API access." Add credits or raise the limit, then send the request again.

## Where to go next

Once the curl request works, install the SDK for your language (`pip install openai` or `npm install openai`) and follow the rest of OpenAI's quickstart. If you use more than one provider, the steps are similar for a [Claude API key](https://claudegpt.si/news/claude-how-to-get-api-key) and a [Gemini API key](https://claudegpt.si/news/gemini-how-to-get-api-key), and an [OpenRouter API key](https://claudegpt.si/news/openrouter-api-key) reaches OpenAI's models and others through one account.

## Frequently asked questions

### Is there a free OpenAI API key?

No special free key exists; every key comes from the API keys page, and its use depends on the organization's credits. OpenAI's quickstart offers a free test request, eligible ChatGPT Pro and Business plans include $100 to $500 a month in API credits, and researchers can apply for up to $1,000 in credits.

### Is there a free OpenAI API key for students?

OpenAI's API docs and help center list no student API key or student credits. The closest program is the Researcher Access Program, which offers up to $1,000 in API credits to researchers with an academic or research affiliation.

### How does OpenAI API billing work?

New accounts buy prepaid credits in the billing overview, starting at $5 with a $10 default, and usage is deducted from that balance. When the balance runs out, requests fail with a 429 error and the code credit_balance_exhausted.

### Where is the OpenAI API dashboard and login?

The API dashboard is at platform.openai.com, where you sign in to manage keys at platform.openai.com/api-keys and credits at platform.openai.com/account/billing/overview.

## Sources

- [Developer quickstart](https://developers.openai.com/api/docs/quickstart), OpenAI
- [API keys and service accounts](https://developers.openai.com/api/docs/guides/api-keys), OpenAI
- [Authentication](https://developers.openai.com/api/docs/api-reference/authentication), OpenAI
- [Rate limits](https://developers.openai.com/api/docs/guides/rate-limits), OpenAI
- [Error codes](https://developers.openai.com/api/docs/guides/error-codes), OpenAI
- [Spend limits](https://developers.openai.com/api/docs/guides/spend-limits), OpenAI
- [Production best practices](https://developers.openai.com/api/docs/guides/production-best-practices), OpenAI
- [Text generation](https://developers.openai.com/api/docs/guides/text), OpenAI
- [API credits for ChatGPT subscribers](https://developers.openai.com/api/docs/guides/chatgpt-api-credits), OpenAI
- [API pricing](https://developers.openai.com/api/docs/pricing), OpenAI
- [Where do I find my OpenAI API key?](https://help.openai.com/en/articles/4936850-where-do-i-find-my-openai-api-key), OpenAI Help Center
- [Assign API key permissions](https://help.openai.com/en/articles/8867743-assign-api-key-permissions), OpenAI Help Center
- [Managing projects in the API platform](https://help.openai.com/en/articles/9186755-managing-projects-in-the-api-platform), OpenAI Help Center
- [What is prepaid billing?](https://help.openai.com/en/articles/8264778-what-is-prepaid-billing), OpenAI Help Center
- [Best practices for API key safety](https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety), OpenAI Help Center
- [Researcher Access Program FAQ](https://help.openai.com/en/articles/10139500-researcher-access-program-faq), OpenAI Help Center
