Reasoning models provide step-by-step thinking processes, making them ideal for complex problem-solving, math, coding, and analysis tasks. RedPill supports all major reasoning models with TEE protection.
Reasoning tokens show the model’s “thinking process” before generating the final answer, leading to more accurate and well-reasoned responses.
from openai import OpenAIclient = OpenAI( api_key="YOUR_REDPILL_API_KEY", base_url="https://api.redpill.ai/v1")response = client.chat.completions.create( model="openai/o1", messages=[ { "role": "user", "content": "Solve this problem step by step: If a train travels at 60 mph for 2.5 hours, then 80 mph for 1 hour, what is the total distance traveled?" } ])print(response.choices[0].message.content)
The model will show its thinking process:1. First segment: 60 mph × 2.5 hours = 150 miles2. Second segment: 80 mph × 1 hour = 80 miles3. Total distance = 150 + 80 = 230 milesAnswer: 230 miles
math_problem = """A water tank can be filled by three pipes A, B, and C.- Pipe A can fill the tank in 6 hours- Pipe B can fill it in 8 hours- Pipe C can fill it in 12 hoursIf all three pipes are opened simultaneously, how long will it take to fill the tank?"""response = client.chat.completions.create( model="openai/o1", messages=[{"role": "user", "content": math_problem}], reasoning={"effort": "high"})print(response.choices[0].message.content)
Output (with reasoning):
Copy
Let me think through this step by step:1. Find rate for each pipe: - Pipe A: 1/6 tank per hour - Pipe B: 1/8 tank per hour - Pipe C: 1/12 tank per hour2. Combined rate when all open: 1/6 + 1/8 + 1/12 = 4/24 + 3/24 + 2/24 = 9/24 = 3/8 tank per hour3. Time to fill one tank: 1 ÷ (3/8) = 8/3 = 2 hours and 40 minutesAnswer: 2 hours 40 minutes (or 2.67 hours)
code_problem = """This Python function is supposed to find duplicates in a list, but it's not working correctly:def find_duplicates(lst): seen = set() duplicates = [] for item in lst: if item in seen: duplicates.append(item) seen.add(item) return duplicatesTest case: find_duplicates([1, 2, 3, 2, 4, 3, 5, 3])Expected: [2, 3, 3]Actual: [2, 3]What's wrong and how do I fix it?"""response = client.chat.completions.create( model="deepseek/deepseek-chat", # Also great for code reasoning messages=[{"role": "user", "content": code_problem}])print(response.choices[0].message.content)
puzzle = """Five houses in a row, each painted a different color.- The English person lives in the red house- The Swede has a dog- The Dane drinks tea- The green house is directly to the left of the white house- The person in the green house drinks coffee- The person who smokes Pall Mall has birds- The person in the yellow house smokes Dunhill- The person in the middle house drinks milk- The Norwegian lives in the first house- The person who smokes Blend lives next to the one with cats- The person with a horse lives next to the one who smokes Dunhill- The person who smokes Blue Master drinks beer- The German smokes Prince- The Norwegian lives next to the blue house- The person who smokes Blend has a neighbor who drinks waterWho owns the fish?"""response = client.chat.completions.create( model="anthropic/claude-sonnet-4", messages=[{"role": "user", "content": puzzle}], reasoning={"effort": "high"})print(response.choices[0].message.content)
research_query = """Analyze the pros and cons of implementing a microservices architecturefor a startup with 10 engineers building an e-commerce platform.Consider:- Development complexity- Operational overhead- Scalability benefits- Team coordination- Cost implications- Time to marketProvide a recommendation with detailed reasoning."""response = client.chat.completions.create( model="anthropic/claude-sonnet-4", messages=[{"role": "user", "content": research_query}], reasoning={"effort": "high"})print(response.choices[0].message.content)
strategy_question = """Our SaaS company has $500K ARR and is growing 15% MoM.We have:- 2 engineers- 1 designer- 1 sales person- $200K in the bankShould we:A) Hire 2 more engineers to ship features fasterB) Hire 2 sales people to accelerate growthC) Hire 1 engineer + 1 sales personD) Focus on profitability and don't hireThink through each option's implications over the next 12 months."""response = client.chat.completions.create( model="anthropic/claude-4.1", messages=[{"role": "user", "content": strategy_question}], reasoning={"effort": "high"})print(response.choices[0].message.content)
prompt = """Let's solve this step by step:Problem: A bakery sells cakes for $12 each. The ingredients cost $5 per cake,and fixed costs are $500/month. How many cakes must they sell to profit $2000/month?Please show your work:1. Calculate profit per cake2. Determine total profit needed3. Calculate cakes needed4. Verify the answer"""response = client.chat.completions.create( model="openai/o1", messages=[{"role": "user", "content": prompt}])print(response.choices[0].message.content)
from openai import OpenAIclient = OpenAI( api_key="YOUR_REDPILL_API_KEY", base_url="https://api.redpill.ai/v1")# Step 1: Break down the problembreakdown = client.chat.completions.create( model="anthropic/claude-sonnet-4", messages=[{ "role": "user", "content": "Break down the problem of optimizing a database with 10M rows and slow queries into 5 actionable steps" }])steps = breakdown.choices[0].message.content# Step 2: Analyze each stepanalysis = client.chat.completions.create( model="anthropic/claude-sonnet-4", messages=[ {"role": "user", "content": "Break down the problem..."}, {"role": "assistant", "content": steps}, {"role": "user", "content": "For each step, explain the reasoning and potential trade-offs"} ], reasoning={"effort": "high"})print(analysis.choices[0].message.content)
# Get reasoning from Claudereasoning_response = client.chat.completions.create( model="anthropic/claude-sonnet-4", messages=[{"role": "user", "content": "How should I structure a Redis cache layer?"}], reasoning={"effort": "high"})reasoning = reasoning_response.choices[0].message.content# Use reasoning with GPT-4ofinal_response = client.chat.completions.create( model="openai/gpt-5", messages=[ {"role": "user", "content": f"Based on this reasoning:\n\n{reasoning}\n\nGenerate a detailed implementation plan with code examples."} ])print(final_response.choices[0].message.content)