> ## 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.

# Routing

> Route requests between agents

Routing directs requests to appropriate agents.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph TB
    subgraph "Routing"
        R[📥 Request] --> RT{🔀 Route}
        RT --> A1[🤖 Agent A]
        RT --> A2[🤖 Agent B]
        RT --> A3[🤖 Agent C]
    end
    
    classDef router fill:#6366F1,stroke:#7C90A0,color:#fff
    classDef agent fill:#10B981,stroke:#7C90A0,color:#fff
    
    class R,RT router
    class A1,A2,A3 agent
```

## Quick Start

<Steps>
  <Step title="Route Requests to Agents">
    ```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    use praisonai::{Agent, when};

    // Create specialized agents
    let coder = Agent::new()
        .name("Coder")
        .instructions("You help with programming tasks")
        .build()?;

    let writer = Agent::new()
        .name("Writer")
        .instructions("You help with writing tasks")
        .build()?;

    // Route based on input content
    let router = when(|input: &str| input.contains("code"))
        .then(coder)
        .otherwise(writer);

    router.run("Help me write code").await?;
    // Routes to coder agent
    ```
  </Step>

  <Step title="Multi-Route Configuration">
    ```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    use praisonai::when;

    let router = when(|i| i.contains("code"))
        .then(coder)
        .when(|i| i.contains("write"))
        .then(writer)
        .otherwise(general);
    ```
  </Step>
</Steps>

***

## Related

<CardGroup cols={2}>
  <Card title="Router" icon="route" href="/docs/rust/router">
    Agent router
  </Card>

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