> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gloo.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Models That Think Before They Answer

> Learn how reasoning models work through a problem before answering, when extra effort pays off, and how to turn it up or down on Gloo's endpoints.

# Lesson 8: Models That Think Before They Answer

## Step by Step, Built In

In the last lesson, you asked the AI to think step by step, and it got better answers by working through the problem out loud.

Many newer models do this on their own. Before they write a single word of the answer, they work through the problem: breaking it into parts, trying an approach, checking it, and sometimes starting over. This is called **reasoning**. You'll also hear it called **thinking**. They're the same idea.

You don't have to ask for it in your prompt. You choose how much effort the model puts in, from a quick answer to a long, careful one.

***

## Core Concepts

### What Reasoning Is

A reasoning model does its working out first, then answers. You can think of it as a scratch pad the model fills in before it speaks.

You control the size of that scratch pad with an **effort** setting. Low effort means a short think and a fast answer. High effort means the model takes longer, considers more, and checks its work more carefully.

Many models also let you see a summary of their reasoning, so you can follow how they reached the answer.

### Built In vs. Asked For

Here's how reasoning compares with the "think step by step" technique from Lesson 7:

| | Think step by step (prompting) | Reasoning (a model setting) |
| :- | :- | :- |
| **How you get it** | You ask for it in your prompt | You set an effort level on the request |
| **Where the steps appear** | In the answer itself | Before the answer, separate from it |
| **Which models** | Any model | Models that support reasoning |
| **What you control** | The shape of the steps ("first list the factors, then...") | How much the model thinks |

**Use step-by-step prompting when** you want the steps in the answer, for example so a reader can follow a calculation, or when you want the model to follow a specific structure you've laid out.

**Use reasoning when** you want the model to think hard but give you a clean, finished answer.

**They combine well.** You can turn up the effort *and* tell the model how to approach the problem. The effort controls how much it thinks; your prompt still guides what it thinks about. Everything from earlier lessons about context and clear instructions still applies.

### When More Effort Is Worth It

**Turn effort up for:**

* Multi-step problems where one early mistake ruins the answer
* Math, scheduling, and anything with numbers that must add up
* Planning, where the model needs to weigh options and trade-offs
* Writing or reviewing code

**Keep effort low (or off) for:**

* Simple lookups and factual questions
* Friendly back-and-forth chat
* Anything where speed matters most, like a live chat window

There's a trade-off. Reasoning is billed as **output tokens** (the small pieces of text a model writes, covered in Lesson 2), the same as the words in the answer, whether or not you see the reasoning. More effort means more tokens, a higher cost per request, and a longer wait. Match the effort to the task, just as you learned to match the technique to the task in Lesson 7.

### Reasoning and Thinking on Gloo

Gloo's **Chat Completions** and **Responses** endpoints call it **reasoning**. The same settings, `reasoning_effort` and the `reasoning` object, work across model families, including Claude 5, Gemini, OpenAI and open-weight models, so you ask for reasoning the same way whichever model you call.

The **Anthropic Messages** endpoint is for code written for the Anthropic SDK. It uses Claude's own **thinking** settings, `thinking` and `output_config.effort`, instead.

***

## Get Started

You'll need a Gloo API key. Get one from the [API Keys page](https://docs.gloo.com/studio/manage-api-credentials.md) in Gloo AI Studio and set it as `GLOO_API_KEY`.

### Set the effort

