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

# Thinking Mode

> Enable step-by-step reasoning for complex tasks

Thinking mode enables the model to reason step by step before producing its final answer. This provides higher quality outputs for complex tasks like math, logic, code generation, and multi-step analysis.

> [!NOTE]
>
> Closed models usually **hide** their reasoning, returning only a summary or nothing at all. Because Subconscious serves **open models**, the model's reasoning is **completely visible**. You get the full, unaltered chain of thought, giving you total transparency for debugging, auditing, and trust.

## How It Works

When thinking mode is enabled, the model generates internal reasoning tokens before the final response. The serving runtime separates these tokens into a structured `reasoning_content` field, so reasoning arrives beside `content` rather than embedded in it. Reasoning tokens are included in your output token usage.

## Enabling Thinking Mode

Each wire format controls thinking with its own syntax.

With the **OpenAI** format,
pass the Subconscious extension `chat_template_kwargs` with `enable_thinking: true` via the
`extra_body` parameter.

With the **Anthropic** format, use the native `thinking` parameter
(`{"type": "enabled", "budget_tokens": ...}`):

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

client = OpenAI(
    api_key="your-api-key",
    base_url="https://api.subconscious.dev/v1",
)

response = client.chat.completions.create(
    model="subconscious/glm-5.3-marathon",
    messages=[{"role": "user", "content": "What is 127 * 849 + 3621?"}],
    extra_body={
        "chat_template_kwargs": {"enable_thinking": True},
    },
)

print(response.choices[0].message.content)
```

```typescript Node.js (OpenAI) theme={null}
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: "your-api-key",
  baseURL: "https://api.subconscious.dev/v1",
});

const response = await client.chat.completions.create({
  model: "subconscious/glm-5.3-marathon",
  messages: [{ role: "user", content: "What is 127 * 849 + 3621?" }],
  // @ts-expect-error Subconscious extension
  chat_template_kwargs: { enable_thinking: true },
});

console.log(response.choices[0].message.content);
```

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

client = Anthropic(
    auth_token="your-api-key",
    base_url="https://api.subconscious.dev",
)

message = client.messages.create(
    model="subconscious/glm-5.3-marathon",
    max_tokens=2048,
    thinking={"type": "enabled", "budget_tokens": 2000},
    messages=[{"role": "user", "content": "What is 127 * 849 + 3621?"}],
)

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

```typescript Node.js (Anthropic) theme={null}
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
  authToken: "your-api-key",
  baseURL: "https://api.subconscious.dev",
});

const message = await client.messages.create({
  model: "subconscious/glm-5.3-marathon",
  max_tokens: 2048,
  thinking: { type: "enabled", budget_tokens: 2000 },
  messages: [{ role: "user", content: "What is 127 * 849 + 3621?" }],
});

for (const block of message.content) {
  if (block.type === "thinking") console.log("[thinking]", block.thinking);
  else if (block.type === "text") console.log(block.text);
}
```

```bash cURL (Chat Completions) theme={null}
curl https://api.subconscious.dev/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "subconscious/glm-5.3-marathon",
    "messages": [{"role": "user", "content": "What is 127 * 849 + 3621?"}],
    "chat_template_kwargs": {"enable_thinking": true}
  }'
```

```bash cURL (Messages) theme={null}
curl https://api.subconscious.dev/v1/messages \
  -H "x-api-key: YOUR_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "subconscious/glm-5.3-marathon",
    "max_tokens": 2048,
    "thinking": {"type": "enabled", "budget_tokens": 2000},
    "messages": [{"role": "user", "content": "What is 127 * 849 + 3621?"}]
  }'
```

> [!NOTE]
>
> Both controls enable the same underlying feature. The OpenAI format toggles it with the
> `enable_thinking` extension; the Anthropic format uses the native `thinking` config and also
> lets you cap reasoning with `budget_tokens`.

## Response Format

With the **OpenAI** format, the reasoning arrives in the `reasoning_content` field of
the response message, and `content` holds only the final answer:

```json theme={null}
{
  "choices": [{
    "message": {
      "reasoning_content": "Let me calculate this step by step. 127 * 849 = 127 * 800 + 127 * 49 ...",
      "content": "The answer is **111,444**."
    }
  }]
}
```

With the **Anthropic** format, the reasoning is returned as a separate `thinking` content block
before the `text` block, rather than inline tags:

```json theme={null}
{
  "content": [
    {"type": "thinking", "thinking": "Let me calculate this step by step...", "signature": ""},
    {"type": "text", "text": "The answer is **111,444**."}
  ]
}
```

## Streaming with Thinking

Thinking mode works with streaming. The reasoning streams first in `delta.reasoning_content`, followed by the final answer in `delta.content`:

```python Python (OpenAI) theme={null}
stream = client.chat.completions.create(
    model="subconscious/glm-5.3-marathon",
    messages=[{"role": "user", "content": "Solve: If 3x + 7 = 22, what is x?"}],
    stream=True,
    extra_body={
        "chat_template_kwargs": {"enable_thinking": True},
    },
)

for chunk in stream:
    delta = chunk.choices[0].delta
    if delta.reasoning_content:
        print(delta.reasoning_content, end="", flush=True)
    if delta.content:
        print(delta.content, end="", flush=True)
```

```python Python (Anthropic) theme={null}
with client.messages.stream(
    model="subconscious/glm-5.3-marathon",
    max_tokens=2048,
    thinking={"type": "enabled", "budget_tokens": 2000},
    messages=[{"role": "user", "content": "Solve: If 3x + 7 = 22, what is x?"}],
) as stream:
    for event in stream:
        if event.type == "content_block_delta":
            if event.delta.type == "thinking_delta":
                print(event.delta.thinking, end="", flush=True)
            elif event.delta.type == "text_delta":
                print(event.delta.text, end="", flush=True)
```

## When to Use Thinking Mode

**Use thinking mode for:**

* Math and arithmetic problems
* Logic puzzles and reasoning tasks
* Complex code generation
* Multi-step analysis
* Tasks requiring planning or strategy

**Skip thinking mode for:**

* Simple Q\&A
* Creative writing
* Translation
* Summarization
* Tasks where speed matters more than accuracy

> [!NOTE]
>
> Thinking tokens count toward your output token usage. For simple tasks, leaving thinking mode off will be faster and more cost-effective.


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