openai

import openai

openai.api_key = "your secret api key"

while True:

    model_engine = "text-davinci-003"

    prompt = input('Enter new prompt: ')

    if 'exit' in prompt or 'quit' in prompt:

        break

    completion = openai.Completion.create(

        engine=model_engine,

        prompt=prompt,

        max_tokens=1024,

        n=1,

        stop=None,

        temperature=0.5,

    )

    response = completion.choices[0].text

    print(response)


To get secret api key  go to   openai.com/api/ and signup

then login and go to  platform.openai.com/ 

click on personal and then click on vie api keys and now click on 'create new secret key'.

No comments: