llm-gateway
БесплатноБез исполняемых скриптовНе проверенLLM gateways in front of RAG stacks. Covers Portkey (caching, fallbacks, retries, observability), OpenRouter (300+ model routing), LiteLLM Proxy, Kong AI…
от claude-dev-suite★ 51 звезда на GitHubОб этом скилле
LLM Gateway
An LLM gateway sits between your RAG app and the provider APIs. It gives you: provider-agnostic API, retries + fallbacks, rate-limit smoothing, semantic + exact cache, cost-based routing, observability. For any RAG stack running in production, a gateway eliminates a class of 3 AM pages and shaves 20–60% off provider spend.
When to Use a Gateway
- You call more than one provider (Anthropic + OpenAI + Bedrock + Voyage).
- You want zero-downtime during provider outages (Claude is down → fall back to GPT-4o).
- You want one place to rotate keys, enforce spend limits, collect traces.
- You're cache-starved: identical or semantically similar queries hit live APIs.
- You serve many tenants with different model entitlements.
Gateway Options
| Gateway | Strengths | Notes |
|---|---|---|
| Portkey | Prod-grade: cache, fallbacks, retries, load balancing, guardrails, virtual keys, analytics, OSS core + cloud | Most feature-complete; OpenAI-compatible |
| OpenRouter | 300+ models, pay-as-you-go across many providers, cheap routing | Hosted only; simple REST |
| LiteLLM Proxy | Self-hosted, OpenAI-compatible, routing, budgets, teams, LangSmith integration | Python; easy to deploy |
| Kong AI Gateway | Plugs into Kong; AI-specific plugins for rate-limit, transform, cache | Best if you already run Kong |
| Helicone | Observability-first, one-line integration, caching | Less heavyweight than Portkey |
| Cloudflare AI Gateway | Global edge, caching, rate-limit, analytics | Cloudflare ecosystem |
Portkey (Config + Client)
from portkey_ai import Portkey
pk = Portkey(
api_key=PORTKEY_API_KEY,
config="pc-rag-prod-abc123", # Portkey Config ID
virtual_key="anthropic-prod-key",
metadata={"tenant_id": tenant_id, "feature": "qa_chat"},
)
resp = pk.chat.completions.create(
model="claude-sonnet-4-5",
messages=[...],
)
Portkey Config Example (fallback + retries + cache)
{
"strategy": { "mode": "fallback" },
"targets": [
{
"provider": "anthropic",
"virtual_key": "anthropic-prod",
"override_params": {"model": "claude-sonnet-4-5"},
"retry": {"attempts": 2, "on_status_codes": [429, 500, 502, 503, 504]}
},
{
"provider": "openai",
"virtual_key": "openai-prod",
"override_params": {"model": "gpt-4o"}
}
],
"cache": { "mode": "semantic", "max_age": 3600 },
"request_timeout": 30000
}
Portkey Load Balancing (cost-based)
{
"strategy": { "mode": "loadbalance" },
"targets": [
{"weight": 0.7, "provider": "anthropic", "override_params": {"model": "claude-haiku-4-5"}},
{"weight": 0.3, "provider": "openai", "override_params": {"model": "gpt-4o-mini"}}
]
}
Use conditional strategy to route by query complexity (simple → cheap, complex → Sonnet/Opus).
OpenRouter
from openai import OpenAI
client = OpenAI(base_url="https://openrouter.ai/api/v1", api_key=OPENROUTER_KEY)
resp = client.chat.completions.create(
model="anthropic/claude-sonnet-4-5",
messages=[{"role": "user", "content": "..."}],
extra_headers={"HTTP-Referer": "https://myapp.com", "X-Title": "RAG QA"},
)
Auto-routing by free-form target:
resp = client.chat.completions.create(
model="openrouter/auto", # OR picks the best-priced working model
messages=[...],
)
Transforms: :floor (cheapest that meets context), :nitro (fastest provider for the model), :free (route to free providers first with fallback).
LiteLLM Proxy (self-hosted)
# config.yaml
model_list:
- model_name: claude-sonnet
litellm_params:
model: anthropic/claude-sonnet-4-5
api_key: os.environ/ANTHROPIC_API_KEY
- model_name: claude-sonnet
litellm_params:
model: bedrock/anthropic.claude-sonnet-4-5-20250514-v1:0
aws_region_name: us-east-1
- model_name: gpt-4o
litellm_params:
model: openai/gpt-4o
api_key: os.environ/OPENAI_API_KEY
router_settings:
routing_strategy: simple-shuffle # or least-busy, usage-based
num_retries: 3
timeout: 30
fallbacks:
- {"claude-sonnet": ["gpt-4o"]}
cooldown_time: 60
general_settings:
master_key: sk-...
database_url: "postgresql://..."
enable_cache: true
cache_params:
type: redis
host: redis
Launch:
litellm --config config.yaml --port 4000
App sees LiteLLM as an OpenAI endpoint:
client = OpenAI(base_url="http://litellm:4000", api_key="sk-team-...")
client.chat.completions.create(model="claude-sonnet", messages=[...])
Per-team virtual keys + budgets are core LiteLLM features — create keys via admin API, each with max_budget and model_list.
Kong AI Gateway
Add AI plugins to a Kong route:
plugins:
- name: ai-proxy
config:
provider: anthropic
model:
name: claude-sonnet-4-5
provider: anthropic
auth:
header_name: x-api-key
header_val
Установить llm-gateway в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadGrepGlobWriteEditFAQ
Что делает скилл llm-gateway?
LLM gateways in front of RAG stacks. Covers Portkey (caching, fallbacks, retries, observability), OpenRouter (300+ model routing), LiteLLM Proxy, Kong AI Gateway, semantic caching at gateway layer, cost-based routing (cheap model for easy queries), rate-limit handling, and unified API across providers. Config examples. USE WHEN: user mentions "LLM gateway", "Portkey", "OpenRouter", "LiteLLM", "Kong AI Gateway", "AI gateway", "semantic cache gateway", "provider fallback", "unified LLM API" DO NOT USE FOR: in-app caching - use `rag-caching`; multi-region routing - use `multi-region`; cost tracking/dashboarding - use `cost-allocation`
Как установить скилл llm-gateway?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл llm-gateway запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic