Skip to main content
For thinking/reasoning models, Fireworks provides access to the model’s reasoning process through the reasoning_content field. This field contains the model’s internal reasoning, which would otherwise appear in <think></think> tags within the content field. For some models, the reasoning content may instead be included directly in the content field itself.

Prerequisites

We recommend using the Fireworks Python SDK to work with reasoning, as it supports Fireworks-specific parameters and response fields.
The SDK is currently in alpha. Use the --pre flag when installing to get the latest version.

Basic usage

Select a reasoning model from our serverless model library.

Controlling reasoning effort

You can control the reasoning token length using either the reasoning_effort parameter or the Anthropic-compatible thinking parameter.

Using reasoning_effort

The reasoning_effort parameter accepts string values like "low", "medium", or "high":
See the reasoning_effort parameter for more details.

Using thinking (Anthropic-compatible)

Alternatively, you can use the thinking parameter, which provides an Anthropic-compatible format for controlling reasoning behavior:
See the thinking parameter for more details.
You cannot specify both thinking and reasoning_effort in the same request. If both are provided, a validation error will be raised.

Streaming with reasoning content

When streaming, the reasoning content is available in each chunk’s delta:

Interleaved thinking

When building multi-turn tool-calling agents with models that support interleaved thinking, you MUST include the reasoning_content from previous assistant turns in subsequent requests. This enables the model to think between tool calls and after receiving tool results, allowing for more complex, step-by-step reasoning.
Diagram showing interleaved thinking where reasoning is preserved within Turn 1 across multiple steps but starts fresh in Turn 2

Interleaved thinking: the model reasons between tool calls within a single turn. Source: Z.AI

You can preserve reasoning context in two ways:
  1. Pass the Message object directly (recommended) - The SDK message object already contains the reasoning_content field alongside content and tool_calls
  2. Manually include reasoning_content - When constructing messages as dictionaries, explicitly add the reasoning_content field
Interleaved thinking is triggered when the last message in your API request has "role": "tool", enabling the model to use its previous reasoning process when responding to the tool result. If a model does not support interleaved thinking, it simply ignores the extra reasoning context so this pattern is safe to use broadly.
Here’s how to preserve reasoning context using both approaches:
If you construct the assistant message manually as a dictionary but omit the reasoning_content field, the model will not have access to its previous reasoning process.
The following script demonstrates this behavior and validates that the reasoning_content from the first turn is included in subsequent requests:
main.py
Below is the expected output:

Preserved thinking

While interleaved thinking preserves reasoning within a single turn (across tool calls), preserved thinking extends this concept across multiple user turns. This allows the model to retain reasoning content from previous assistant turns in the conversation context, enabling more coherent multi-turn reasoning.
Diagram showing preserved thinking where reasoning from Turn 1 is included in the input context for Turn 2

Preserved thinking: reasoning from previous turns is retained and passed to subsequent turns. Source: Z.AI

Controlling reasoning history

You can control how historical reasoning content is included in subsequent requests using the reasoning_history parameter:
See the reasoning_history parameter for all accepted values.
When reasoning_history is set to "preserved", the model receives the full reasoning context from all previous turns. This is particularly useful for complex multi-turn conversations where maintaining reasoning continuity is important.
The following script demonstrates preserved thinking across multiple turns and validates that reasoning_content from all previous turns is included in subsequent requests:
main.py
Below is the expected output:
GLM-4.7 (output)