Skip to main content

Add an optional reasoning panel to a chat reply

Section: DOC-MA-model-controls-reasoning#show-reasoning-alongside-replies.

If you are building a chat interface, you can show a model's returned reasoning text in a separate, optional panel beside its answer. Your app should still work when the model returns only an answer. Reasoning text can help a reader understand the response, but it is not a complete record of the model's internal reasoning or proof that the answer is correct.

Use the small order-total question below to build the display: the answer belongs in the chat bubble and any returned reasoning belongs in a separate collapsed panel. You need an authenticated thread, a supporting model and the normal send/result loop. The panel is optional; the application must finish a reply when no reasoning is returned.

Step 1: request the answer and optional reasoning​

Section: DOC-MA-model-controls-reasoning#request-reasoning.

Start with a conversation configured to use a model that supports reasoning controls. In a send-message request, use overrideGenerationConfig.reasoning to request reasoning for that turn. This example asks for medium effort and allows reasoning text in the response:

{
"conversationKey": "your_conversation_id",
"userMessage": {
"role": "ROLE_USER",
"content": [
{ "type": "CONTENT_PART_TYPE_TEXT", "content": "Two items cost $15 each and shipping is $5. What is the total?" }
]
},
"overrideGenerationConfig": {
"reasoning": {
"effort": "EFFORT_MEDIUM",
"exclude": false
}
}
}

Request example: Send a message to a conversation · Request fields.

Replace your_conversation_id with your conversation's ID. See send and receive a reply for authentication, the HTTP request and retrieving the result. Wait for the current turn to settle before sending this example: per-turn overrides are not retained for queued messages.

Step 2: render by content type, not array position​

Section: DOC-MA-model-controls-reasoning#display-answer-and-reasoning.

An assistant message can contain both reasoning and answer text. For example, this message excerpt includes both kinds of content:

{
"content": [
{
"type": "CONTENT_PART_TYPE_REASONING",
"content": "I will add the price of both items, then include shipping."
},
{
"type": "CONTENT_PART_TYPE_TEXT",
"content": "The total is $35."
}
]
}

Message excerpt: Message fields.

For a text chat, display CONTENT_PART_TYPE_TEXT parts as the assistant's reply. Put nonempty CONTENT_PART_TYPE_REASONING parts in a separate panel labeled Reasoning, collapsed by default. If there are several parts of the same type, retain their order. If no reasoning text is returned, omit the panel and show the reply normally.

Use each part's type rather than assuming the first part is the answer. Display its content as text, or with your app's safe Markdown renderer; metadata is not display copy. Other content types, such as images, need their own renderer.

Check the display with both outcomes: reasoning plus answer, and answer only. For the controlled question above, the stated prices total $35; compare the answer with that known result rather than treating the presence of reasoning as evidence of correctness.

Step 3: finish the turn and continue with a follow-up​

Section: DOC-MA-model-controls-reasoning#continue-conversation.

Receiving reasoning text does not mean the reply is complete. Keep the runId returned by send-message and follow the polling recipe before marking that turn finished. This guide describes reading conversation state; see streaming availability before building a live token display.

For a follow-up such as “What if I buy three?”, send a new userMessage with the same conversationKey. Travila builds the model's context from the stored conversation and its configured history settings. Your app does not need to reconstruct provider messages or copy the reasoning panel into the next user message. See conversation context for controlling which history is included.

Finished result: the chat shows the completed answer normally, offers the reasoning panel only when nonempty reasoning was returned, and sends the follow-up in the same thread. An interrupted or failed run remains visibly unresolved or unsuccessful even if reasoning text already arrived.

Document ID: DOC-MA-model-controls-reasoning. Section identities and revisions.