How to get your own API Key for using OpenAI ChatGPT

TfTHacker
6 min readApr 21, 2023

--

In this article, I will document the process for requesting an API key for using OpenAI’s artificial intelligence services. This is for things like ChatGPT, gpt-3.5, gpt-4, whisper, and DALL-E.

Why do you need an API key? Many programs these days that perform artificial intelligence tasks require an API Key. For many of us, especially those who are not software developers, this is something we have never done before and can seem so intimidating. But it isn't!

This article is split up into four sections:

  • What is an API?
  • Why do I need an API key?
  • How do you get your API Key from OpenAI?
  • If I subscribe to ChatGPT plus, do I still have to pay for access to the OpenAI API?

Feel free to skip to the “How do you get your API Key from OpenAI?” section if you already know the answer to the two other questions. However, if you are not familiar with the term API, a little education will be helpful to you in the future.

Please note, full disclosure, I used AI tools to assist in the writing of this article. (Grammarly, gpt-4, and Whisper).

What is an API?

API stands for Application Programming Interface. It is a set of rules, protocols, and tools that allows different software applications to communicate with each other.

In simpler terms, an API acts as a bridge between two software programs, enabling them to exchange data and interact with each other.

Developers use APIs to access the functionality or data provided by another software system without having to build that functionality from scratch. APIs are widely used in the technology world to simplify the development process and create a seamless integration between different software components.

For example, when you use a mobile app to check the weather, the app might use an API to request weather data from a weather service provider. The API enables the app to communicate with the weather service, request the necessary information, and display it to you in a user-friendly format.

Why do I need an API key?

Many tools have in recent times added support for artificial intelligence. Let us use Obsidian as an example.

Obsidian by itself does not know how to talk to OpenAI’s artificial intelligence API.

So we need to use plugins that know how “bridge” the gap between Obsidian and OpenAI services.

OpenAI is a business and thus charges money for using its services. So the API key gives you not only access to their services but also methods for paying for those services.

Without an API key, you will not be able to use most of the artificial intelligence plugins inside Obsidian.

There is one other benefit to having your own API key. It makes it much easier for you to control your expenses when using artificial intelligence in AI applications for that matter, and it also gives you control over who can use the services you are paying for.

Personally, I have seen that using the OpenAI API directly is cheaper than using other add-on services from companies that have AI products.

The cost savings can be significant and makes it worth the time of getting your own API key.

Help support all your favorite writers using my referral link: https://bit.ly/o42-medium or buy me a coffee at: https://bit.ly/o42-kofi. Your support is appreciated!

How do you get your API Key from OpenAI?

This is actually very easy to do. We can simplify it in two steps:

  • Requesting access to openAI’s API service
  • Creating an API Key

Requesting access to OpenAI’s API service

  1. Go to OpenAI’s developer site at: https://platform.openai.com/overview
  2. Click on Sign up and create your account (it is free).
  3. They will ask for some basic information about you:

4. Verify your phone number

That is it! You are in. This will give you API access to gpt3.5 and other OpenAI services.

GPT-4: If you want access to the gpt-4 API, at the time of the writing of this article, you need to go a step further and apply for access to gpt-4 API, which can be done at this link.

Creating an API Key

Now that you have a registered account, you can create an API key. To do that, at the openAI developer site https://platform.openai.com/, click on your profile icon and select View API keys.

View your API keys for openAI

This opens the API Keys page. Click on the + Create new secret key button.

Create new secret key button

You are then prompted for the name of the key.

Name the new secret key

First, why is it a secret key? This is a key to the API. The key is like a key to the door of your home. You don’t give that key just to anyone, rather you give it to those you trust like family members or close friends.

In a similar way, you don’t want to give just anyone access to your API keys, because they are tied to your billing account. You give keys to those you work with and trust.

Second, you name the key because you will likely create multiple keys and even delete keys in the future. This gives you a way to manage your keys:

  • For what purpose was it created
  • When was it created
  • Deleting them

After naming your key, you will receive this message:

Key generated

The generated key looks something like this:

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

All the OpenAI keys begin with sk- as the first three characters of the key Make sure to copy that key and put it somewhere safe.

After that, you are brought back to the API keys page where you see all your keys. Here I have registered tow more keys:

API Keys manager at OpenAI

FYI: the sample keys I have shown here of course have been deleted and are no longer valid 🤓.

If I subscribe to ChatGPT Plus, do I still have to pay for access to the OpenAI API?

This is a question many have asked. OpenAI offers a service called ChatGPT Plus. This is a version of ChatGPT that has some additional features for $20 USD a month.

It would make sense that having this subscription would also give you API access, but sadly it doesn’t work that way.

If you subscribe to ChatGPT Plus and want access to the OpenAI API with your own API key, those are separate services and we pay for each of them that we use.

Final Note

Also, when you create an account, OpenAI gives you free credit to experiment with the API, however in time you will need to set up a payment method to pay for API access.

It isn’t free, but it is not expensive to use for the average needs of an individual. Even if you use it heavily, it is cheaper than other services. For example, I use it daily and probably spend one to two dollars a week, and that is if I have been intensely using it.

You now have your OpenAI API key in hand and can use this key with a variety of programs designed to work with the OpenAI API.

Again, make sure to safeguard these keys in a secure place.

If you run into problems, DM me on Twitter and I will be happy to help you out.

Help support all your favorite writers using my referral link: https://bit.ly/o42-medium or buy me a coffee at: https://bit.ly/o42-kofi. Your support is appreciated!

--

--

TfTHacker

Exploring Tools for Thought with a focus on Obsidian & popular TfT Tools. Find out more about my work at https://tfthacker.com