Reasoning models like OpenAI’s O1 and O3 use extended thinking time to solve complex problems through chain-of-thought processing, making them ideal for mathematics, coding, scientific reasoning, and strategic planning.
import openaiclient = openai.OpenAI(base_url="https://gateway.visca.ai/v1",api_key="your-api-key")response = client.chat.completions.create(model="o1",messages=[{"role": "user","content": """Solve this problem step by step:A train travels from City A to City B at 60 mph,then returns at 40 mph. What is the average speed for the entire trip?"""}])print(response.choices[0].message.content)
response = client.chat.completions.create( model="o1", messages=[{ "role": "user", "content": """Solve this physics problem with full explanation: A 2kg object is thrown upward with initial velocity of 20 m/s. Ignoring air resistance, calculate: 1. Maximum height reached 2. Time to reach maximum height 3. Total time in air 4. Velocity when it returns to starting point Show all work and formulas used.""" }])
Code Generation & Debugging
Copy
response = client.chat.completions.create( model="o1-mini", messages=[{ "role": "user", "content": """Review this Python code and fix any bugs: def quicksort(arr): if len(arr) <= 1: return arr pivot = arr[0] left = [x for x in arr if x < pivot] right = [x for x in arr if x > pivot] return quicksort(left) + [pivot] + quicksort(right) What's wrong and how can it be optimized?""" }])
Logic & Strategy
Copy
response = client.chat.completions.create( model="o3", messages=[{ "role": "user", "content": """Analyze this chess position and suggest the best move: Position (FEN): rnbqkbnr/pppp1ppp/8/4p3/4P3/8/PPPP1PPP/RNBQKBNR w KQkq e6 0 2 Provide: 1. Best move in algebraic notation 2. Strategic reasoning 3. Alternative moves and why they're inferior 4. Evaluation of the position""" }])
Data Analysis
Copy
response = client.chat.completions.create( model="o1", messages=[{ "role": "user", "content": """Analyze this dataset and provide insights: Sales data: Q1: $1.2M, Q2: $1.5M, Q3: $1.1M, Q4: $2.3M Marketing spend: Q1: $200K, Q2: $250K, Q3: $180K, Q4: $400K Calculate: 1. ROI for each quarter 2. Correlation between marketing and sales 3. Forecast for Q1 next year 4. Recommendations for marketing budget allocation""" }])
Reasoning models: - Cannot use system messages (user/assistant only) -
Don’t support streaming - Don’t support function calling - Have higher latency
(5-30 seconds typical) - Cost more per token than standard models