OpenAI, a leading artificial intelligence company, offers API keys for developers to interact with its platform and use its LLM models in various projects. In this article, you will learn how to create your own OpenAI API key, updated as of 2024.
The easiest and most recommended way to generate your API key is through the OpenAI developer platform, where you can manage your projects (in OpenAI, a “project” is an environment where developers can organize their ai applications, APIs and resources associated).
Note: This article assumes you are new to creating API keys in OpenAI.
Steps to create an API key
Visit the OpenAI platform: Gonna https://plataforma.openai.com and log in or register.
If you register, you will be asked to provide the name and date of birth of your organization. You can enter anything for the organization name, but keep in mind that this will be the name of your account. Choose something your team recognizes.
After you have provided your organization name and date of birth, you will be redirected to the following interface:
Create a project
In the upper left corner, click “Default Project” and select “Create Project.”
Name your project. If you only need multiple API keys for a single project, create a project and manage all the keys in it. Create separate projects when you need different environments, access control, or billing settings.
After creating a project, select it in the upper left corner.
Verify your phone number (for new users)
For new users, phone verification is required before creating an API key. Navigate to API Keys on the Dashboard tab.
Click Start Verification. Enter your phone number, then enter the code you receive.
Create the API key
After verification, navigate to API Keys in the Control Panel. Click “Create new secret key”.
Give the key a name to make it easier to manage (optional but recommended). Select the project where the key will be stored. Adjust permissions as necessary.
There are two types of keys you can create:
- Personal API key: This is a personal API key linked to your OpenAI account and becomes invalid if the user account is deleted.
- Service account key: This API key is created for automated systems or applications and remains valid even if the associated user account is deleted.
Consult the official documentation for better understanding.
Once you click “Create secret key”, the key will be displayed
Important: Save the key immediately because you will not be able to view it again. If you lose it, you will have to generate a new one.
Congratulations!
You've generated your first API key, but wait. You can't use this key in your project yet, as you need to put some balance in your account first, because you know very well that this is a fee-based service and some money is needed in the account for it to work.
Add credits to your account
Navigate to Billing section in Settings, and you will be able to see the remaining credit in your account.
Click “Add payment details” and enter your credit/debit card details.
Click Continue and then you can set up your payment. Choose how much credit you want to purchase ($5 to $100). You can also set up automatic recharges and set a threshold for when to automatically recharge and how much.
Click Continue and then a final invoice will be generated and you will be asked to make payment. Once the payment is successful, the balance will reflect in your account.
You are now ready to use the API key in your projects. Usage costs will be deducted from your balance and you can top up as needed.
Set cost limits for organization or projects (optional)
OpenAI allows you to set cost limits at the organization or project level. This helps you control your budget and avoid unexpected charges. You can also choose which Project-level models can be accessed with APIs.
Gonna Organization Boundaries in Settings to view the rate limits for your organization. API usage is subject to rate limits applied to tokens per minute (TPM), requests per minute or day (RPM/RPD), and other model-specific limits.
By default, your organization will be at usage level 1, but as your usage increases, you will be upgraded to higher levels with higher limits.
Scroll to the bottom of the page and you will have the option to set a monthly limit and also an email notification threshold.
If you want to set limits at the project level, navigate to the bottom of the Settings panel, under Project, and there you can set the monthly budget and notification threshold, and you can also allow or block models and change rate limits. (TPM/RPM). Rate limits are inherited from the organization unless overridden at the project level.
Points to remember
- Cost limits for API keys: You cannot set individual cost limits for specific API keys. Instead, cost limits are applied at the project level. All API keys associated with that project will share the limits set for the project, ensuring that the entire project stays within the defined budget.
- Project file and API keys: Projects cannot be deleted in OpenAI, but they can be archived. Once a project is archived, all associated API keys are no longer available and cannot be used. There is currently no feature to directly delete API keys, only to archive the project they belong to, which disables the keys.
Conclusion
Creating your OpenAI API key is a simple process that opens the door to leveraging powerful ai models for your projects. By following the steps outlined, you can easily manage your projects, set budget limits, and ensure your API key is generated and used securely. Whether you're developing a personal project or working within an organization, understanding how to navigate the OpenAI developer platform will improve your experience and help you effectively integrate ai into your applications.
If you want to know more about the model and pricing, you can explore the links given below:
Using the links above, you can estimate the cost of using different models and adjust your strategy accordingly.
I hope this guide helps you generate and manage your OpenAI API key efficiently.
Frequently asked questions
A. An OpenAI API key is a unique identifier that allows developers to access and interact with OpenAI language models and other ai services. It is essential for authentication and usage tracking.
A. Yes, new users must verify their phone number before they can create an API key. This step helps improve account security.
A. Yes, you can create multiple API keys in different projects to manage access and permissions according to your needs.
A. If you lose your API key, you will need to generate a new one, as the original key cannot be recovered once created.
A. To add credits, navigate to the Billing section in your account settings, enter your payment details, choose the amount of credit you would like to purchase, and complete the transaction.