Get Started with the OpenAI API

Learn how to sign up for an OpenAI account and retrieve the API key of the OpenAI API.

We need to complete a few steps before we can start using the OpenAI API.

Sign up

Visit the registration link and perform the following steps:

  • Enter a valid “Email address,” create a “Password,” and click the “Continue” button.
  • You will receive a verification email in your provided email address inbox. Open the received email and click the “Verify email address” link. It will open a new tab.
  • In the new tab, fill in the details under the heading “Tell us about you” and click “Continue.”
  • Next, enter a valid “phone number” and click “Send code.”
  • You will then receive a code on the “Phone number” given in the previous step. Enter the 6-digit code that you receive. Once that has been verified, you’ll be directed to the next page.
  • Lastly, choose your use case.

You’ll be redirected to the welcome page once the account is created.

Fetch the API Key

  • Visit this page and click your profile at the top right corner. From the drop-down menu, select the “Manage account” option.
  • Now, click the “Usage” option from the sidebar. It will open the usage history of the API. Note you have been credited an $18 grant.
  • You’ll see your secret key under the “SECRET KEY” section. Copy it and paste it somewhere safe. If you wish to make a new key, you can do it by selecting the “Create new secret key" button.

Save the API Key

Let’s save the API Key to use throughout the course.

Follow the instructions below:

  1. Click the “Edit” button in the following widget.
  2. Enter your secret key in the SECRET_KEY field.
  3. Click the “Save” button.

Once the SECRET_KEY is saved, it can be used throughout the course. Press the “Run” button to print a list of engines available.

import openai
openai.api_key = "{{SECRET_KEY}}"
try:
print(openai.Model.list())
except Exception as e:
print(f"Error: {e}")