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

# Reasoning

> Advanced reasoning capabilities with the Responses API

The Responses API supports advanced reasoning capabilities, allowing models to show their internal reasoning process with configurable effort levels.

## Reasoning Configuration

Configure reasoning behavior using the `reasoning` parameter:

```typescript title="TypeScript" lines theme={null}
const response = await fetch('https://openrouter.ai/api/v1/responses', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${process.env.OPENROUTER_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    model: 'openai/gpt-5-mini',
    input: 'What is the meaning of life?',
    reasoning: {
      effort: 'high'
    },
    max_output_tokens: 9000,
  }),
});

const result = await response.json();
console.log(JSON.stringify(result, null, 2));

```

```python title="Python" lines theme={null}
import os
import json
import requests

response = requests.post(
    'https://openrouter.ai/api/v1/responses',
    headers={
        'Authorization': f'Bearer {os.environ["OPENROUTER_API_KEY"]}',
        'Content-Type': 'application/json',
    },
    json={
        'model': 'openai/gpt-5-mini',
        'input': 'What is the meaning of life?',
        'reasoning': {
            'effort': 'high'
        },
        'max_output_tokens': 9000,
    }
)

result = response.json()
print(json.dumps(result, indent=2))

```

```bash title="cURL" lines theme={null}
curl -X POST https://openrouter.ai/api/v1/responses \
  -H "Authorization: Bearer $OPENROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4o-mini",
    "input": "What is the meaning of life?",
    "reasoning": {
      "effort": "high"
    },
    "max_output_tokens": 9000
  }'
```

```go title="Go" lines theme={null}
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"log"
	"net/http"
	"os"
)

func main() {
	body, _ := json.Marshal(map[string]any{
		"model": "openai/gpt-5-mini",
		"input": "What is the meaning of life?",
		"reasoning": map[string]any{
			"effort": "high",
		},
		"max_output_tokens": 9000,
	})

	req, _ := http.NewRequest("POST", "https://openrouter.ai/api/v1/responses", bytes.NewReader(body))
	req.Header.Set("Authorization", "Bearer "+os.Getenv("OPENROUTER_API_KEY"))
	req.Header.Set("Content-Type", "application/json")

	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		log.Fatal(err)
	}
	defer resp.Body.Close()

	data, _ := io.ReadAll(resp.Body)
	var out bytes.Buffer
	if err := json.Indent(&out, data, "", "  "); err != nil {
		log.Fatal(string(data))
	}
	fmt.Println(out.String())
}

```

