Capabilities

Thinking

Some models — Qwen3, Phi-4-reasoning, gpt-oss, and the like — reason through a problem step by step before giving an answer. They're worth reaching for on maths, logic, multi-step planning, and tricky code, where the extra deliberation noticeably improves accuracy.

What the model page shows

On a model's page, the Architecture & specs card marks the model's reasoning style:

  • Reasoning — the model thinks before it answers, as described below.
  • Hybrid (toggle thinking) — same, but you can switch the thinking off per request when you want a fast, direct reply (see Turn thinking off below).

How it works

There's no special flag — send a normal chat completion to a reasoning-capable model and Pendra does the rest. It keeps the model's chain-of-thought separate from its final answer: the thinking comes back on a reasoning_content field (streamed as delta.reasoning_content) — and, for wider client compatibility, mirrored on reasoning — while the answer stays in the usual content. In the Playground the thinking shows up in a collapsible Thinking block above the reply.

from pendra import Pendra

client = Pendra()

response = client.chat.completions.create(
    model="qwen3.6:27b",
    messages=[{"role": "user", "content": "If a train leaves at 3pm going 60mph..."}],
)

msg = response.choices[0].message
print(msg.reasoning)   # the model's working
print(msg.content)     # the final answer
Response

Thinking — The train leaves at 3pm at 60mph. To find arrival time I need the distance… 60mph means 1 mile a minute, so 90 miles takes 90 minutes…

It arrives at 4:30pm.

Control the effort

Set reasoning_effort to "low", "medium", or "high" to trade speed against depth on models that support it. Higher effort spends more tokens thinking and takes longer; lower effort answers faster. The tokens spent reasoning are reported under usage.completion_tokens_details.reasoning_tokens so you can see what each request cost.

Turn thinking off

Sometimes you want a reasoning model to answer directly — for a quick classification, a short completion, or when you've set a small max_tokens and don't want the whole budget spent thinking (which would come back as empty content with finish_reason: "length"). Send "enable_thinking": false to skip the chain-of-thought and get straight to the answer:

{
  "model": "qwen3.6:27b",
  "messages": [{ "role": "user", "content": "Classify: 'ship it'. positive or negative?" }],
  "max_tokens": 5,
  "enable_thinking": false
}

"reasoning_effort": "none" does the same thing. Either one leaves the model running normally with thinking on by default, so you only opt out when you mean to.

If a reply does come back empty because thinking used up the whole max_tokens budget, Pendra attaches a short advisory to the response at pendra.notice — with code: "truncated_during_reasoning" and a message explaining what happened — so you can detect the case in code and retry with a larger budget or with thinking turned off. The partial thinking is still returned on reasoning_content.

Thinking is a feature of the chat endpoint. For every field and the full response shape, see the Chat completions API reference.