RelayPlane
OpenRouter routes. RelayPlane observes, governs, and learns.
Agent ops for OpenClaw power users. Your agents make hundreds of API calls per session — RelayPlane gives you visibility, cost control, and governance over all of them.
What It Does
RelayPlane is an optional optimization layer that sits in your agent's request pipeline. It routes simple tasks to cheaper models, enforces budgets, and logs everything — with automatic fallback to direct provider calls if anything goes wrong.
Key principle: RelayPlane is never a dependency. If the proxy dies, your agents keep working. Zero downtime, guaranteed.
Installation
CODEBLOCK0
Quick Start
CODEBLOCK1
⚠️ Important: Do NOT Set BASE_URL
Never do this:
CODEBLOCK2
Instead, use the config approach:
CODEBLOCK3
The config approach uses a circuit breaker — if the proxy is down, traffic goes direct. The BASE_URL approach has no fallback and will take down your entire system.
Architecture
CODEBLOCK4
- - Circuit breaker: 3 consecutive failures → proxy bypassed for 30s
- Auto-recovery: Health probes detect when proxy comes back
- Process management: Gateway can spawn/manage the proxy automatically
Configuration
Minimal (everything else has defaults):
CODEBLOCK5
Full options:
CODEBLOCK6
Commands
| Command | Description |
|---|
| INLINECODE1 | Start the proxy server |
| INLINECODE2 |
View usage and cost breakdown |
|
relayplane-proxy --port 8080 | Custom port |
|
relayplane-proxy --offline | No telemetry |
|
relayplane-proxy --help | Show all options |
Programmatic Usage (v1.3.0+)
CODEBLOCK7
Advanced: Full Agent Ops Proxy
CODEBLOCK8
What's New in v1.4.0
Three Pillars — All Integrated:
- - Observes (Learning Ledger) — every run captured, full decision explainability
- Governs (Policy Engine) — budget caps, model allowlists, approval gates
- Learns (Learning Engine) — pattern detection, cost suggestions, rule management
Sandbox Architecture (v1.3.0+):
- - Circuit breaker — automatic failover, no more system outages
- Process manager — proxy runs as managed child process
- Health probes — active recovery detection
- Stats & observability — p50/p95/p99 latencies, request counts, circuit state
Learning Engine Endpoints (v1.4.0):
- -
GET /v1/analytics/summary — analytics with date range - INLINECODE7 — detect patterns, anomalies, generate suggestions
- INLINECODE8 — list pending suggestions
- INLINECODE9 /
reject — suggestion workflow - INLINECODE11 — active rules
- INLINECODE12 — is this rule helping?
Privacy
- - Your prompts stay local — never sent to RelayPlane servers
- Anonymous telemetry — only token counts, latency, model used
- Opt-out anytime — INLINECODE13
- Fully offline mode — INLINECODE14
Links
- - Docs: https://relayplane.com/docs
- GitHub: https://github.com/RelayPlane/proxy
- npm: https://www.npmjs.com/package/@relayplane/proxy
RelayPlane
OpenRouter路由。RelayPlane负责观察、治理与学习。
面向OpenClaw高级用户的智能体运维工具。您的智能体每次会话需发起数百次API调用——RelayPlane让您对所有调用实现可视化、成本控制与治理。
功能概述
RelayPlane是一个可选的优化层,部署在智能体的请求管道中。它能将简单任务路由至更经济的模型、执行预算管控并记录所有操作——若出现异常,将自动回退至直接供应商调用。
核心原则:RelayPlane绝非依赖项。 即使代理失效,您的智能体仍可正常运行。零停机,有保障。
安装
bash
npm install -g @relayplane/proxy@latest
快速开始
bash
1. 启动代理(默认运行于localhost:4100)
relayplane-proxy
2. 添加至openclaw.json:
{ relayplane: { enabled: true } }
3. 完成配置。OpenClaw在正常状态下通过RelayPlane路由,
代理失效时自动回退至直接供应商调用。
⚠️ 重要提示:请勿设置BASE_URL
切勿执行以下操作:
bash
❌ 错误操作——劫持所有流量,代理失效时导致OpenClaw崩溃
export ANTHROPIC
BASEURL=http://localhost:4100
请使用配置方式:
json
// ✅ 正确操作——openclaw.json
{
relayplane: {
enabled: true
}
}
配置方式采用断路器机制——代理离线时,流量直接发送。而BASE_URL方式无回退机制,将导致整个系统崩溃。
架构
智能体 → OpenClaw网关 → 断路器 → RelayPlane代理 → 供应商
↓ (故障时)
直接连接供应商
- - 断路器: 连续3次失败 → 绕过代理30秒
- 自动恢复: 健康探测检测代理恢复状态
- 进程管理: 网关可自动生成/管理代理进程
配置
最小配置(其余参数使用默认值):
json
{
relayplane: {
enabled: true
}
}
完整配置选项:
json
{
relayplane: {
enabled: true,
proxyUrl: http://127.0.0.1:4100,
autoStart: true,
circuitBreaker: {
failureThreshold: 3,
resetTimeoutMs: 30000,
requestTimeoutMs: 3000
}
}
}
命令
| 命令 | 说明 |
|---|
| relayplane-proxy | 启动代理服务器 |
| relayplane-proxy stats |
查看用量与成本明细 |
| relayplane-proxy --port 8080 | 自定义端口 |
| relayplane-proxy --offline | 无遥测模式 |
| relayplane-proxy --help | 显示所有选项 |
编程使用(v1.3.0+)
typescript
import { RelayPlaneMiddleware, resolveConfig } from @relayplane/proxy;
const config = resolveConfig({ enabled: true });
const middleware = new RelayPlaneMiddleware(config);
// 路由请求——尝试代理,失败时回退至直接发送
const response = await middleware.route(request, directSend);
// 检查状态
const status = middleware.getStatus();
console.log(middleware.formatStatus());
高级:全功能智能体运维代理
typescript
import { createSandboxedProxyServer } from @relayplane/proxy;
const { server, middleware } = createSandboxedProxyServer({
enableLearning: true, // 启用模式检测
enforcePolicies: true, // 执行预算/模型策略
relayplane: { enabled: true }, // 断路器封装
});
await server.start();
// 三大支柱全部激活:观察 + 治理 + 学习
// 断路器保护防止代理故障
v1.4.0 新特性
三大支柱——全面集成:
- - 观察(学习账本) — 记录每次运行,完整决策可解释性
- 治理(策略引擎) — 预算上限、模型白名单、审批关卡
- 学习(学习引擎) — 模式检测、成本建议、规则管理
沙盒架构(v1.3.0+):
- - 断路器 — 自动故障转移,杜绝系统中断
- 进程管理器 — 代理作为受管子进程运行
- 健康探测 — 主动恢复检测
- 统计与可观测性 — p50/p95/p99延迟、请求计数、电路状态
学习引擎端点(v1.4.0):
- - GET /v1/analytics/summary — 带日期范围的分析
- POST /v1/analytics/analyze — 检测模式、异常,生成建议
- GET /v1/suggestions — 列出待处理建议
- POST /v1/suggestions/:id/approve / reject — 建议工作流
- GET /v1/rules — 活跃规则
- GET /v1/rules/:id/effectiveness — 规则有效性评估
隐私保护
- - 您的提示词本地存储 — 绝不发送至RelayPlane服务器
- 匿名遥测 — 仅收集令牌数量、延迟、使用模型
- 随时退出 — relayplane-proxy telemetry off
- 完全离线模式 — relayplane-proxy --offline
相关链接
- - 文档: https://relayplane.com/docs
- GitHub: https://github.com/RelayPlane/proxy
- npm: https://www.npmjs.com/package/@relayplane/proxy