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

# Reasoning Models

## Overview

Reasoning models are advanced language models optimized for complex problem-solving tasks. By generating detailed reasoning steps (chain-of-thought), they improve the accuracy of answers in analytical scenarios.

### Typical Use Cases

* **Complex Problem Solving**: Suitable for tasks requiring step-by-step logic, such as math or scientific reasoning.
* **Decision Support Systems**: Helps explain the logic behind conclusions by providing detailed reasoning processes.
* **Education and Training**: Assists learners in understanding complex concepts by presenting derivation processes clearly.

***

## Installation & Setup

Before using reasoning models, make sure the latest OpenAI SDK is installed:

```bash theme={"system"}
pip install -U openai
```

***

## API Usage

Use the `/chat/completions` endpoint to invoke reasoning models.

### Request Parameters

* `max_tokens`: Sets the maximum number of tokens the model can return.
* `temperature`: Recommended between 0.5 and 0.7 (suggested: 0.6) to balance creativity and logic.
* `top_p`: Recommended value is 0.95.

***

### Example Code

#### Streaming Response

```python theme={"system"}
from openai import OpenAI

client = OpenAI(api_key="YOUR_API_KEY", base_url="https://api.novita.ai/openai")
messages = [
    {"role": "user", "content": "Explain Newton's Second Law."}
]

response = client.chat.completions.create(
    model="deepseek/deepseek-v4.1-flash",
    messages=messages,
    stream=True,
    max_tokens=4096
)

content = ""
reasoning_content = ""
for chunk in response:
    if chunk.choices[0].delta.content:
        content += chunk.choices[0].delta.content
    if chunk.choices[0].delta.reasoning_content:
        reasoning_content += chunk.choices[0].delta.reasoning_content

print("Final Answer:", content)
print("Reasoning Steps:", reasoning_content)
```

#### Non-Streaming Response

```python theme={"system"}
response = client.chat.completions.create(
    model="deepseek/deepseek-v4.1-flash",
    messages=[
        {"role": "user", "content": "What is the greenhouse effect? How can it be mitigated?"}
    ],
    stream=False,
    max_tokens=4096
)

content = response.choices[0].message.content
reasoning_content = response.choices[0].message.reasoning_content

print("Final Answer:", content)
print("Reasoning Steps:", reasoning_content)
```

***

## Context Management

Reasoning outputs are not automatically carried over to the next round of dialogue. You must manually maintain the message history:

```python theme={"system"}
messages.append({"role": "assistant", "content": content})
messages.append({"role": "user", "content": "Please continue explaining the solution."})
```

***

## Supported Models

The following reasoning models are currently supported on the Novita platform:

***

## Billing

* Billing is based on the number of tokens for both input and output.
* Please refer to each model's pricing page for specific billing rules and token conversion details.

***

## Notes & Best Practices

* Avoid placing reasoning instructions in the `system` message. Instead, make the intent explicit in the `user` message.
* For mathematical tasks, clearly instruct the model, e.g., “Please reason step by step and provide a final answer.”
* To prevent the model from skipping reasoning steps, consider asking for a newline before the final answer.


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