Dev ❤ Ops

How to use ChatGPT API

How to use ChatGPT API

We all are waiting to know how to use ChatGPT API but until it is publicly available to use we can use GPT API to connect AI and get automated API responses based on the “DaVinci” engine. GPT3 is the actual technology behind the CHAT GPT so let’s see how to use GPT API.

Check out our new article for How to access New ChatGPT and Whisper API

Step 1: Log into the OpenAI account

To access the GPT API, you will need to create an OpenAI account and apply for access to the API.

Sign up or Sign in to the OpenAI website.

How to use ChatGPT API

Step 2: Obtain GPT API Key

At the right top corner of the page click on view API keys.

How to use ChatGPT API

Click on “Create an API Key” to get GPT API key.

How to use ChatGPT API

Step 3: Download Required libraries

Download open API python library required for the code, instead of python any other coding language also works fine with GPT APIs.

pip install openai

Step 4: Create code to use GPT API

Following is the example python code which can be executed from anywhere, in this case, we are running it from a Linux terminal.

vi heyGPT
#!/usr/bin/env python3
#Import  Modules
import openai,os,sys
prompt = sys.argv[1]
openai.api_key = os.environ['api_key']
completions = openai.Completion.create(
# davinci-003 , davinci-002 also can be used.
message = completions.choices[0].text
chmod +x heyGPT

Start Using GPT and get amazed by the response

How to use ChatGPT API

Above is an example of how to access GPT-3 API and perform some operations to get useful results but there are numerous opportunities to build applications around it. Currently, CHAT-GPT APIs are not available to the general public but can be requested from ChatGPT API request Form.

Check out our new article for How to access New ChatGPT and Whisper API

This article is created based on experience but If you discover any corrections or enhancements, please write a comment in the comment section or email us at You can also reach out to us from Contact-Us Page.

Follow us on LinkedIn for updates!

Leave a comment

Your email address will not be published. Required fields are marked *