Add `reasoning_effort` to a Chat Completions request. Effort levels run from `none` (no reasoning, on models that can turn it off) through `minimal`, `low`, `medium` and `high` up to `xhigh` and `max`. Each model accepts some of these levels; the [model catalog](https://docs.gloo.com/api-guides/supported-models.md) lists which. A level the model doesn't list may not be applied as asked; the [Reasoning guide](https://docs.gloo.com/api-guides/reasoning.md) explains what happens. Claude Sonnet 5.5, used below, takes `low` to `max`.

```bash cURL theme={null}
curl -X POST 'https://platform.ai.gloo.com/ai/v2/guarded/chat/completions' \
  -H "Authorization: Bearer $GLOO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "gloo-anthropic-claude-sonnet-5.5",
    "reasoning_effort": "medium",
    "messages": [
      { "role": "user", "content": "Three Masses draw 140, 95 and 210 people. 15% of the people attend two of them and the rest attend one. About how many distinct people attend?" }
    ]
  }'
```

```python Python theme={null}
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["GLOO_API_KEY"],
    base_url="https://platform.ai.gloo.com/ai/v2/guarded",
)

completion = client.chat.completions.create(
    model="gloo-anthropic-claude-sonnet-5.5",
    reasoning_effort="medium",
    messages=[{"role": "user", "content": "Three Masses draw 140, 95 and 210 people. 15% of the people attend two of them and the rest attend one. About how many distinct people attend?"}],
)

message = completion.choices[0].message
print("Reasoning:", getattr(message, "reasoning_content", None))
print("Answer:", message.content)
```

```typescript TypeScript theme={null}
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env.GLOO_API_KEY,
  baseURL: 'https://platform.ai.gloo.com/ai/v2/guarded',
});

const completion = await client.chat.completions.create({
  model: 'gloo-anthropic-claude-sonnet-5.5',
  reasoning_effort: 'medium',
  messages: [{ role: 'user', content: 'Three Masses draw 140, 95 and 210 people. 15% of the people attend two of them and the rest attend one. About how many distinct people attend?' }],
});

// reasoning_content is not in the SDK's types.
const message: { content: string | null; reasoning_content?: string | null } =
  completion.choices[0].message;
console.log('Reasoning:', message.reasoning_content);
console.log('Answer:', message.content);
```

### Read the reasoning

The reasoning comes back in `choices[0].message.reasoning_content`, next to the answer in `content`:

```json theme={null}
{
  "choices": [
    {
      "message": {
        "role": "assistant",
        "content": "About 387 distinct people attend.",
        "reasoning_content": "Total attendance is 445. People who attend two Masses are counted twice, so 1.15 × N = 445..."
      },
      "finish_reason": "stop"
    }
  ]
}
```

On the Responses endpoint, add `"summary": "auto"` to the `reasoning` object to get the reasoning back. It arrives as a `reasoning` item in `output[]`, before the answer, and `usage.output_tokens_details.reasoning_tokens` shows how many of the output tokens were reasoning, where the model reports it:

```bash cURL theme={null}
curl -X POST 'https://platform.ai.gloo.com/ai/v2/guarded/responses' \
  -H "Authorization: Bearer $GLOO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "gloo-anthropic-claude-sonnet-5.5",
    "reasoning": { "effort": "medium", "summary": "auto" },
    "input": "Summarize the book of Ruth in two sentences."
  }'
```

```python Python theme={null}
# Uses the client from the example above.
response = client.responses.create(
    model="gloo-anthropic-claude-sonnet-5.5",
    reasoning={"effort": "medium", "summary": "auto"},
    input="Summarize the book of Ruth in two sentences.",
)

for item in response.output:
    if item.type == "reasoning":
        print("Reasoning:", " ".join(part.text for part in item.summary))
print("Answer:", response.output_text)
# Some models report the count as 0 or leave it out.
details = getattr(response.usage, "output_tokens_details", None)
print("Reasoning tokens:", getattr(details, "reasoning_tokens", None))
```

```json theme={null}
{
  "object": "response",
  "status": "completed",
  "model": "gloo-anthropic-claude-sonnet-5.5",
  "output": [
    {
      "type": "reasoning",
      "id": "rs_...",
      "summary": [
        { "type": "summary_text", "text": "The user wants two sentences. Ruth stays with Naomi after loss, then Boaz redeems the family line..." }
      ]
    },
    {
      "type": "message",
      "role": "assistant",
      "content": [
        { "type": "output_text", "text": "After losing her husband, Ruth stays loyal to her mother-in-law Naomi..." }
      ]
    }
  ],
  "usage": { "input_tokens": 21, "output_tokens": 412, "output_tokens_details": { "reasoning_tokens": 318 }, "total_tokens": 433 }
}
```

On Chat Completions, the same count is in `usage.completion_tokens_details.reasoning_tokens`, where the model reports it.

### Using the Anthropic SDK

On Anthropic Messages, use Claude's `thinking` settings. Set `display: "summarized"` to see the thinking, and `output_config.effort` to set how much Claude puts in:

```python Python theme={null}
import os
from anthropic import Anthropic

client = Anthropic(
    base_url="https://platform.ai.gloo.com/ai/v2/direct/anthropic",
    auth_token=os.environ["GLOO_API_KEY"],
)

message = client.messages.create(
    model="gloo-anthropic-claude-opus-5.5",
    max_tokens=16000,
    thinking={"type": "adaptive", "display": "summarized"},
    output_config={"effort": "medium"},
    messages=[{"role": "user", "content": "How many prime numbers are there below 100?"}],
)

for block in message.content:
    if block.type == "thinking":
        print("Thinking:", block.thinking)
    elif block.type == "text":
        print("Answer:", block.text)
```

```bash cURL theme={null}
curl https://platform.ai.gloo.com/ai/v2/direct/anthropic/v1/messages \
  -H "Authorization: Bearer $GLOO_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gloo-anthropic-claude-opus-5.5",
    "max_tokens": 16000,
    "thinking": { "type": "adaptive", "display": "summarized" },
    "output_config": { "effort": "medium" },
    "messages": [
      { "role": "user", "content": "How many prime numbers are there below 100?" }
    ]
  }'
```

The thinking comes back as `thinking` blocks before the `text` block.

### Good to know

* **Reasoning is optional in the response.** Some models, including Claude 5 models, decide how much each request needs and can skip reasoning on easy questions. Read the reasoning if it's there, and don't depend on it.
* **Leave room in your output limit.** Reasoning counts toward `max_tokens` (`max_output_tokens` on Responses). A high effort with a small limit can use up the limit before the answer starts.
* **Many models reason by default.** With no setting, each model does what it normally does, and some reason anyway. The [reasoning guide](https://docs.gloo.com/api-guides/reasoning.md#what-happens-when-you-send-nothing) lists the defaults.

***

## Key Takeaway

Reasoning models do their "step by step" thinking before they answer, and you decide how much. Turn effort up for multi-step problems, math, planning and code; keep it low for simple questions and fast chat. Combine it with clear prompts, and remember that every bit of thinking is billed as output tokens.

***

## What's Next

To learn more:

* [Reasoning](https://docs.gloo.com/api-guides/reasoning.md): every setting, effort level and response field on the Chat Completions and Responses endpoints
* [Anthropic Messages: Thinking](https://docs.gloo.com/api-guides/anthropic-messages.md#thinking): Claude's `thinking` and `output_config.effort` settings for the Anthropic SDKs
* [Supported Models](https://docs.gloo.com/api-guides/supported-models.md): which models reason, and the effort levels each one takes

When you're ready to continue the course, head to **Lesson 9: The Art of Iteration**, where you'll learn to build on AI's responses and turn good prompts into great outcomes.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.