AI API Key Essentials Part 1 : How to Set Up Your OpenAI API Key: A Quick Beginner Guide

Alozie Igbokwe
4 min readMay 30, 2024

--

If you’re looking to build AI tools leveraging openai api, the first step is setting up your API key. This guide will walk you through the process.

Step 1: Log In to Your OpenAI Account

  1. Visit OpenAI Platform.
Openai Platform Home Page
  1. Click on the Log In button at the top right corner. If you don’t have an account, click Sign Up.

Step 2: Access the Dashboard

  1. After logging in, click on the Dashboard text at the top right-hand side.
Dashboard Page

Step 3: Navigate to the API Key Section

  1. On the Dashboard, locate and click on the API Key text on the left-hand side. It’s the last option in the column.
API Key Page

Step 4: Create a New Secret Key

  1. Click Create a new secret key.
  2. Set your parameters for the API key:
  • Name: Assign a name to your key.
  • Project: Use the default value or specify a project.
  • Permissions: Use the default settings unless you have specific needs.

3. Once created, copy the key and store it securely. Note that you cannot view the key value again, so keep it safe. If you lose it, you’ll need to create a new one and delete the old one.

API Key Creation Pop up Screen

Step 5: Set Up Billing

  1. OpenAI provides a $5 free credit when you first set up your account. However, to access newer models like GPT-4 and to be allowed api usage after your credits run out you’ll need to switch to a pay as you go subscription plan for api usage.
  2. Go to Settings in the top right corner with the gear icon.
  3. Click on Billing on the left-hand side (third option under Organization).
Settings Page

4. Click on Add Payment Details and enter your account information.

Payment Plan Page

5. Add at least $5 credit to your account. It’s advisable to disable automatic recharge to control your expenses better. Leave other values blank and click Continue.

Configure Payment Pop Up Page

Step 6: Monitor Your Usage

  1. Tracking and predicting your exact API usage cost can be complex and will have to be talked about about in another write up, but here’s a basic method to to least monitor your cost.
  2. Go back to the Dashboard page and click on Usage.
Usage is second to last on the left hand side

3. Here, you can track your API cost and usage.

Here you can track the cost of usage per a model
Here you can track api request and token usage which will affect your cost. Tokens are the most important thing to look at here though as they are a direct factor

Step 7: Save on Costs

  1. For cost efficiency, especially during testing, use GPT-3.5-turbo when you can as it is much cheaper than GPT-4.
  2. Test on the ChatGPT interface either through the regular ChatGPT UI or the Custom GPT Playground before using the api directly
Regular ChatUI. Very limited on what you can test since it doesn’t have retrieval or function capabilities but has a couple features you can use for testing(will need paid 20 dollar chatgpt plan to use some of these features)
Can read and give responses based on file you feed it. This can work for testing retrieval without using api
if you go to Settings(can access by clicking your profile icon on the top right side) and click on personalization you can give Chatgpt Custom instructions this can be good for for testing your prompting without using the api.
You can use browsing , Dall-E and Code interpreters functionality in Chat UI also. So you can test these features in ChatUI also
You can also test GPT vision or Image reading fucntionlites using ChatGPT4o
Can also test in the GPT playground by clicking Explore GPTs then CreateGPTs. This will allow you to test the retrieval, code interpreter and function capabilities without having to use the api

By following these steps, you’ll have your OpenAI API key set up and be ready to integrate AI capabilities into your projects. Remember to monitor your usage and manage your billing settings to optimize costs and to keep your api key safe and secure.

Additional Resources:

This is a follow up to common ask questions to the Begineer Guides I wrote before

--

--

Alozie Igbokwe

I write articles on AI Agents. Here is my YT Channel if you want to see walkthroughs on AI Agents you can build for your business -https://shorturl.at/5s1tN