Simple steps to connect chatGPT using openAPI key for python


Assuming you have python in VScode running.

1. Install openAPI

> pip install openai

2. Get you openAPI key from personal > View API Key and create a new API Key 


3. use it in test.py file as follows.

secret = 'sk-21QbkZp4qgPHxkgsdscOsyBT3BlbkFJBQp85bgeYsi6JxxFItVP'
query = 'who is vinod kotiya'
import openai
openai.api_key = secret

response = openai.Completion.create(
  model="text-davinci-003",
  prompt=query,
  temperature=0.7,
  max_tokens=256,
  top_p=1,
  frequency_penalty=0,
  presence_penalty=0
)
print(response)        

Comments