Reasoning Models
OpenAI o1, o3 Reasoning API - Advanced AI reasoning for math, coding, and complex problems. Access reasoning models through UniterRouter with extended thinking and chain-of-thought.
Reasoning Models
Reasoning models like o1 and o3 use extended thinking to solve complex problems in math, coding, and science.
Available Models: o1, o1-mini, o1-preview, o3-mini, and provider-specific reasoning models like deepseek-reasoner.
How It Works
Reasoning models "think" before responding:
- Analyze the problem internally
- Break down into steps
- Generate chain-of-thought
- Produce final answer
Basic Usage
from openai import OpenAI
client = OpenAI(
base_url="https://api.uniterouter.ai/v1",
api_key="your_api_key",
)
response = client.chat.completions.create(
model="o1",
messages=[
{
"role": "user",
"content": "Solve: If a train travels 120km in 2 hours, then stops for 30 minutes, then travels 90km in 1.5 hours, what is the average speed for the entire journey?"
}
]
)
print(response.choices[0].message.content)import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.uniterouter.ai/v1",
apiKey: process.env.UNITEROUTER_API_KEY,
});
const response = await client.chat.completions.create({
model: "o1",
messages: [
{
role: "user",
content: "Prove that the square root of 2 is irrational",
},
],
});
console.log(response.choices[0].message.content);curl https://api.uniterouter.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $UNITEROUTER_API_KEY" \
-d '{
"model": "o1",
"messages": [
{"role": "user", "content": "Write a proof that there are infinitely many prime numbers"}
]
}'Reasoning Effort
Control how much the model thinks (o1 and o3):
response = client.chat.completions.create(
model="o3-mini",
messages=[{"role": "user", "content": "Solve this complex integral..."}],
reasoning_effort="high" # "low", "medium", "high"
)| Level | Use Case | Tokens |
|---|---|---|
low | Simple problems | Fewer |
medium | Balanced (default) | Moderate |
high | Complex problems | More |
Model Comparison
| Model | Best For | Speed | Cost |
|---|---|---|---|
o1 | Complex reasoning | Slower | Higher |
o1-mini | Faster reasoning | Medium | Medium |
o3-mini | Balanced | Fast | Lower |
deepseek-reasoner | Cost-effective | Fast | Lowest |
DeepSeek Reasoner
Access DeepSeek's reasoning model:
response = client.chat.completions.create(
model="deepseek-reasoner",
messages=[
{"role": "user", "content": "Explain the P vs NP problem"}
]
)
# Access reasoning content if available
if hasattr(response.choices[0].message, 'reasoning_content'):
print("Thinking:", response.choices[0].message.reasoning_content)
print("Answer:", response.choices[0].message.content)Use Cases
| Domain | Example |
|---|---|
| Mathematics | Proofs, complex calculations |
| Coding | Algorithm design, debugging |
| Science | Research analysis, hypothesis |
| Logic | Puzzles, deduction |
| Planning | Multi-step strategies |
Example: Complex Math
response = client.chat.completions.create(
model="o1",
messages=[{
"role": "user",
"content": """
Find all positive integers n such that n^2 + 1 divides n! + 1.
Show your work step by step.
"""
}]
)Example: Code Analysis
response = client.chat.completions.create(
model="o1",
messages=[{
"role": "user",
"content": """
Analyze this algorithm and determine its time complexity:
def mystery(n):
if n <= 1:
return 1
return mystery(n-1) + mystery(n-2)
Also suggest an optimized version.
"""
}]
)Limitations
- No streaming - Most reasoning models don't support streaming
- No system messages - o1 models ignore system prompts
- Higher latency - Thinking takes time
- Token usage - Reasoning tokens count toward limits
Best Practices
- Be specific - Clear problem statements get better reasoning
- One problem at a time - Focus on single complex tasks
- Skip simple tasks - Use GPT-4o for straightforward questions
- Verify outputs - Always validate mathematical/logical results
- Consider cost - Use o1-mini or o3-mini for less critical tasks
Related
- Chat Completions - Base API
- Structured Output - JSON responses
How is this guide?
Structured Output
OpenAI JSON Mode API - Generate validated JSON with GPT-4, GPT-4o. Schema-based structured output for reliable data extraction, API integrations, and type-safe AI responses.
Responses
OpenAI Responses API - New conversation format for GPT-4, GPT-4o with built-in tool handling. Simplified API for multi-turn conversations and agent workflows.