```text title="Output" theme={null}
{
  "id": "gen-1794947581-gO54HG8Z2IiDBA5rYFaV",
  "object": "response",
  "created_at": 1794947581,
  "model": "openai/gpt-5-mini",
  "status": "completed",
  "completed_at": 1794947600,
  "output": [
    {
      "id": "rs_0087c2a781b3de00016afcb9fdd05087d18c7711a811e099b9",
      "type": "reasoning",
      "status": "completed",
      "summary": [],
      "encrypted_content": "gAAAAABq_LoLHn70RQLCVSfSKQJPmEnj0JKIBnYpTr3DdN9yBRj7qNNXDTwpqyh59GHZCBoydUrNnHV0ARwRJ4xDmJ7CFLFi0T3L0ZXAcLtJZHOQaHuAi_3HoBytD1eRfkTL5TGyyi-_aDRhF9xC6aP4Z4RNGUV0C_SdPE3EnIRTKVSlxuqDLt_cq2H7soJXiOsmJNwvpcBt_Oc8psQlvwy7IG8AbeZjIrzWGCqaI_EsJuf5qlupdg5DdM8VxTzSVQk-An2JIKWQ0pnsnsiaEptV23sdc5hwDdLgDobDoTINo7yTtZ6xiFrY2NDi-BIPWnnCYjosICzvOdEHk5S3tmy_uLwvRe2l1DhF07j5bl7_ucc8TLkdSSHHp_ar_SQfOT1pv94kO1vTr6h6yylq0yx3yIISGpluahWtfzgvidcbATyhQeRpdp_3IOZMD7GSYM1JA1v4EwK78JNGnLJNnoBWyzB4nYk3jBX4rKLHepWT1ReA7M8ikUmtMs6CNKuj76k5oj5n0X6TcugALljkFfNLMeDHJl69AxWRZTgxeLiP99HT1tNeV2wSAn1pIcvwNxe5TBgyia1Xxhc2PQQgZFFH8cp2KAdYa-cB1YgtqlhJfxUOScPBbtXBv10XRasEnFFFxo3EzLeL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ZrlWdTNzkt4tUq_XVhpdIhJ7NodQpKfiuTMAYStKO10NmRU-gywofAm2EcE7x763BHRqHaZOxtSXeOquBp1usIvQT4NGqBLVeySjmeMUcRjae_SseH3TyoybWr6uf71QAbGqVapFKzunsddFYC-yPVZrBC19vtF0qylLxd-8mVMg7CP66o43CcJ39XI2B5R_i3AeQ2mc82HRv3ocUDv8k53io4h2e-MITVtUJlOtJ5PA7aeSjaHWia4n7S1DNVzrA9aQY8iFYd7CEZ6-1BBLgTQyQzHrcvEuLukRAuT4DBBnpIpG1X8UmN6cflNmyL_rsTpuOekaOV2y5-yAE1ZOSnU1vW7avG_VSn4X2rIfsMTJHkIgj_EGdoZEtTddXM1f3ts44Ss0IrtxB9CX5yqdq8BxMFKxDbwWoRJQudfFaMH4vaINMiBm8FXg1GnQ7sn6VzH3zyJprlNrrOWao2hgTEmZjfPW6xOVIgAmbEmAtXttiqZWd22YExKdk_TVoeLSJ5xqcV5_KFX3EQUtWpLiE2lageyO85OKWazUA-LcQYmOLNVnNz_-Cwps9Bg3k5jh0orF2bvmY3sdHqy-zS5lNqZ2wYD0o3TyEyEu9wFp5KTX0G2Ws2umE81f861jUZEQpEN5Zie_7u_FwqZHxxkz3KufYOP53cuhHoZezIZSuUaH6Oqk6M6knt_EPhaXx-fk33e2D-eYKuM5-GXFgmaC07OXR48I2kX_YpNc0zQau6tSc5CVGPpWtk4BpkP0fIFadNjsNkmIRb8sTlEKiY47zy1WLyOtEEOcCffh8r-K2YDARmCYqOqxXHgRKEnTJ
…[16914 chars clipped]…
1LW1pbmktMjAyNS0wOC0wN3xvcGVuYWkifQ",
      "format": "openai-responses-v1"
    },
    {
      "id": "msg_tmp_jsfyfbl46cb",
      "type": "message",
      "role": "assistant",
      "status": "completed",
      "content": [
        {
          "type": "output_text",
          "text": "Short answer: there’s no single guaranteed answer — meaning is something humans discover or create. Different people and traditions answer differently, and what makes life feel meaningful is often personal. Below are common ways people find meaning and practical steps to explore it yourself.\n\nCommon perspectives\n- Biological: life’s “purpose” from a biological view is survival and reproduction; meaning is something minds construct on top of that.\n- Philosophical: existentialists say you create meaning through your choices; stoics focus on virtue and what you can control; eudaimonists (Aristotle) emphasize flourishing by fulfilling your potential.\n- Religious/spiritual: many faiths place meaning in relationship with the divine, spiritual growth, or service to others.\n- Psychological: research links a sense of purpose to better health and well-being; models like Self-Determination Theory highlight autonomy, competence, and relatedness as core to meaningful life.\n\nWhat typically makes life feel meaningful\n- Connection: close relationships and belonging.\n- Contribution: helping others or making a positive difference.\n- Growth: learning, mastery, and becoming who you want to be.\n- Coherence: a narrative that ties your life together—values, goals, and story.\n- Commitment: projects, roles, or causes that endure beyond momentary pleasure.\n\nPractical steps to explore and build meaning\n- Clarify values: write your top 3–5 values and check how your daily choices align with them.\n- Create a mission statement: one sentence describing what you want to stand for.\n- Start a meaning journal: daily note one thing you did that felt significant and why.\n- Do one deliberate act of contribution each week (help, volunteer, mentor).\n- Take on a challenging project that produces visible results (promotes flow).\n- Reframe suffering: ask what you can learn or how you can use hardship constructively.\n- Deepen relationships: invest time, be present, show gratitude.\n- Build rituals and small habits that reinforce what matters to you.\n\nIf you want a short reading list: Viktor Frankl’s Man’s Search for Meaning, Mihaly Csikszentmihalyi’s Flow, and Marcus Aurelius’ Meditations are good starting points.\n\nIf you’d like, tell me what matters to you (values, interests, current situation) and I’ll suggest a focused exercise or a short plan to help you explore purpose in your life.",
          "annotations": [],
          "logprobs": []
        }
      ]
    }
  ],
  "error": null,
  "incomplete_details": null,
  "access_programs": {
    "cyber": "standard"
  },
  "tools": [],
  "tool_choice": "auto",
```

