step 1:

pip install openai

step 2:

import openai
# Set your API key
openai.api_key = "your api key"

completion = openai.Completion.create(
# text-davinci-003   text-davinci-002
    engine="text-davinci-003",
    prompt='使用python实现冒泡排序算法',
    max_tokens=2048,
    temperature=0.1
)
# get response
print(completion.choices[0].text)

开发了一个基于chatgpt的聊天小网站,可以问题代码,报告,文书设计,唠嗑等,欢迎访问试玩:http://user-chat.top/

更多推荐

python 如何调用chatgpt模型