Many people want to use OpenAI’s ChatGPT API but find the process confusing. Creating an account and generating API keys can be tricky, especially with permissions and limits to consider. This can be frustrating and time-consuming. 

But don't worry! We will simplify the steps to get your ChatGPT API key, set up projects, and understand the costs and limits. Follow along to quickly and easily start using OpenAI’s powerful tools for your projects.

Account creation

To use OpenAI through API, you must create a free account and generate keys. Fortunately, it is pretty straightforward.

1. Sign up here https://platform.openai.com/signup. You can use your Google or Microsoft account to sign up if you don't want to create using an email/password combination. You may need a valid mobile number to verify your account.

2. After signing up for ChatGPT, visit this page https://openai.com/api/ and click on "Start Building." 

3. Now you will reach your account's default project, OpenAI Playground. On this page, you need to click on the API keys located in the left bar section.

How to get ChatGPT API Key

Permissions and Ownership

  • Project vs. Organization Owners: Only owners of an organization can create projects. Project owners can then create API keys specific to that project.

  • Default Project: Every organization has a default project that cannot be configured for limits or renamed. API keys are automatically created for new users and service accounts within the default project.

4. Later on, you reach the API page and select the "Create New Secret Key" option. Then, you can choose the type of OpenAI API key you want. You can select permissions, whether you want it to be restricted (read-only), and also the project for which you want the API key. You can also switch to a service account if you want to create your API key in a service account. However, you need to have a service account ID to create an API key in a service account.

How to get ChatGPT API Key

4. Based on your preferences, select the option. Then click on "Create Secret Key," and you will be done. Make sure to copy the ID to a folder on your computer if you frequently use your OpenAI API key. Otherwise, it will be a hassle to go through the OpenAI account every time you need to copy your OpenAI API key.

How to get ChatGPT API Key

Create a new project

If you want to create a new project, you can go to your organisation settings. You can locate the project you want to create an API key for and navigate to its settings. Alternatively, you can click on the default project option on your Open API key page, and you will get the option to create a new project. Give a name to your project, and your new project is done.

How to get ChatGPT API Key

Additional Considerations

  • Service Accounts: Organizations and project owners can create service accounts for programmatic access. These accounts have unique API keys managed separately from user accounts.

  • Project Limits: Organizations can set billing and usage limits at the organization level, which will cascade down to projects. Project owners can further restrict these limits within their projects.

Open AI API Keys Cost 

OpenAI offers a variety of powerful models accessible through API keys, but the cost can be confusing. Let's break down the key points to make it easier to understand.

How OpenAI Charges:

  • Per Token: OpenAI charges based on the number of tokens you use. A token is a unit roughly equivalent to a word. The cost depends on the model you choose and whether the tokens are for input (text you provide) or output (text generated by the model).

  • Batch API Discount: You can get a 50% discount by submitting requests in batches. This option takes longer (responses within 24 hours) but can be cost-effective for large projects.

Open AI GPT-4o Pricing

GPT-4o is a powerful model with strong vision capabilities. It is faster and cheaper than GPT-4 Turbo.

Model Version

Regular Pricing

Batch API Pricing (50% Off)

GPT-4o

$5.00 per 1M input tokens

$15.00 per 1M output tokens

$2.50 per 1M input tokens

$7.50 per 1M output tokens

GPT-4o-2024-05-13

$5.00 per 1M input tokens

$15.00 per 1M output tokens

$2.50 per 1M input tokens

$7.50 per 1M output tokens

Open AI GPT-3.5 Turbo Pricing:

GPT-3.5 Turbo is a fast and inexpensive model ideal for simple tasks and dialogue. It has two versions: the standard and the Instruction model.

Model Version

Regular Pricing

Batch API Pricing (50% Off)

GPT-3.5-turbo-0125

$0.50 per 1M input tokens

$1.50 per 1M output tokens

$0.25 per 1M input tokens<br>$0.75 per 1M output tokens

GPT-3.5-turbo-instruct

$1.50 per 1M input tokens

$2.00 per 1M output tokens

$0.75 per 1M input tokens

$1.00 per 1M output tokens

Open AI Embedding Models Pricing 

Embedding models help build search, clustering, topic modelling, and classification functionality.

Model Version

Regular Pricing

Batch API Pricing (50% Off)

text-embedding-3-small

$0.02 per 1M tokens

$0.01 per 1M tokens

text-embedding-3-large

$0.13 per 1M tokens

$0.07 per 1M tokens

ada v2

$0.10 per 1M tokens

$0.05 per 1M tokens

Open AI Fine-Tuning Models Pricing 

