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

# Reasoning

> Let the model think before it answers.

Gemma 4 can think step by step before it answers, which helps with math, code and multi-step problems. Thinking is
off by default because it adds output tokens and time.

## Turning it on

Set `reasoning_effort` to `low`, `medium` or `high`. `none` turns thinking off.

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

client = OpenAI(base_url="https://api.fastrun.si/v1", api_key=os.environ["FASTRUN_API_KEY"])

res = client.chat.completions.create(
    model="google/gemma-4-31b-it",
    messages=[{"role": "user", "content": "How many prime numbers are there between 100 and 150?"}],
    reasoning_effort="medium",
)
msg = res.choices[0].message
print("thinking:", getattr(msg, "reasoning", None))
print("answer:", msg.content)
```

```bash curl theme={null}
curl https://api.fastrun.si/v1/chat/completions \
  -H "Authorization: Bearer $FASTRUN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "google/gemma-4-31b-it",
    "reasoning_effort": "medium",
    "messages": [{"role": "user", "content": "How many prime numbers are there between 100 and 150?"}]
  }'
```

You can also turn it on through the chat template with `"chat_template_kwargs": {"enable_thinking": true}`. In the
OpenAI Python SDK, pass it as `extra_body={"chat_template_kwargs": {"enable_thinking": True}}`.

## Where the thinking goes

The thinking comes in a separate `reasoning` field, and `content` holds only the answer:

```json theme={null}
{
  "role": "assistant",
  "reasoning": "Check each odd number from 101 to 149 ...",
  "content": "There are 10 primes between 100 and 150."
}
```

When streaming, it arrives in `delta.reasoning` before the answer starts in `delta.content`.

> [!NOTE]
>
> Some clients read a field named `reasoning_content`. fastrun uses `reasoning`.

## Cost and limits

Thinking tokens are output tokens: they count toward `completion_tokens`, `max_tokens` and the price. Leave enough
room in `max_tokens` for both the thinking and the answer, or the answer may be cut off.

Reasoning works together with [tool calling](https://docs.fastrun.si/guides/tool-calling.md) and [structured outputs](https://docs.fastrun.si/guides/structured-outputs.md).


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