使用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)

使用Python调用ChatGPT_第1张图片

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

你可能感兴趣的:(AI)