安装openai库
pip install openai
应用代码
from openai import OpenAI
client = OpenAI(api_key='key')
completion = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "你好!"},
{"role": "user", "content": "今天会下雨吗"}
]
)
print(completion.choices[0].message)