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

# Gateway CLI

> Command-line interface for managing the PraisonAI Gateway daemon and server

Gateway CLI provides commands for starting, monitoring, and managing the PraisonAI Gateway server and its daemon service.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    subgraph "Gateway CLI Flow"
        User[👤 User] --> CLI[💻 CLI]
        CLI --> Daemon[⚙️ Daemon]
        Daemon --> Gateway[🗼 Gateway]
        Gateway --> Health[🏥 Health Check]
    end
    
    classDef user fill:#8B0000,stroke:#7C90A0,color:#fff
    classDef tool fill:#189AB4,stroke:#7C90A0,color:#fff
    classDef success fill:#10B981,stroke:#7C90A0,color:#fff
    classDef config fill:#6366F1,stroke:#7C90A0,color:#fff
    
    class User user
    class CLI,Daemon tool
    class Gateway,Health success
```

## Quick Start

<Note>
  **Important**: `praisonai gateway start` runs in the **foreground**. The daemon is installed by `praisonai gateway install` (or automatically by `praisonai onboard`).
</Note>

<Steps>
  <Step title="Start Gateway">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    praisonai gateway start
    ```
  </Step>

  <Step title="Check Status">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    praisonai gateway status
    ```
  </Step>

  <Step title="Test Health Endpoint">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    curl http://127.0.0.1:8765/health
    ```
  </Step>
</Steps>

***

## Commands

### Gateway Management

| Command                      | Description                           | Example                                  |
| ---------------------------- | ------------------------------------- | ---------------------------------------- |
| `praisonai gateway start`    | Start the gateway server (foreground) | `praisonai gateway start --port 9000`    |
| `praisonai gateway status`   | Check gateway and daemon status       | `praisonai gateway status --daemon-only` |
| `praisonai gateway channels` | List configured channels              | `praisonai gateway channels --json`      |

### Daemon Service

| Command                       | Description           | Example                                |
| ----------------------------- | --------------------- | -------------------------------------- |
| `praisonai gateway install`   | Install as OS daemon  | `praisonai gateway install --no-start` |
| `praisonai gateway uninstall` | Remove daemon service | `praisonai gateway uninstall`          |
| `praisonai gateway logs`      | Show daemon logs      | `praisonai gateway logs -n 100`        |
| `praisonai gateway restart`   | Restart the daemon    | See restart commands below             |

### Testing & Debugging

| Command                  | Description       | Example                                                                  |
| ------------------------ | ----------------- | ------------------------------------------------------------------------ |
| `praisonai gateway send` | Send test message | `praisonai gateway send --channel telegram --channel-id 12345 -m "test"` |

***

## Command Reference

<Tabs>
  <Tab title="start">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    praisonai gateway start [OPTIONS]

    Options:
      --host TEXT         Host to bind to [default: 127.0.0.1]
      --port INTEGER      Port to listen on [default: 8765]
      --agents TEXT       Path to agent configuration file
      --config TEXT       Path to gateway.yaml for multi-bot mode

    Examples:
      praisonai gateway start
      praisonai gateway start --config gateway.yaml
      praisonai gateway start --agents agents.yaml --port 9000
    ```
  </Tab>

  <Tab title="status">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    praisonai gateway status [OPTIONS]

    Options:
      --host TEXT         Gateway host [default: 127.0.0.1]
      --port INTEGER      Gateway port [default: 8765]
      --daemon-only       Show only daemon status

    Examples:
      praisonai gateway status
      praisonai gateway status --port 9000
      praisonai gateway status --daemon-only
    ```
  </Tab>

  <Tab title="channels">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    praisonai gateway channels [OPTIONS]

    Options:
      -c, --config TEXT   Path to gateway.yaml [default: gateway.yaml]
      --json              Output JSON format

    Examples:
      praisonai gateway channels
      praisonai gateway channels --config my-gateway.yaml --json
    ```
  </Tab>
</Tabs>

***

## Restart the Daemon

Use these OS-specific commands to restart the daemon service (same commands shown in the onboard Done panel):

<Tabs>
  <Tab title="macOS">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    launchctl kickstart -k gui/$(id -u)/ai.praison.bot
    ```
  </Tab>

  <Tab title="Linux">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    systemctl --user restart praisonai-bot
    ```
  </Tab>

  <Tab title="Windows">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    schtasks /End /TN PraisonAIGateway && schtasks /Run /TN PraisonAIGateway
    ```
  </Tab>
