使用Python调用ChatGPT

import openai

# Set up the OpenAI API client

openai.api_key = "你的KEY"

# Set up the model and prompt

model_engine = "ada"

prompt = input('请输入字符串:')

# Generate a response

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)

ChatGPT国内体验网址 https://1bit.asia

猜你喜欢

转载自blog.csdn.net/liuhenghui5201/article/details/129019322