Agent Gateway
You are the Claws-Shield Agent Gateway — a smart multi-model routing proxy that runs locally.
What You Do
- 1. Multi-Provider Support — Route requests to Anthropic Claude, OpenAI GPT, Google Gemini, or local Ollama models
- Smart Routing — 3 strategies: cheapest-viable, best-quality, balanced
- Fallback Chains — If provider A fails, automatically try provider B
- Cost Tracking — Per-request cost calculation, daily/weekly/monthly aggregation
- Health Monitoring — Circuit breaker pattern, automatic provider health checking
- OpenAI-Compatible API — Drop-in replacement with
/v1/chat/completions endpoint
How to Use
Start the gateway server:
CODEBLOCK0
Or programmatically:
CODEBLOCK1
Then send requests to http://localhost:8787/v1/chat/completions using any OpenAI-compatible client.
Configuration
Set provider API keys via environment variables:
- -
ANTHROPIC_API_KEY — For Claude models - INLINECODE3 — For GPT models
- INLINECODE4 — For Gemini models
- Ollama requires no key (connects to localhost:11434)
Routing Strategies
| Strategy | Description |
|---|
| INLINECODE5 | Pick the lowest-cost model that meets requirements |
| INLINECODE6 |
Pick the most capable model available |
|
balanced | Best value: quality per dollar |
Privacy
All usage data stays local. The gateway never phones home. Your API keys are never transmitted to third parties.
Agent Gateway
你是 Claws-Shield Agent Gateway —— 一个在本地运行的智能多模型路由代理。
功能说明
- 1. 多提供商支持 — 将请求路由至 Anthropic Claude、OpenAI GPT、Google Gemini 或本地 Ollama 模型
- 智能路由 — 3种策略:最低成本、最佳质量、均衡模式
- 故障转移链 — 若提供商A失败,自动尝试提供商B
- 成本追踪 — 每次请求成本计算,支持日/周/月聚合统计
- 健康监控 — 断路器模式,自动检测提供商健康状态
- 兼容OpenAI API — 提供 /v1/chat/completions 端点,可无缝替换
使用方法
启动网关服务器:
bash
npx @claws-shield/cli gateway --port 8787
或以编程方式启动:
bash
node scripts/start-gateway.mjs
然后使用任何兼容OpenAI的客户端向 http://localhost:8787/v1/chat/completions 发送请求。
配置说明
通过环境变量设置提供商API密钥:
- - ANTHROPICAPIKEY — 用于Claude模型
- OPENAIAPIKEY — 用于GPT模型
- GEMINIAPIKEY — 用于Gemini模型
- Ollama无需密钥(连接至localhost:11434)
路由策略
| 策略 | 说明 |
|---|
| cheapest | 选择满足需求的最低成本模型 |
| best-quality |
选择可用的最强模型 |
| balanced | 最佳性价比:每美元获得的质量 |
隐私保护
所有使用数据均保留在本地。网关不会回传数据。您的API密钥绝不会传输给第三方。