Fine-tuning allows you to create custom models with your training data. You only pay for the tokens used in requests to the fine-tuned model.

Model Version

Regular Pricing

Batch API Pricing (50% Off)

GPT-3.5-turbo

$3.00 per 1M input tokens

$6.00 per 1M output tokens

$8.00 per 1M training tokens

$1.50 per 1M input tokens

$3.00 per 1M output tokens

DaVinci-002

$12.00 per 1M input tokens

$12.00 per 1M output tokens

$6.00 per 1M training tokens

$6.00 per 1M input tokens

$6.00 per 1M output tokens

babbage-002

$1.60 per 1M input tokens

$1.60 per 1M output tokens

$0.40 per 1M training tokens

$0.80 per 1M input tokens

$0.80 per 1M output tokens

Open AI Assistants API Pricing 

The Assistants API helps developers build AI assistants into their applications. The pricing depends on the chosen language model.

Tool

Input

Code Interpreter

$0.03 per session

File Search

$0.10 per GB of vector storage per day (1 GB free)

Open AI Image Models Pricing: 

Image models like DALL·E generate and edit images and art. DALL·E 3 offers the highest quality, while DALL·E 2 is optimized for lower cost.

Model

Quality

Resolution

Price

DALL·E 3

Standard

1024×1024

$0.040 per image

DALL·E 3

Standard

1024×1792, 1792×1024

$0.080 per image

DALL·E 3

HD

1024×1024

$0.080 per image

DALL·E 3

HD

1024×1792, 1792×1024

$0.120 per image

DALL·E 2

-

1024×1024

$0.020 per image

DALL·E 2

-

512×512

$0.018 per image

DALL·E 2

-

256×256

$0.016 per image

Open AI Audio Models Pricing 

Audio models like Whisper transcribe speech into text and translate languages into English. Text-to-speech (TTS) converts text into spoken audio.

Model

Usage

Whisper

$0.006 per minute (rounded to the nearest second)

TTS

$15.00 per 1M characters

TTS HD

$30.00 per 1M characters

Open AI Older Models Pricing: 

OpenAI continues to support older models at discounted prices when using the Batch API. The prices for the older models are as follows. Also if you want to have a Batch API then you get a 50% off on the Open AI models. 

Model

Input Pricing

Output Pricing

GPT-4-turbo

$10.00 per 1M tokens

$30.00 per 1M tokens

gpt-4-turbo-2024-04-09

$10.00 per 1M tokens

$30.00 per 1M tokens

GPT-4

$30.00 per 1M tokens

$60.00 per 1M tokens

GPT-4-32k

$60.00 per 1M tokens

$120.00 per 1M tokens

GPT-4-0125-preview

$10.00 per 1M tokens

$30.00 per 1M tokens

GPT-4-1106-preview

$10.00 per 1M tokens

$30.00 per 1M tokens

GPT-4-vision-preview

$10.00 per 1M tokens

$30.00 per 1M tokens

GPT-3.5-turbo-1106

$1.00 per 1M tokens

$2.00 per 1M tokens

GPT-3.5-turbo-0613

$1.50 per 1M tokens

$2.00 per 1M tokens

gpt-3.5-turbo-16k-0613

$3.00 per 1M tokens

$4.00 per 1M tokens

GPT-3.5-turbo-0301

$1.50 per 1M tokens

$2.00 per 1M tokens

DaVinci-002

$2.00 per 1M tokens

$2.00 per 1M tokens

babbage-002

$0.40 per 1M tokens

$0.40 per 1M tokens

Open AI Usage Limits 

Rate limits control how often you can access OpenAI's services within a specific time frame. They help maintain the service's stability and ensure fair access for all users.

How Open AI Rate Limits Work

Rate limits are measured in various ways:

  • Requests Per Minute (RPM)

  • Requests Per Day (RPD)

  • Tokens Per Minute (TPM)

  • Tokens Per Day (TPD)

  • Images Per Minute (IPM)

These limits apply at both the organization and project levels. They vary depending on the model being used and the usage tier of your account.

Usage Tiers and Limits

As you use the OpenAI API more, your usage tier can increase, giving you higher limits. Here’s a breakdown of the different tiers:

Tier

Qualification

Usage Limit

Free

Allowed geography

$100 / month

Tier 1

$5 paid

$100 / month

Tier 2

$50 paid, 7+ days

$500 / month

Tier 3

$100 paid, 7+ days

$1,000 / month

Tier 4

$250 paid, 14+ days

$5,000 / month

Tier 5

$1,000 paid, 30+ days

$50,000 / month

Open AI Free Tier Rate Limits

Model

RPM

RPD

TPM

Batch Queue Limit

GPT-3.5-turbo

