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

# Router

> Route requests to appropriate agents

Router directs requests to the most appropriate agent.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph TB
    subgraph "Agent Router"
        R[📥 Request] --> RT{🔀 Router}
        RT --> |Technical| T[🔧 Tech Agent]
        RT --> |Sales| S[💼 Sales Agent]
        RT --> |Support| SP[🙋 Support Agent]
    end
    
    classDef router fill:#6366F1,stroke:#7C90A0,color:#fff
    classDef agent fill:#10B981,stroke:#7C90A0,color:#fff
    
    class R,RT router
    class T,S,SP agent
```

## Quick Start

<Steps>
  <Step title="Create Agent Router">
    ```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    use praisonai::{Agent, when};

    // Create specialized agents
    let tech_agent = Agent::new()
        .name("Tech Support")
        .instructions("Help with technical issues")
        .build()?;

    let sales_agent = Agent::new()
        .name("Sales")
        .instructions("Handle sales inquiries")
        .build()?;

    let support_agent = Agent::new()
        .name("Support")
        .instructions("General customer support")
        .build()?;

    // Create router with conditions
    let router = when(|input: &str| input.contains("API") || input.contains("error"))
        .then(tech_agent)
        .when(|input: &str| input.contains("price") || input.contains("buy"))
        .then(sales_agent)
        .otherwise(support_agent);

    router.run("I need help with an API error").await?;
    // Routes to tech_agent
    ```
  </Step>
</Steps>

***

## Routing Strategies

| Strategy | Description                |
| -------- | -------------------------- |
| Keyword  | Match keywords in input    |
| Semantic | Use embeddings to classify |
| LLM      | Use LLM to decide          |
| Rules    | Custom routing rules       |

***

## Related

<CardGroup cols={2}>
  <Card title="Conditions" icon="code-branch" href="/docs/rust/conditions">
    Conditional logic
  </Card>

  <Card title="Agent Teams" icon="users" href="/docs/rust/agent-team">
    Multi-agent teams
  </Card>
</CardGroup>
