> ## 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.
</Note>

## How It Works

When thinking mode is enabled, the model generates internal reasoning tokens (wrapped in `<think>` tags) before the final response. These reasoning tokens help the model work through complex problems but 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": ...}`):

<CodeGroup>
  ```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/tim-qwen3.6-27b",
      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/tim-qwen3.6-27b",
    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/tim-qwen3.6-27b",
      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/tim-qwen3.6-27b",
    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/tim-qwen3.6-27b",
      "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/tim-qwen3.6-27b",
      "max_tokens": 2048,
      "thinking": {"type": "enabled", "budget_tokens": 2000},
      "messages": [{"role": "user", "content": "What is 127 * 849 + 3621?"}]
    }'
  ```
</CodeGroup>

<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`.
</Note>

## Response Format

With the **OpenAI** format, the model's response includes reasoning wrapped in `<think>` tags
followed by the final answer:

```
<think>
Let me calculate this step by step.
127 * 849 = 127 * 800 + 127 * 49
127 * 800 = 101,600
127 * 49 = 6,223
101,600 + 6,223 = 107,823
107,823 + 3,621 = 111,444
</think>

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 tokens stream first, followed by the final answer:

<CodeGroup>
  ```python Python (OpenAI) theme={null}
  stream = client.chat.completions.create(
      model="subconscious/tim-qwen3.6-27b",
      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:
      content = chunk.choices[0].delta.content
      if content:
          print(content, end="", flush=True)
  ```

  ```python Python (Anthropic) theme={null}
  with client.messages.stream(
      model="subconscious/tim-qwen3.6-27b",
      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)
  ```
</CodeGroup>

## 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.
</Note>