3

200

40,000

200,000

text-embedding-3-large

3,000

200

1,000,000

3,000,000

text-embedding-3-small

3,000

200

1,000,000

3,000,000

text-embedding-ada-002

3,000

200

1,000,000

3,000,000

whisper-1

3

200

-

-

tts-1

3

200

-

-

dall-e-2

5 mg/min

-

-

-

dall-e-3

1 mg/min

-

-

-

Open AI Tier 1 Rate Limits

Model

RPM

RPD

TPM

Batch Queue Limit

GPT-4o

500

-

30,000

90,000

gpt-4-turbo

500

-

30,000

90,000

GPT-4

500

10,000

10,000

100,000

GPT-3.5-turbo

3,500

10,000

60,000

200,000

text-embedding-3-large

3,000

-

1,000,000

3,000,000

text-embedding-3-small

3,000

-

1,000,000

3,000,000

text-embedding-ada-002

3,000

-

1,000,000

3,000,000

whisper-1

50

-

-

-

tts-1

50

-

-

-

dall-e-2

5 mg/min

-

-

-

dall-e-3

5 mg/min

-

-

-

Open AI Higher Tiers Usage Limits 

For higher tiers (2-5), the limits increase progressively. Here are some example limits for Tier 5

Model

RPM

TPM

Batch Queue Limit

Batch Queue Limit

GPT-4o

10,000

22,000,000

4,000,000,000

90,000

GPT-4-turbo

10,000

2,000,000

300,000,000

90,000

GPT-4

10,000

1,000,000

150,000,000

100,000

GPT-3.5-turbo

10,000

15,000,000

2,250,000,000

200,000

text-embedding-3-large

10,000

10,000,000

4,000,000,000

3,000,000

text-embedding-3-small

10,000

10,000,000

4,000,000,000

3,000,000

text-embedding-ada-002

10,000

10,000,000

4,000,000,000

3,000,000

whisper-1

500

-

-

-

tts-1

500

-

-

-

dall-e-2

500 mg/min

-

-

-

dall-e-3

200 mg/min

-

-

-

Viewing and Managing Rate Limits

You can check your rate limits in the headers of the HTTP response or the limits section of your account settings. Key header fields include:

  • x-ratelimit-limit-requests: Max requests allowed.

  • x-ratelimit-limit-tokens: Max tokens allowed.

  • x-ratelimit-remaining-requests: Remaining requests.

  • x-ratelimit-remaining-tokens: Remaining tokens.

  • x-ratelimit-reset-requests: Time until requests limit resets.

  • x-ratelimit-reset-tokens: Time until tokens limit resets.

By understanding and managing these limits, you can make the most of the OpenAI API while ensuring a stable and fair environment for all users.

Open AI API Keys Common Erros 

When working with OpenAI's API, you might encounter several errors related to API keys. These errors can be frustrating, but understanding their causes and solutions can help you quickly resolve them. Here's a simplified guide to common OpenAI API key errors and their solutions

Error Code

Error Message

Cause

Solution

401

Invalid Authentication

Invalid credentials used

Ensure the correct API key and organization ID are used

401

Incorrect API key provided

Wrong API key used

Check and correct the API key, clear the browser cache, or generate a new key

401

Must be a member of an organization to use the API

Account not part of an organization

Contact support to join or create an organization

403

Country, region, or territory not supported

Access from an unsupported location

Check location restrictions

429

Rate limit reached for requests

Too many requests in a short time

Pace your requests and follow rate limit guidelines

429

Exceeded current quota

Run out of credits or hit max monthly spend

Purchase more credits or upgrade your plan

500

Server error

Server issue

Retry after a brief wait; contact support if persistent

503

Engine overloaded

High traffic on servers

Retry after a brief wait

Python Library Error Types

Error Type

Cause

Solution

APIConnectionError

Issue connecting to services

Check network settings, proxy, SSL certificates, or firewall rules

APITimeoutError

Request timed out

Retry request after a brief wait, check network stability

AuthenticationError

Invalid, expired, or revoked API key or token

Verify and correct API key or token, generate a new one if needed

BadRequestError

A malformed request or missing parameters

Check error messages for specifics, validate parameters and format

ConflictError

Resource updated by another request

Retry updating the resource

internal server error

The issue on the server side

Retry the request after a brief wait, and check the status page for updates

NotFoundError

The requested resource does not exist

Ensure correct resource identifier is used

PermissionDeniedError

Lack of access to the requested resource

Verify API key, organization ID, and resource ID

RateLimitError

Hit the assigned rate limit

Slow down requests, follow rate limit guidelines

UnprocessableEntityError

Unable to process request

Retry the request