Module 2, Lesson 5: Showing Reasoning (OpenAI)
Request reasoning summaries from the Responses API and print them next to the answer.
Published: 11/23/2026
Lesson 5: Showing the model's reasoning
OpenAI doesn't expose raw reasoning either. It can return a summary, but only if you ask. This lesson adds that to lesson 4. The file is src/openai/basic-chat-with-tools-conversation-reasoning.ts, a copy of lesson 4's file. Everything not shown here is identical to lesson 4.
1. Ask for summaries
const chat = (input: ResponseInput): Promise<Response> => client.responses.create({ model, instructions: basicTravelSystemPrompt, conversation: conversation.id, input, tools, reasoning: { summary: "auto" }, });
reasoning.summary accepts "auto", "concise" or "detailed". Without it, no summary is returned.
You don't need include: ["reasoning.encrypted_content"] here. That was for the stateless version in lesson 3. In this version the Conversations API stores the items on OpenAI's side.
2. Collect the summary
Reasoning arrives as separate reasoning items in response.output, not inside the message.
const getReasoningSummary = (response: Response): string => response.output .flatMap((item) => item.type === "reasoning" ? item.summary.map((s) => s.text) : [], ) .filter(Boolean) .join("\n\n");
3. Print it every turn
const runTurn = async (input: ResponseInput): Promise<Response> => { while (true) { const response = await chat(input); const summary = getReasoningSummary(response); if (summary) console.log(`\n[reasoning summary] ${summary}\n`); const calls = response.output.filter( (item): item is ResponseFunctionToolCall => item.type === "function_call", ); if (calls.length === 0) return response; input = await runTools(calls); } };
As with Anthropic, the summary is printed after every response, including tool-call turns.
Anthropic and OpenAI side by side
| Anthropic | OpenAI | |
|---|---|---|
| Where reasoning appears | thinking blocks inside message.content | Separate reasoning items in response.output |
| How to opt in | display: "summarized" | reasoning.summary |
| Default on the newest models | Omitted (empty text) | No summary unless requested |
Try it
Run the file and watch the [reasoning summary] lines appear between the [tool] lines.
👉 Continue to Module 3: Guardrails