开始使用免费开始使用

从一条消息到另一条消息

现在请您开始将多次响应串联起来,在请求之间保留上下文!这实际上是在创建对话历史——这是对话的重要组成部分。

本练习是课程的一部分

使用 OpenAI Responses API

查看课程

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Create the first request
response1 = client.____.____(
    model="gpt-5.4-mini",
    ____="Draft a short LinkedIn post announcing that I'm learning about the OpenAI Responses API to upskill in AI engineering on DataCamp!",
    reasoning={"effort": "none"}
)

# Extract the ID from response1
conversation_id = ____
print("Initial post:", response1.output_text)
编辑并运行代码