PuppyCoding

Friendly Python & AI tutorials for beginner & intermediate programmers.


Unofficial Guide to OpenAI API Keys

Picture of several happy monsters, each holding a big key.

( Jump to video ⇩)

I’ve seen a lot of confusion and questions about how to get an OpenAI API key and any restrictions, so hopefully this FAQ will clear a few things up.

  1. How can I get an OpenAI API key?
  2. Do I need an API key to use ChatGPT?
  3. How much is an API key? Can I get one for free?
  4. Do I need a ChatGPT Plus subscription to use the OpenAI API?
  5. If I get an API key, can I use GPT-4?
  6. I’m paying for ChatGPT Plus. Can I use GPT-4 in the API?
  7. Do I need to have a credit card to get an API key?
  8. How many API keys can I have?
  9. How can I set a spending limit for my account?
  10. Will OpenAI tell me if I get close to my spending limit?
  11. Can I set a spending limit per API key?
  12. How can I see how many credits I’ve used?
  13. I’m using the API but I get a 429 error. What’s that?
  14. It says my credits expired or I exceeded my quota, but I only just started using the API.
  15. When using the API, do you get charged for the prompt as well as the response?
  16. Do API keys expire?
  17. Can I get more free credits by creating a second account?

How can I get an OpenAI API key?

To get an OpenAI API key, first create an OpenAI account, then click on your profile image in the top right corner, and go to View API keys. From there you can create (and delete) API keys.

Do I need an API key to use ChatGPT?

No, you can use ChatGPT online at chat.openai.com without an API key. You only need an API key if you’re a developer and you want to use OpenAI’s services (e.g. GPT, DALL-E, Whisper) within any programs you develop.

How much is an API key? Can I get one for free?

API keys are free, but you use up credits each time you use them. When you first open an OpenAI account you get $5 of credits, valid for 3 months from the time you open the account.

Source: openai.com/pricing

Do I need a ChatGPT Plus subscription to use the OpenAI API?

No, ChatGPT Plus and the OpenAI API are separate things. You can create and use API keys without a ChatGPT Plus subscription.

Source: openai.com/pricing

If I get an API key, can I use GPT-4?

Not necessarily. The gpt-4 model is only for developers with a paid account, i.e. a credit card registered with your OpenAI account that has been billed at least once. If you haven’t added billing information to your OpenAI account, you can use the gpt-3.5-turbo model.

Source: openai.com/blog/gpt-4-api-general-availability

I’m paying for ChatGPT Plus. Can I use GPT-4 in the API?

No, ChatGPT Plus (the monthly subscription) is unrelated to API key usage. You need to have billing information (credit card) registered in your OpenAI account and to have been charged at least once for API usage.

Source: openai.com/blog/gpt-4-api-general-availability

Do I need to have a credit card to get an API key?

Not at first. You don’t need to enter any billing information to create API keys during the trial period. When the 3 month trial period has finished, or you use up the $5 free credits, you will then have to enter billing information. to continue using the OpenAI API.

Source: help.openai.com/en/articles/4936830-what-happens-after-i-use-my-free-tokens-or-the-3-months-is-up-in-the-free-trial

How many API keys can I have?

Up to 25. You can now give them individual names too, which is useful if you’re developing multiple apps.

Source: community.openai.com/t/named-api-keys-and-new-api-key-limit/157935

How can I set a spending limit for my account?

Go to Manage Account -> Billing -> Usage Limits to set both a soft limit (to just get a notification) and a hard limit (complete stop). Note that OpenAI automatically sets a spending limit on each account anyway.

Will OpenAI tell me if I get close to my spending limit?

Yes, you can set a “soft limit” in your Usage Limits page. When you hit that limit, you’ll get a notification email.

Can I set a spending limit per API key?

No, you can only set a spending limit for the account as a whole. To do so, go to Manage Account -> Billing -> Usage Limits

How can I see how many credits I’ve used?

In your OpenAI account, go to Manage Account -> Usage. You can check your daily and monthly credit usage.

I’m using the API but I get a 429 error. What’s that?

openai.error.RateLimitError: You exceeded your current quota, please check your plan and billing details.

This means you have no more credits or you’ve hit the spending limit for your account. Try one of the following things:

  • If you were on a free trial, add billing information (a credit card) to your account.
  • If you’ve hit your spending limit, either increase the limit or wait until it resets next month.

It says my credits expired or I exceeded my quota, but I only just started using the API.

Here are some things to check:

  • Did you open the account over 3 months ago? If so, your credits have expired, even if you’ve never used the API.
  • Did you open the account using a phone number linked to an existing account? If so, the new account does not get any credits.

If you still think you should have credits, it’s best to search or ask in the OpenAI community forums.

When using the API, do you get charged for the prompt as well as the response?

Yes. You get charged for the total number of tokens in the prompt (input) and the response (output). 1,000 tokens is roughly equal to 750 words.

Source: openai.com/pricing

Do API keys expire?

Keys do not expire unless you delete them. However, your keys may stop working in one of these situations:

  • You’re on a free trial and use up your credits (currently $5).
  • You’re on a free trial and it expires (currently 3 months).
  • You hit the usage limit for your account.

Can I get more free credits by creating a second account?

Each account is associated with a phone number. If you create a second account with the same phone number, you will not get any free credits. If you create a second account with a different phone number, you will get free credits.

Source: community.openai.com/t/how-can-i-get-free-trial-credits/26742/27


Hopefully that’s helped with your OpenAI API key questions. If you still have problems, I recommend asking on the OpenAI community forums.



2 responses to “Unofficial Guide to OpenAI API Keys”

Leave a comment