# Reasoning (/docs/entwickler/reasoning)

> Set how much a model thinks before it answers and read its reasoning, with tested support per model and endpoint.

Reasoning models work through a problem before they answer. Through the API you can set how much effort a model puts into that, and read the reasoning it returns. What works depends on the model and the endpoint. The table below was tested against the live API on 11.11.2026.

## When reasoning helps
Reasoning pays off when the answer depends on several steps that build on each other:

- calculations and allocations (split a bill, prorate a fee, check a total)
- dates and schedules (deadlines, timetables, notice periods)
- rules with exceptions (does this expense qualify under the policy?)
- planning, comparing options, and code

It adds little to tasks a model does in one pass: translating, summarising, rewording, classifying short texts or pulling fields out of a document. There, a model without reasoning, or `low` effort, is faster and cheaper with the same result.

## Quick start

**curl**

```bash
curl https://api.peakprivacy.ch/v1/ai/chat/completions \
  -H "Authorization: Bearer $PEAKPRIVACY_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "model": "gpt-swiss",
    "messages": [
      {"role": "user", "content": "Anna pays twice what Ben pays. Ben pays 6 more than Cora. Together they pay 94. How much does Cora pay?"}
    ],
    "reasoning_effort": "high"
  }'
```

**Python**

```python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.peakprivacy.ch/v1/ai",
    api_key=os.environ["PEAKPRIVACY_API_KEY"],
)

completion = client.chat.completions.create(
    model="gpt-swiss",
    messages=[{"role": "user", "content": "Anna pays twice what Ben pays. Ben pays 6 more than Cora. Together they pay 94. How much does Cora pay?"}],
    reasoning_effort="high",
)

message = completion.choices[0].message
print(getattr(message, "reasoning_content", None))  # how the model got there
print(message.content)                              # the answer
print(completion.usage.completion_tokens_details.reasoning_tokens)
```

**JavaScript**

```js
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.peakprivacy.ch/v1/ai",
  apiKey: process.env.PEAKPRIVACY_API_KEY,
});

const completion = await client.chat.completions.create({
  model: "gpt-swiss",
  messages: [{ role: "user", content: "Anna pays twice what Ben pays. Ben pays 6 more than Cora. Together they pay 94. How much does Cora pay?" }],
  reasoning_effort: "high",
});

const message = completion.choices[0].message;
console.log(message.reasoning_content); // how the model got there
console.log(message.content);           // the answer
console.log(completion.usage?.completion_tokens_details?.reasoning_tokens);
```

The reasoning comes back next to the answer:

```json
{
  "model": "gpt-swiss",
  "choices": [
    {
      "message": {
        "role": "assistant",
        "reasoning_content": "Let C be Cora's share. Ben pays C + 6, Anna 2(C + 6) …",
        "content": "Cora pays 19."
      }
    }
  ],
  "usage": {
    "completion_tokens": 190,
    "completion_tokens_details": { "reasoning_tokens": 181 }
  }
}
```

## Models
| Model | Effort on chat completions | Effort on `/responses` | Accepted values | Reasoning you get back |
|---|---|---|---|---|
| `gpt-swiss` | Yes | Yes | `low`, `medium`, `high` | Full reasoning text |
| `gpt-5` | No, the model doesn't reason on this endpoint. With `tools`, send `"reasoning_effort": "none"`, otherwise the request returns `500`, see [Tool calling](/docs/entwickler/tool-calling#models). | Yes | `none`, `low`, `medium`, `high`, `xhigh`, `max` | A summary, if you ask for one with `reasoning.summary` |
| `deepseek-v4-flash`, `deepseek-r1`, `glm5`, `gpt-eu` | Ignored: always reasons | Ignored: always reasons | – | Full reasoning text |
| `claude-opus`, `claude-sonnet` | Ignored | Endpoint not available | – | None |
| `gemini-3-pro-preview`, `gemini-3.5-flash` | Ignored | Endpoint not available | – | None. The models think internally; those tokens count in `completion_tokens`. |
| `gpt-4o`, `gpt-4.1`, `qwen-3`, `qwen-3-fast` | No reasoning | No reasoning | – | None |
| `mistral-small-swiss`, `gemma-3` | No reasoning | Endpoint not available | – | None |

