python code to talk with chatGPT

Python code to talk with ChatGPT

Hello Everyone, now anyone can talk with ChatGPT. It’s free for some period.
You have to download your API key from https://openai.com/api/ website and then you can start chatting with ChatGPT with the code given below.

import os
import openai

#openai.api_key = os.getenv("OPENAI_API_KEY")
openai.api_key = 'paste here your API Code'
while True:
        ask = input('Your Question: ')
        response = openai.Completion.create(
                model="text-davinci-003",
                prompt=ask,
                temperature=0.9,
                max_tokens=150,
                top_p=1,
                frequency_penalty=0,
                presence_penalty=0.6,
                stop=[" Human:", " AI:"]
        )
        print(response)
        text = response['choices'][0]['text']
        print ('Reply: '+text)

CHECK OUR BLOG FOR API KEY CREATION – CLICK HERE

MtroView team is giving its best & working hard to provide the content to help you understand things better in simple terms. We are heartily open to receiving suggestions to improve our content to help more people in society. Please write to us in the form of a comment or can also send an email to mtroview@gmail.com

1 thought on “Python code to talk with ChatGPT”

  1. Pingback: How to get API key for ChatGPT? - MtroView

Leave a Comment

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