Module 2, Lesson 1: Chat with OpenAI

The OpenAI Responses API compared with Anthropic's Messages API, and what this module builds.

Published: 11/22/2026

Welcome to Module 2

You've built the chatbot with Anthropic. Now you build the same chatbot with OpenAI, using the openai package and the Responses API, so you can see what changes and what doesn't.

The model ID used in this module is gpt-6-luna.

Anthropic versus OpenAI

IdeaAnthropic Messages APIOpenAI Responses API
System promptsysteminstructions
Conversationmessages arrayinput array of items
Callclient.messages.createclient.responses.create
Plain-text replytext blocks in contentresponse.output_text
Tool definitioninput_schemaparameters (with strict: true)
Tool requesttool_use blockfunction_call item
Tool resulttool_result block in a user messagefunction_call_output item
Done whenstop_reason is not tool_useno function_call items in the output
Server-side historynone on the Messages APIoptional (Conversations API)

The tool loop is identical in shape: call, run the requested tools, send the results, repeat.

What you'll build

LessonWhat it adds
Lesson 2: Basic chatA multi-turn loop with the history kept in your code
Lesson 3: Chat with toolsThe same tools, with reasoning items kept in the history
Lesson 4: Server-side conversationThe Conversations API, so OpenAI keeps the history
Lesson 5: Showing reasoningReasoning summaries printed next to each answer

Create src/openai/config.ts:

export const model = "gpt-6-luna";

👉 Continue to Lesson 2: Basic chat