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
| Idea | Anthropic Messages API | OpenAI Responses API |
|---|---|---|
| System prompt | system | instructions |
| Conversation | messages array | input array of items |
| Call | client.messages.create | client.responses.create |
| Plain-text reply | text blocks in content | response.output_text |
| Tool definition | input_schema | parameters (with strict: true) |
| Tool request | tool_use block | function_call item |
| Tool result | tool_result block in a user message | function_call_output item |
| Done when | stop_reason is not tool_use | no function_call items in the output |
| Server-side history | none on the Messages API | optional (Conversations API) |
The tool loop is identical in shape: call, run the requested tools, send the results, repeat.
What you'll build
| Lesson | What it adds |
|---|---|
| Lesson 2: Basic chat | A multi-turn loop with the history kept in your code |
| Lesson 3: Chat with tools | The same tools, with reasoning items kept in the history |
| Lesson 4: Server-side conversation | The Conversations API, so OpenAI keeps the history |
| Lesson 5: Showing reasoning | Reasoning summaries printed next to each answer |
Create src/openai/config.ts:
export const model = "gpt-6-luna";
👉 Continue to Lesson 2: Basic chat