## Reasoning Effort Levels

The `effort` parameter controls how much computational effort the model puts into reasoning:

| Effort Level | Description |
| - | - |
| `minimal` | Basic reasoning with minimal computational effort |
| `low` | Light reasoning for simple problems |
| `medium` | Balanced reasoning for moderate complexity |
| `high` | Deep reasoning for complex problems |

To change effort partway through a conversation without invalidating the prompt cache, add a `configuration_update` input item before the user message it should apply to. The item is interchangeable with the Chat Completions and Anthropic Messages API forms. See [Changing Effort Mid-Conversation](https://openrouter.ai/docs/guides/best-practices/reasoning-tokens.md#changing-effort-mid-conversation) for the request shape, placement rules, and supported models.

## Complex Reasoning Example

For complex mathematical or logical problems:

```typescript title="TypeScript" expandable lines theme={null}
const response = await fetch('https://openrouter.ai/api/v1/responses', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${process.env.OPENROUTER_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    model: 'openai/gpt-4o-mini',
    input: [
      {
        type: 'message',
        role: 'user' as const,
        content: [
          {
            type: 'input_text',
            text: 'Was 1995 30 years ago? Please show your reasoning.',
          },
        ],
      },
    ],
    reasoning: {
      effort: 'high'
    },
    max_output_tokens: 9000,
  }),
});

const result = await response.json();
console.log(JSON.stringify(result, null, 2));
```

```python title="Python" expandable lines theme={null}
import os
import json
import requests

response = requests.post(
    'https://openrouter.ai/api/v1/responses',
    headers={
        'Authorization': f'Bearer {os.environ["OPENROUTER_API_KEY"]}',
        'Content-Type': 'application/json',
    },
    json={
        'model': 'openai/gpt-4o-mini',
        'input': [
            {
                'type': 'message',
                'role': 'user',
                'content': [
                    {
                        'type': 'input_text',
                        'text': 'Was 1995 30 years ago? Please show your reasoning.',
                    },
                ],
            },
        ],
        'reasoning': {
            'effort': 'high'
        },
        'max_output_tokens': 9000,
    }
)

result = response.json()
print(json.dumps(result, indent=2))

```

```go title="Go" lines theme={null}
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"log"
	"net/http"
	"os"
)

func main() {
	body, _ := json.Marshal(map[string]any{
		"model": "openai/gpt-4o-mini",
		"input": []map[string]any{
			{
				"type": "message",
				"role": "user",
				"content": []map[string]any{
					{
						"type": "input_text",
						"text": "Was 1995 30 years ago? Please show your reasoning.",
					},
				},
			},
		},
		"reasoning": map[string]any{
			"effort": "high",
		},
		"max_output_tokens": 9000,
	})

	req, _ := http.NewRequest("POST", "https://openrouter.ai/api/v1/responses", bytes.NewReader(body))
	req.Header.Set("Authorization", "Bearer "+os.Getenv("OPENROUTER_API_KEY"))
	req.Header.Set("Content-Type", "application/json")

	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		log.Fatal(err)
	}
	defer resp.Body.Close()

	data, _ := io.ReadAll(resp.Body)
	var out bytes.Buffer
	if err := json.Indent(&out, data, "", "  "); err != nil {
		log.Fatal(string(data))
	}
	fmt.Println(out.String())
}

```

```bash title="cURL" lines theme={null}
curl -X POST https://openrouter.ai/api/v1/responses \
  -H "Authorization: Bearer $OPENROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4o-mini",
    "input": [
      {
        "type": "message",
        "role": "user",
        "content": [
          {
            "type": "input_text",
            "text": "Was 1995 30 years ago? Please show your reasoning."
          }
        ]
      }
    ],
    "reasoning": {
      "effort": "high"
    },
    "max_output_tokens": 9000
  }'
```

```text title="Output" theme={null}
{
  "id": "gen-1794947669-ZwVa9WtDLFWibOSBE5JB",
  "object": "response",
  "created_at": 1794947669,
  "model": "openai/gpt-4o-mini",
  "status": "completed",
  "completed_at": 1794947670,
  "output": [
    {
      "id": "msg_tmp_g3lyvwqq9z",
      "type": "message",
      "role": "assistant",
      "status": "completed",
      "content": [
        {
          "type": "output_text",
          "text": "To determine if 1995 was 30 years ago, we can subtract 1995 from the current year, 2023.\n\n2023 - 1995 = 28\n\nThis calculation shows that 1995 was 28 years ago, not 30 years ago.",
          "annotations": [],
          "logprobs": []
        }
      ]
    }
  ],
  "error": null,
  "incomplete_details": null,
  "access_programs": null,
  "tools": [],
  "tool_choice": "auto",
  "parallel_tool_calls": true,
  "max_output_tokens": 9000,
  "temperature": 1,
  "top_p": 1,
  "presence_penalty": 0,
  "frequency_penalty": 0,
  "top_logprobs": 0,
  "max_tool_calls": null,
  "metadata": {},
  "background": false,
  "previous_response_id": null,
  "service_tier": "default",
```

## Reasoning in Conversation Context

Include reasoning in multi-turn conversations:

```typescript title="TypeScript" expandable lines theme={null}
const response = await fetch('https://openrouter.ai/api/v1/responses', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${process.env.OPENROUTER_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    model: 'openai/gpt-4o-mini',
    input: [
      {
        type: 'message',
        role: 'user' as const,
        content: [
          {
            type: 'input_text',
            text: 'What is your favorite color?',
          },
        ],
      },
      {
        type: 'message',
        role: 'assistant',
        id: 'msg_abc123',
        status: 'completed',
        content: [
          {
            type: 'output_text',
            text: "I don't have a favorite color.",
            annotations: []
          }
        ]
      },
      {
        type: 'message',
        role: 'user' as const,
        content: [
          {
            type: 'input_text',
            text: 'How many Earths can fit on Mars?',
          },
        ],
      },
    ],
    reasoning: {
      effort: 'high'
    },
    max_output_tokens: 9000,
  }),
});

const result = await response.json();
console.log(JSON.stringify(result, null, 2));
```

```python title="Python" expandable lines theme={null}
import os
import json
import requests

response = requests.post(
    'https://openrouter.ai/api/v1/responses',
    headers={
        'Authorization': f'Bearer {os.environ["OPENROUTER_API_KEY"]}',
        'Content-Type': 'application/json',
    },
    json={
        'model': 'openai/gpt-4o-mini',
        'input': [
            {
                'type': 'message',
                'role': 'user',
                'content': [
                    {
                        'type': 'input_text',
                        'text': 'What is your favorite color?',
                    },
                ],
            },
            {
                'type': 'message',
                'role': 'assistant',
                'id': 'msg_abc123',
                'status': 'completed',
                'content': [
                    {
                        'type': 'output_text',
                        'text': "I don't have a favorite color.",
                        'annotations': []
                    }
                ]
            },
            {
                'type': 'message',
                'role': 'user',
                'content': [
                    {
                        'type': 'input_text',
                        'text': 'How many Earths can fit on Mars?',
                    },
                ],
            },
        ],
        'reasoning': {
            'effort': 'high'
        },
        'max_output_tokens': 9000,
    }
)

result = response.json()
print(json.dumps(result, indent=2))

```

```go title="Go" lines theme={null}
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"log"
	"net/http"
	"os"
)

func main() {
	body, _ := json.Marshal(map[string]any{
		"model": "openai/gpt-5-mini",
		"input": []map[string]any{
			{
				"type": "message",
				"role": "user",
				"content": []map[string]any{
					{
						"type": "input_text",
						"text": "What is your favorite color?",
					},
				},
			},
			{
				"type":   "message",
				"role":   "assistant",
				"id":     "msg_abc123",
				"status": "completed",
				"content": []map[string]any{
					{
						"type":        "output_text",
						"text":        "I don't have a favorite color.",
						"annotations": []any{},
					},
				},
			},
			{
				"type": "message",
				"role": "user",
				"content": []map[string]any{
					{
						"type": "input_text",
						"text": "How many Earths can fit on Mars?",
					},
				},
			},
		},
		"reasoning": map[string]any{
			"effort": "high",
		},
		"max_output_tokens": 9000,
	})

	req, _ := http.NewRequest("POST", "https://openrouter.ai/api/v1/responses", bytes.NewReader(body))
	req.Header.Set("Authorization", "Bearer "+os.Getenv("OPENROUTER_API_KEY"))
	req.Header.Set("Content-Type", "application/json")

	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		log.Fatal(err)
	}
	defer resp.Body.Close()

	data, _ := io.ReadAll(resp.Body)
	var out bytes.Buffer
	if err := json.Indent(&out, data, "", "  "); err != nil {
		log.Fatal(string(data))
	}
	fmt.Println(out.String())
}

```

```bash title="cURL" lines theme={null}
curl -X POST https://openrouter.ai/api/v1/responses \
  -H "Authorization: Bearer $OPENROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4o-mini",
    "input": [
      {
        "type": "message",
        "role": "user",
        "content": [
          {
            "type": "input_text",
            "text": "What is your favorite color?"
          }
        ]
      },
      {
        "type": "message",
        "role": "assistant",
        "id": "msg_abc123",
        "status": "completed",
        "content": [
          {
            "type": "output_text",
            "text": "I don'\''t have a favorite color.",
            "annotations": []
          }
        ]
      },
      {
        "type": "message",
        "role": "user",
        "content": [
          {
            "type": "input_text",
            "text": "How many Earths can fit on Mars?"
          }
        ]
      }
    ],
    "reasoning": {
      "effort": "high"
    },
    "max_output_tokens": 9000
  }'
```

```text title="Output" theme={null}
{
  "id": "gen-1794947707-VOdFKz0P9AutcaSTGCk4",
  "object": "response",
  "created_at": 1794947707,
  "model": "openai/gpt-4o-mini",
  "status": "completed",
  "completed_at": 1794947709,
  "output": [
    {
      "id": "msg_tmp_fwa2kzbl93l",
      "type": "message",
      "role": "assistant",
      "status": "completed",
      "content": [
        {
          "type": "output_text",
          "text": "Mars has a volume of about 163 million cubic kilometers, while Earth has a volume of approximately 1 trillion cubic kilometers. To find out how many Earths could fit on Mars, we divide the volume of Mars by the volume of Earth.\n\nCalculating this gives:\n\n\\[\n\\frac{163 \\text{ million km}^3}{1 \\text{ trillion km}^3} \\approx 0.163\n\\]\n\nThis means that Mars can hold about 0.163 Earths, or, in other words, you cannot fit even one whole Earth on Mars due to its smaller size.",
          "annotations": [],
          "logprobs": []
        }
      ]
    }
  ],
  "error": null,
  "incomplete_details": null,
  "access_programs": null,
  "tools": [],
  "tool_choice": "auto",
  "parallel_tool_calls": true,
  "max_output_tokens": 9000,
  "temperature": 1,
  "top_p": 1,
  "presence_penalty": 0,
  "frequency_penalty": 0,
  "top_logprobs": 0,
  "max_tool_calls": null,
  "metadata": {},
  "background": false,
  "previous_response_id": null,
  "service_tier": "default",
```

## Streaming Reasoning

Enable streaming to see reasoning develop in real-time:

```typescript title="TypeScript" expandable lines theme={null}
const response = await fetch('https://openrouter.ai/api/v1/responses', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${process.env.OPENROUTER_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    model: 'openai/gpt-5-mini',
    input: 'Solve this step by step: If a train travels 60 mph for 2.5 hours, how far does it go?',
    reasoning: {
      effort: 'medium'
    },
    stream: true,
    max_output_tokens: 9000,
  }),
});

const reader = response.body!.getReader();
const decoder = new TextDecoder();
let buffer = '';

stream: while (true) {
  const { done, value } = await reader.read();
  if (done) break;

  buffer += decoder.decode(value, { stream: true });
  const lines = buffer.split('\n');
  buffer = lines.pop() ?? '';

  for (const line of lines) {
    if (line.startsWith('data: ')) {
      const data = line.slice(6);
      if (data === '[DONE]') break stream;

      try {
        const parsed = JSON.parse(data);
        if (
          parsed.type === 'response.reasoning_text.delta' ||
          parsed.type === 'response.reasoning_summary_text.delta'
        ) {
          console.log('Reasoning:', parsed.delta);
        } else if (parsed.type === 'response.output_text.delta') {
          process.stdout.write(parsed.delta);
        }
      } catch (e) {
        // Skip invalid JSON
      }
    }
  }
}
console.log();
```

```python title="Python" expandable lines theme={null}
import os
import requests
import json

response = requests.post(
    'https://openrouter.ai/api/v1/responses',
    headers={
        'Authorization': f'Bearer {os.environ["OPENROUTER_API_KEY"]}',
        'Content-Type': 'application/json',
    },
    json={
        'model': 'openai/gpt-5-mini',
        'input': 'Solve this step by step: If a train travels 60 mph for 2.5 hours, how far does it go?',
        'reasoning': {
            'effort': 'medium'
        },
        'stream': True,
        'max_output_tokens': 9000,
    },
    stream=True
)

for line in response.iter_lines():
    if line:
        line_str = line.decode('utf-8')
        if line_str.startswith('data: '):
            data = line_str[6:]
            if data == '[DONE]':
                break
            try:
                parsed = json.loads(data)
                event_type = parsed.get('type')
                if event_type in ('response.reasoning_text.delta', 'response.reasoning_summary_text.delta'):
                    print(f"Reasoning: {parsed.get('delta', '')}")
                elif event_type == 'response.output_text.delta':
                    print(parsed.get('delta', ''), end='', flush=True)
            except json.JSONDecodeError:
                continue
print()

```

```go title="Go" lines theme={null}
package main

import (
	"bufio"
	"bytes"
	"encoding/json"
	"fmt"
	"log"
	"net/http"
	"os"
	"strings"
)

func main() {
	body, _ := json.Marshal(map[string]any{
		"model": "openai/gpt-5-mini",
		"input": "Solve this step by step: If a train travels 60 mph for 2.5 hours, how far does it go?",
		"reasoning": map[string]any{
			"effort": "medium",
		},
		"stream":            true,
		"max_output_tokens": 9000,
	})

	req, _ := http.NewRequest("POST", "https://openrouter.ai/api/v1/responses", bytes.NewReader(body))
	req.Header.Set("Authorization", "Bearer "+os.Getenv("OPENROUTER_API_KEY"))
	req.Header.Set("Content-Type", "application/json")

	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		log.Fatal(err)
	}
	defer resp.Body.Close()

	scanner := bufio.NewScanner(resp.Body)
	scanner.Buffer(make([]byte, 1024*1024), 1024*1024)
	for scanner.Scan() {
		line := scanner.Text()
		if !strings.HasPrefix(line, "data: ") {
			continue
		}
		data := strings.TrimPrefix(line, "data: ")
		if data == "[DONE]" {
			break
		}

		var parsed struct {
			Type  string `json:"type"`
			Delta string `json:"delta"`
		}
		if err := json.Unmarshal([]byte(data), &parsed); err != nil {
			continue // Skip invalid JSON
		}
		switch parsed.Type {
		case "response.reasoning_text.delta", "response.reasoning_summary_text.delta":
			fmt.Println("Reasoning:", parsed.Delta)
		case "response.output_text.delta":
			fmt.Print(parsed.Delta)
		}
	}
	fmt.Println()
}

```

```bash title="cURL" lines theme={null}
curl -sN https://openrouter.ai/api/v1/responses \
  -H "Authorization: Bearer $OPENROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-5-mini",
    "input": "Solve this step by step: If a train travels 60 mph for 2.5 hours, how far does it go?",
    "reasoning": {
      "effort": "medium",
      "summary": "auto"
    },
    "stream": true,
    "max_output_tokens": 9000
  }' | jq -nRrj --unbuffered '
    foreach (inputs | select(startswith("data: ")) | .[6:] | fromjson?
      | select((.type // "") | test("reasoning_text\\.delta|reasoning_summary_text\\.delta|output_text\\.delta"))) as $e
      ({kind: null, out: ""};
       ($e.type | if test("reasoning") then "reasoning" else "output" end) as $k
       | .out = (if $k != .kind then
                   (if .kind then "\n\n" else "" end) + (if $k == "reasoning" then "Reasoning: " else "Output: " end)
                 else "" end) + $e.delta
       | .kind = $k;
       .out)'
echo

```

```text title="Output" theme={null}
Distance = speed × time.

Speed = 60 miles per hour, time = 2.5 hours.

Distance = 60 × 2.5 = 60 × (5/2) = 30 × 5 = 150 miles.

So the train goes 150 miles.
```

## Response with Reasoning

When reasoning is enabled, the response includes reasoning information:

```json expandable lines theme={null}
{
  "id": "resp_1234567890",
  "object": "response",
  "created_at": 1234567890,
  "model": "openai/o4-mini",
  "output": [
    {
      "type": "reasoning",
      "id": "rs_abc123",
      "encrypted_content": "gAAAAABotI9-FK1PbhZhaZk4yMrZw3XDI1AWFaKb9T0NQq7LndK6zaRB...",
      "summary": [
        "First, I need to determine the current year",
        "Then calculate the difference from 1995",
        "Finally, compare that to 30 years"
      ]
    },
    {
      "type": "message",
      "id": "msg_xyz789",
      "status": "completed",
      "role": "assistant",
      "content": [
        {
          "type": "output_text",
          "text": "Yes. In 2025, 1995 was 30 years ago. In fact, as of today (Aug 31, 2025), it's exactly 30 years since Aug 31, 1995.",
          "annotations": []
        }
      ]
    }
  ],
  "usage": {
    "input_tokens": 15,
    "output_tokens": 85,
    "output_tokens_details": {
      "reasoning_tokens": 45
    },
    "total_tokens": 100
  },
  "status": "completed"
}
```

## Best Practices

1. **Choose appropriate effort levels**: Use `high` for complex problems, `low` for simple tasks
2. **Consider token usage**: Reasoning increases token consumption
3. **Use streaming**: For long reasoning chains, streaming provides better user experience
4. **Include context**: Provide sufficient context for the model to reason effectively

## Next Steps

* Explore [Tool Calling](https://openrouter.ai/docs/api_reference/responses/tool-calling.md) with reasoning
* Learn about [Web Search](https://openrouter.ai/docs/api_reference/responses/web-search.md) integration
* Review [Basic Usage](https://openrouter.ai/docs/api_reference/responses/basic-usage.md) fundamentals
