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

# AI Reasoning Models API

> Use chain-of-thought reasoning models like DeepSeek-R1 and Qwen3 for math, logic, and complex analysis through the Runcrate API.

export const RuncrateStyles = () => {
  if (typeof document !== 'undefined' && !document.getElementById('runcrate-overrides')) {
    const s = document.createElement('style');
    s.id = 'runcrate-overrides';
    s.textContent = `
      /* Match Runcrate's rounding scale (--radius: 0.75rem) */
      .rounded-sm { border-radius: 0.5rem !important; }   /* 8px */
      .rounded-md { border-radius: 0.625rem !important; } /* 10px */
      .rounded-lg { border-radius: 0.75rem !important; }  /* 12px */
      .rounded-l-sm { border-top-left-radius: 0.5rem !important; border-bottom-left-radius: 0.5rem !important; }
      .rounded-r-sm { border-top-right-radius: 0.5rem !important; border-bottom-right-radius: 0.5rem !important; }
      .rounded-l-md { border-top-left-radius: 0.625rem !important; border-bottom-left-radius: 0.625rem !important; }
      .rounded-r-md { border-top-right-radius: 0.625rem !important; border-bottom-right-radius: 0.625rem !important; }
      .rounded-l-lg { border-top-left-radius: 0.75rem !important; border-bottom-left-radius: 0.75rem !important; }
      .rounded-r-lg { border-top-right-radius: 0.75rem !important; border-bottom-right-radius: 0.75rem !important; }

      /* Cards: never pure white in light mode */
      .card { background-color: #fcfcfc !important; border-radius: 0.75rem !important; }
      html.dark .card { background-color: #141414 !important; }

      /* Docs hero box */
      .rc-hero { background-color: #fcfcfc; border: 1px solid #e0e0e0; }
      html.dark .rc-hero { background-color: #141414; border-color: #242424; }
      html.dark .rc-hero h1 { color: #f5f5f5; }

      /* Runcrate scrollbar — thin, transparent track, hide-until-hover thumb */
      ::-webkit-scrollbar { width: 6px; height: 6px; background-color: transparent; }
      ::-webkit-scrollbar-track { background-color: transparent; }
      ::-webkit-scrollbar-thumb { background-color: rgba(155, 155, 155, 0.5); border-radius: 10px; transition: opacity 0.3s ease; opacity: 0; }
      ::-webkit-scrollbar-thumb:hover { background-color: rgba(155, 155, 155, 0.7); }
      *:hover::-webkit-scrollbar-thumb,
      *:focus::-webkit-scrollbar-thumb,
      *:active::-webkit-scrollbar-thumb { opacity: 1; }
      * { scrollbar-width: thin; scrollbar-color: rgba(155, 155, 155, 0.5) transparent; }
    `;
    document.head.appendChild(s);
  }
  return null;
};

<RuncrateStyles />

Reasoning models think step-by-step before answering. They produce a `reasoning_content` trace followed by a final answer — improving accuracy on math, logic, coding, and multi-step analysis.

## Available models

| Model                             | Parameters  | Strengths                        |
| --------------------------------- | ----------- | -------------------------------- |
| **DeepSeek-R1-0528**              | 671B MoE    | Top-tier math and code reasoning |
| **Qwen3-Max-Thinking**            | Proprietary | Strong multilingual reasoning    |
| **Qwen3-235B-A22B-Thinking-2507** | 235B MoE    | Open weights, cost-effective     |

***

## Basic reasoning

<CodeGroup>
  ```python Python theme={"theme":"github-dark"}
  from runcrate import Runcrate

  client = Runcrate(api_key="rc_live_YOUR_API_KEY")
  response = client.models.chat_completion(
      model="deepseek-ai/DeepSeek-R1-0528",
      messages=[{"role": "user", "content": "A train leaves Chicago at 9am at 80mph. Another leaves New York (790mi away) at 10am at 100mph toward Chicago. When do they meet?"}],
  )
  print("Thinking:", response.choices[0].message.reasoning_content)
  print("Answer:", response.choices[0].message.content)
  ```

  ```typescript TypeScript theme={"theme":"github-dark"}
  import Runcrate from '@runcrate/sdk';

  const rc = new Runcrate({ apiKey: 'rc_live_YOUR_API_KEY' });
  const response = await rc.models.chatCompletion({
    model: 'deepseek-ai/DeepSeek-R1-0528',
    messages: [{ role: 'user', content: 'Train from Chicago at 9am 80mph, another from NYC (790mi) at 10am 100mph. When do they meet?' }],
  });
  console.log('Thinking:', response.choices[0].message.reasoning_content);
  console.log('Answer:', response.choices[0].message.content);
  ```
</CodeGroup>

***

## Streaming

```python theme={"theme":"github-dark"}
# Using the same client
stream = client.models.chat_completion(
    model="deepseek-ai/DeepSeek-R1-0528",
    messages=[{"role": "user", "content": "Prove that the square root of 2 is irrational."}],
    stream=True,
)
for chunk in stream:
    delta = chunk["choices"][0]["delta"]
    if delta.get("reasoning_content"):
        print(delta["reasoning_content"], end="", flush=True)
    if delta.get("content"):
        print(delta["content"], end="", flush=True)
```

***

## Vercel AI SDK

```typescript theme={"theme":"github-dark"}
import { runcrate } from '@runcrate/ai';
import { streamText } from 'ai';

const result = streamText({
  model: runcrate('deepseek-ai/DeepSeek-R1-0528'),
  prompt: 'Find all primes p where p^2 + 2 is also prime. Prove completeness.',
});
for await (const chunk of result.textStream) {
  process.stdout.write(chunk);
}
```

***

## Financial analysis

```python theme={"theme":"github-dark"}
response = client.models.chat_completion(
    model="Qwen/Qwen3-Max-Thinking",
    messages=[
        {"role": "system", "content": "You are a financial analyst. Think step by step."},
        {"role": "user", "content": "Q1: Rev $12.4M, COGS $4.8M, OpEx $5.1M. Q2: $14.1M, $5.2M, $5.4M. Q3: $13.8M, $5.5M, $5.6M. Q4: $16.2M, $5.9M, $5.8M. Calculate margins, identify trends, project Q1 next year."}
    ],
)
print(response.choices[0].message.content)
```

***

## Code debugging

```python theme={"theme":"github-dark"}
response = client.models.chat_completion(
    model="Qwen/Qwen3-235B-A22B-Thinking-2507",
    messages=[{"role": "user", "content": "Find the bug:\ndef merge_sorted(a, b):\n    result, i, j = [], 0, 0\n    while i < len(a) and j < len(b):\n        if a[i] <= b[j]: result.append(a[i]); i += 1\n        else: result.append(b[j]); j += 1\n    return result"}],
)
print(response.choices[0].message.content)
```

***

## Tips

* **reasoning\_content** contains the step-by-step trace. The final answer is in `content`.
* **Longer thinking = better answers.** 10-30 seconds on hard problems is normal.
* **Cost scales with thinking tokens.** Complex problems generate more reasoning tokens.
* **When to use.** Math, logic, code debugging, multi-step analysis. For simple Q\&A, standard models are faster.