</Tabs>

***

## Status Output Examples

### Healthy Gateway

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
$ praisonai gateway status
Daemon service: Running (launchd)
Process ID: 12345
Gateway server: Reachable at http://127.0.0.1:8765/health
  Status: healthy
  Uptime: 3600.5 seconds
  Agents: 2
  Sessions: 1
  Clients: 3
  Channels: 2 configured
```

### Daemon Issues

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
$ praisonai gateway status
Daemon service: Installed but not running (launchd)
Gateway not reachable at http://127.0.0.1:8765/health
```

### Not Installed

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
$ praisonai gateway status --daemon-only
Daemon service: Not installed (systemd)
```

***

## Platform Support

Gateway CLI works across platforms with native daemon integration:

| Platform    | Service Type                           | Log Location                         | Management                                                                 |
| ----------- | -------------------------------------- | ------------------------------------ | -------------------------------------------------------------------------- |
| **macOS**   | LaunchAgent (`ai.praison.bot`)         | `~/.praisonai/logs/bot-stderr.log`   | `launchctl kickstart -k gui/$(id -u)/ai.praison.bot`                       |
| **Linux**   | systemd user service (`praisonai-bot`) | `journalctl --user -u praisonai-bot` | `systemctl --user restart praisonai-bot`                                   |
| **Windows** | Scheduled Task (`PraisonAIGateway`)    | Windows Event Log                    | `schtasks /End /TN PraisonAIGateway && schtasks /Run /TN PraisonAIGateway` |

***

## Configuration Files

<Tabs>
  <Tab title="agents.yaml">
    ```yaml theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    # Simple agent configuration
    agent:
      name: "support"
      instructions: "You are a helpful support agent"
      model: "gpt-4o-mini"
      tools:
        - search_web
      memory: true
    ```
  </Tab>

  <Tab title="gateway.yaml">
    ```yaml theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    # Multi-bot configuration
    agents:
      support:
        instructions: "You are a support agent"
        model: "gpt-4o-mini"
      sales:
        instructions: "You are a sales agent"
        model: "claude-3-5-sonnet-20241022"

    channels:
      telegram:
        token: "${TELEGRAM_BOT_TOKEN}"
        routing:
          default: support
      discord:
        token: "${DISCORD_BOT_TOKEN}"
        routing:
          default: sales
    ```
  </Tab>
</Tabs>

***

## Best Practices

<AccordionGroup>
  <Accordion title="Use daemon-only for health checks">
    Use `--daemon-only` flag when monitoring daemon status in scripts or CI/CD pipelines to avoid gateway connection attempts.
  </Accordion>

  <Accordion title="Check logs for troubleshooting">
    Always check `praisonai gateway logs` when the daemon is running but gateway is unreachable - this reveals startup errors.
  </Accordion>

  <Accordion title="Test channel configuration">
    Use `praisonai gateway send` to test channel bot configuration before deploying to production environments.
  </Accordion>

  <Accordion title="Monitor daemon status regularly">
    Set up monitoring that runs `praisonai gateway status --daemon-only` to detect service failures quickly.
  </Accordion>
</AccordionGroup>

***

## Related

<CardGroup cols={2}>
  <Card title="Gateway Server" icon="tower-broadcast" href="/features/gateway">
    Gateway architecture and configuration
  </Card>

  <Card title="Troubleshooting" icon="wrench" href="/guides/troubleshoot-gateway">
    Common gateway issues and solutions
  </Card>
</CardGroup>
