The reasoning capabilities in Sudo allow you to access advanced reasoning models like o3 for complex problem-solving tasks.

Basic Reasoning

reasoning_effort parameter is mainly supported for OpenAI models. While other providers have reasoning models as well, not all providers support reasoning_effort

Simple Reasoning Task

TypeScript
import { Sudo } from "sudo-ai";

const sudo = new Sudo({
  serverURL: "https://sudoapp.dev/api",
  apiKey: process.env.SUDO_API_KEY ?? "",
});

async function simpleReasoningTask() {
  try {
    const response = await sudo.router.create({
      model: "o3",  // Reasoning model
      messages: [
        {
          role: "user",
          content: "Solve this step by step: If a train travels 120 km in 2 hours, and then 180 km in 3 hours, what is its average speed for the entire journey?"
        }
      ]
    });
    
    console.log("Reasoning Response:");
    console.log(response.choices[0].message.content);
    
  } catch (error) {
    console.error("Reasoning error:", error);
  }
}

simpleReasoningTask();

Reasoning Effort Levels (OpenAI models)

TypeScript
import { Sudo } from "sudo-ai";

const sudo = new Sudo({
  serverURL: "https://sudoapp.dev/api",
  apiKey: process.env.SUDO_API_KEY ?? "",
});

async function solveWithDifferentEfforts(problem: string): Promise<void> {
  // Effort levels to control reasoning depth
  const efforts: Array<"low" | "medium" | "high"> = ["low", "medium", "high"];
  
  try {
    for (const effort of efforts) {
      console.log(`\n--- Reasoning Effort: ${effort.toUpperCase()} ---`);
      
      const response = await sudo.router.create({
        model: "o3",
        messages: [
          { role: "user", content: problem }
        ],
        reasoningEffort: effort
      });
      
      console.log(response.choices[0].message.content);
      
      // Show token usage for different efforts
      if (response.usage) {
        console.log(`Tokens used: ${response.usage.totalTokens}`);
      }
    }
  } catch (error) {
    console.error("Reasoning with efforts error:", error);
  }
}

// Example complex problem
const problem = `
A company has 3 departments. Department A has 15 employees with an average salary of $60,000. 
Department B has 20 employees with an average salary of $75,000. 
Department C has 10 employees with an average salary of $90,000.
If the company wants to give everyone a 8% raise, but needs to keep the total payroll increase under $50,000, 
what should they do?
`;

solveWithDifferentEfforts(problem);

Next Steps

  1. CRUD Operations - Manage stored completions
Reasoning models like o3 excel at complex problem-solving, mathematical reasoning, and multi-step analysis. Use higher reasoning effort levels for more complex problems, but be aware they consume more tokens. Both TypeScript and Python SDKs provide full support for reasoning capabilities with proper error handling.