360 Secure SkillHub
360 安全技能中心

Agent Gateway

提供一个本地运行的 OpenAI 兼容 API 网关,可将聊天补全请求路由到 Claude、GPT、Gemini 或本地 Ollama,支持按成本或质量选择模型、失败回退链、请求成本与用量统计、健康检查和熔断,并声明用量数据保存在本地。

mackding
mackding
热度 35.33
最近更新 2026-05-11 17:39:00
分类:开发依赖:代码执行 / 第三方 API应用场景:API 集成 / 工作流

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add agent-gateway
Metadata
name
Agent Gateway
description
Smart multi-model routing — use Claude, GPT, Gemini, or local Ollama models with automatic cost optimization, fallback chains, and usage tracking.
version
1.0.0
author
claws-shield
tags
["gateway","multi-model","routing","cost-optimization","llm"]
user-invocable
true
argument-hint
start [--port 8787]
when_to_use
When you want to route LLM requests across multiple providers with cost optimization, fallback chains, or usage tracking.
allowed-tools
["Bash"]

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
  2. Smart Routing — 3 strategies: cheapest-viable, best-quality, balanced
  3. Fallback Chains — If provider A fails, automatically try provider B
  4. Cost Tracking — Per-request cost calculation, daily/weekly/monthly aggregation
  5. Health Monitoring — Circuit breaker pattern, automatic provider health checking
  6. OpenAI-Compatible API — Drop-in replacement with /v1/chat/completions endpoint

How to Use

Start the gateway server:

npx @claws-shield/cli gateway --port 8787

Or programmatically:

node scripts/start-gateway.mjs

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
  • OPENAI_API_KEY — For GPT models
  • GEMINI_API_KEY — For Gemini models
  • Ollama requires no key (connects to localhost:11434)

Routing Strategies

Strategy Description
cheapest Pick the lowest-cost model that meets requirements
best-quality 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.