Reasoning flags are currently only available for the OpenAI GPT OSS model.
To enable reasoning, use the reasoning_effort parameter within the chat.completions.create method. This parameter controls the amount of reasoning the model performs.
1

Initial Setup

Begin by importing the Cerebras SDK and setting up the client.
import os
from cerebras.cloud.sdk import Cerebras

client = Cerebras(
    # This is the default and can be omitted
    api_key=os.environ.get("CEREBRAS_API_KEY"),
)
2

Using Reasoning

Set the reasoning_effort parameter within the chat.completions.create method to enable reasoning capabilities.
completion_create_response = client.chat.completions.create(
  messages=[
      {
          "role": "system",
          "content": "You are a helpful assistant."
      },
      {
          "role": "user",
          "content": "Say hello to the world."
      },
      {
          "role": "assistant",
          "content": "Hello, world! 🌍"
      }
  ],
  model="gpt-oss-120b",
  stream=False,
  max_completion_tokens=65536,
  temperature=1,
  top_p=1,
  reasoning_effort="medium"
)

print(completion_create_response)

Reasoning Effort Levels

The reasoning_effort parameter accepts the following values:
  • "low" - Minimal reasoning, faster responses
  • "medium" - Moderate reasoning (default)
  • "high" - Extensive reasoning, more thorough analysis

Response Format

When reasoning is enabled, the response includes a reasoning field containing the model’s internal thought process:
{
  "id": "chatcmpl-xxx",
  "object": "chat.completion",
  "choices": [
    {
      "message": {
        "role": "assistant",
        "content": "Hello, world!",
        "reasoning": "The user is asking for a simple greeting to the world. This is a straightforward request that doesn't require complex analysis. I should provide a friendly, direct response."
      }
    }
  ]
}

Accessing Reasoning Tokens

When using streaming responses with reasoning models, reasoning tokens are delivered in the reasoning field of the response for models that support it:
{
  "choices": [
    {
      "delta": {
        "reasoning": " should"
      },
      "index": 0
    }
  ]
}