import openai
# 设置OpenAI API键
openai.api_key = "YOUR_OPENAI_API_KEY"
# 定义模型和提示
model_engine = "o1"
prompt = "Hello, who are you?"
# 调用completions端点生成文本
response = openai.Completion.create(
engine=model_engine,
prompt=prompt,
max_tokens=10,
n=1,
stop=None,
temperature=0.5,
)
# 打印生成的文本
print(response.choices[0].text)