"Endpoint not available" returns `400` with `unsupported_endpoint`. Which endpoints a model supports is listed in `meta.capabilities`, see [Models › Endpoint support](/docs/entwickler/models#capabilities).

## Parameters
| Endpoint | Field | Values |
|---|---|---|
| Chat completions | `reasoning_effort` (string) | An effort from the table above |
| Chat completions | `reasoning.effort` (string, alternative) | Same. Wins if you send both. |
| `/responses` | `reasoning.effort` (string) | An effort from the table above |
| `/responses` | `reasoning.summary` (string) | `auto`, `concise` or `detailed`. Only `gpt-5`. |

How PeakPrivacy treats values:

- Unsupported values are dropped, not rejected. The request succeeds and the model uses its default. Example: `minimal` on `gpt-5` runs at `medium`, and `max` on `gpt-swiss` is ignored.
- An invalid `summary` drops the whole `reasoning` object, `effort` included.
- Check what was applied: on `/responses`, the `reasoning` field of the response shows the effort and summary that were used.

## Read the reasoning
**Chat completions.** The reasoning text is in `choices[0].message.reasoning_content`, the count in `usage.completion_tokens_details.reasoning_tokens`. `reasoning_content` isn't a typed field in the OpenAI SDKs: read it with `getattr` in Python, or directly in JavaScript as above.

**Responses.** `output` holds an item with `"type": "reasoning"` before the message. For `gpt-swiss`, `deepseek-v4-flash`, `deepseek-r1`, `glm5` and `gpt-eu`, the text is in its `content[].text`. For `gpt-5` you only get a summary, in `summary[].text`, and only when you send `reasoning.summary`. The count is in `usage.output_tokens_details.reasoning_tokens`.

**curl**

```bash
curl https://api.peakprivacy.ch/v1/ai/responses \
  -H "Authorization: Bearer $PEAKPRIVACY_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "model": "gpt-5",
    "input": "Anna pays twice what Ben pays. Ben pays 6 more than Cora. Together they pay 94. How much does Cora pay?",
    "reasoning": {"effort": "high", "summary": "auto"}
  }'
```

**Python**

```python
response = client.responses.create(
    model="gpt-5",
    input="Anna pays twice what Ben pays. Ben pays 6 more than Cora. Together they pay 94. How much does Cora pay?",
    reasoning={"effort": "high", "summary": "auto"},
)

for item in response.output:
    if item.type == "reasoning":
        for part in item.summary:
            print("Summary:", part.text)

print(response.output_text)
print(response.reasoning.effort)  # the setting that was applied
```

**JavaScript**

```js
const response = await client.responses.create({
  model: "gpt-5",
  input: "Anna pays twice what Ben pays. Ben pays 6 more than Cora. Together they pay 94. How much does Cora pay?",
  reasoning: { effort: "high", summary: "auto" },
});

for (const item of response.output) {
  if (item.type === "reasoning") {
    for (const part of item.summary) console.log("Summary:", part.text);
  }
}
console.log(response.output_text);
console.log(response.reasoning?.effort); // the setting that was applied
```

## Conversations
The API keeps no history: you send the whole conversation with every request. Put only the model's `content` back into the history, not its `reasoning_content`. In our tests, sending the reasoning back changed nothing in the answer, but it cost input tokens, and with `deepseek-v4-flash` the model reasoned about twice as long on the next turn.

```python
messages = [{"role": "user", "content": "A train leaves Zürich at 08:12 and arrives in Bern at 09:08. A second train leaves Bern at 08:40 and arrives in Zürich at 09:36. When do they pass each other?"}]

completion = client.chat.completions.create(model="gpt-swiss", messages=messages, reasoning_effort="low")
answer = completion.choices[0].message

# keep the answer, drop the reasoning
messages.append({"role": "assistant", "content": answer.content})
messages.append({"role": "user", "content": "And if the second train leaves 10 minutes later?"})

follow_up = client.chat.completions.create(model="gpt-swiss", messages=messages, reasoning_effort="low")
print(follow_up.choices[0].message.content)
```

## Show reasoning to users
Reasoning is a working note. If you show it in your product:

- Put it behind a toggle such as "Show how the answer was reached", collapsed by default. Show `content` as the answer.
- Present it as unverified. A model can reason correctly and still answer wrongly, or the other way round.
- Treat it like the prompt it came from. It repeats names, amounts and other details from the request, so log and store it with the same care.

## Streaming
Streamed chunks carry reasoning in `choices[0].delta.reasoning_content` and the answer in `delta.content`.

> **Known limitation:** with reasoning models, a stream doesn't keep reasoning and answer reliably apart. The answer, or its first characters, can arrive in `delta.reasoning_content`, reasoning can arrive after the answer or inside it (also in `/responses` streams, as `response.output_text.delta`), and the final usage chunk reports `reasoning_tokens` as 0. **Workaround:** send requests to reasoning models without `stream` when you need the answer and the reasoning separately.

## Choose the effort
Reasoning tokens are output tokens: they count in `completion_tokens` or `output_tokens` and add time before the answer. Higher effort buys more reasoning, which helps on hard problems and is wasted on easy ones. A model may use no reasoning at all on an easy question, even at `high`.

One test run with `gpt-swiss` and the timetable question above:

| Effort | Reasoning tokens | Answer |
|---|---|---|
| `low` | 318 | 08:54 (correct) |
| `medium` (default) | 575 | 08:54 (correct) |
| `high` | 1,117 | 08:54 (correct) |

All three were right, and `high` cost more than three times the reasoning of `low`. Start low and raise the effort only for the tasks where your own test cases show a difference:

- `low` for extraction, classification, short rewrites and simple checks.
- `medium` or the model default for everyday questions.
- `high` and above for multi-step calculations, planning and code that has to be right the first time.

## See also
- [Chat completions](/docs/entwickler/chat-completions)
- [Models](/docs/entwickler/models)
- [Errors and limits](/docs/entwickler/errors)
