Skip to main content

Why does a chat model's API reply include its thinking, and how do I get only the answer?

For reasoning models, debugoutput joins the thinking and the answer, so read the answer from the structured output instead.

For reasoning models run through the Run API, debugoutput and outputs[0].content.raw join the model's thinking and its answer into one text, with no separator between them. For the answer alone, read the structured content instead:

  • outputs[0].content.answer is a list of the answer's text parts. Join them.

  • Or, in outputs[0].content.segments, keep the items whose type is "answer", in order. Items of type "thinking" hold the reasoning.

  • On the WebSocket, the final task_postprocess_end message has the same answer and segments in message[0].content. While a reply streams, replace your copy on every update instead of appending (see streaming a reply).

The LLM Gateway keeps reasoning apart from the reply: in Chat Completions it can appear in message.reasoning. More: How do I get the result of an API request? and thinking and answer segments in our docs.

Did this answer your question?