Skip to main content
The HTTP API is also described in Channels → Custom Integrations.
The gateway exposes an HTTP API on port 7433 (configurable via gateway.port). This API is used by the TUI (for LLM proxying and tool execution), by plugin channels, and can be used for custom integrations.

Base URL

The host and port can be configured in config.json5:

Endpoints

Health Check

Returns the gateway health status. Response:
Example:

List Agents

Returns all configured agents with their model configuration, tool/skill assignments, and pre-built context strings for the system prompt. Response:
Example:

Get Config

Returns agent configurations and provider metadata (without API keys). Response:
Example:

List Agent Models

Returns model metadata for the agent’s allowed models (primary + fallbacks). The TUI uses this to set up proxy model registrations without needing API keys. Parameters:
  • :name — Agent name (URL-encoded)
Response:
Example:

Execute Tool

Execute a core tool (read, write, patch, exec) in the agent’s sandbox. Parameters:
  • :name — Agent name (URL-encoded)
Request Body:
The optional sessionKey is used to derive the channel and session context injected as environment variables into the sandbox (BEIGE_AGENT_NAME, BEIGE_CHANNEL, BEIGE_SESSION_KEY). If omitted, defaults to tui:<agentName>:default. Response:
Tool Parameters: Examples:

Send Prompt

Send a message to an agent and get the full response (non-streaming). The agent session is managed server-side by the gateway’s AgentManager, including fallback model handling and hook execution. Parameters:
  • :name — Agent name (URL-encoded)
Request Body:
If sessionKey is omitted, a default session key is used (api:<agentName>:default). Response:
Example:

Stream LLM Response (LLM Proxy)

Proxy an LLM call through the gateway. The gateway resolves API keys server-side, executes prePrompt/postResponse hooks, applies fallback model logic on rate-limit errors, and audit-logs the call. Responses are streamed back as newline-delimited JSON (AssistantMessageEvent objects from the pi SDK). This is the endpoint the TUI uses for all LLM calls — it never needs API keys locally. Request Body:
Response: Newline-delimited JSON stream (application/x-ndjson). Each line is a JSON object — standard pi AssistantMessageEvent types plus two gateway-specific event types: Example:

List Sessions

List saved sessions for an agent. Parameters:
  • :name — Agent name (URL-encoded)
Response:
Example:

Restart Gateway

Trigger a graceful in-place restart of the gateway:
  1. Drain all in-flight LLM/tool calls (including proxied TUI streams)
  2. Tear down sandboxes, sockets, API, and channels
  3. Reload config from disk
  4. Restart everything fresh
Response:
Returns 202 Accepted immediately; the restart happens asynchronously. Example:

Hook Endpoints

These endpoints execute plugin hooks. They are used by the TUI for session lifecycle events and are available for custom integrations. The prePrompt and postResponse hooks for TUI LLM calls are now executed server-side inside the /api/chat/stream endpoint automatically.

Run prePrompt Hooks

Request Body:
Response:

Run postResponse Hooks

Request Body:
Response:

Fire sessionCreated Hook

Request Body:
Response: { "ok": true }

Fire sessionDisposed Hook

Request Body:
Response: { "ok": true }

Error Responses

All endpoints return errors in a consistent format:
Common HTTP status codes:

Authentication

The HTTP API currently has no authentication. It binds to 127.0.0.1 by default and is intended for local use only. If you expose the API to a network, you are responsible for adding authentication (e.g., via a reverse proxy with basic auth, or by modifying the gateway code).

Rate Limiting

There is no built-in rate limiting on the HTTP API itself. The gateway tracks per-provider rate limits internally and applies fallback logic automatically (see LLM Providers → Model Fallback).

Using the API from Code

JavaScript/TypeScript

Python