一键导入
multi-model-routing
Multi-model routing with cost/quality selection and provider fallbacks. Use for AI gateway abstraction.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Multi-model routing with cost/quality selection and provider fallbacks. Use for AI gateway abstraction.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Level 2 — Pantheon-native context compression with priority scoring, semantic summarization, downstream-aware compression, budget allocation, and cross-references
Multi-agent orchestration with model routing, category delegation, and sprint management. Use for coordinating Pantheon agents.
Auto-continue through todos with idle detection and safety gates. Use for multi-step orchestration.
Level 2 — Pantheon-native context compression with priority scoring, semantic summarization, downstream-aware compression, budget allocation, and cross-references
MCP security hardening — credential leakage prevention, input sanitization, and tool access control. Use for reviewing agent MCP configurations.
Improve prompts using best practices for clarity, specificity, and structure. Use for optimizing AI agent and bot instructions.
| name | multi-model-routing |
| description | Multi-model routing with cost/quality selection and provider fallbacks. Use for AI gateway abstraction. |
| context | fork |
| globs | [] |
| alwaysApply | false |
Route LLM requests to optimal providers based on cost, quality, and availability. Includes fallback chains and provider abstraction.
| Task Type | Primary | Fallback | Cost Tier |
|---|---|---|---|
| Complex reasoning | Claude Sonnet | GPT-4o | $$ |
| Code generation | Claude Sonnet | GPT-4o | $$ |
| Quick tasks | Haiku | 4o-mini | $ |
| Vision | GPT-4o | Claude Vision | $$ |
| Embeddings | text-embedding-3-small | bge-large | $ |
| Chat | Haiku | 4o-mini | $ |
from abc import ABC, abstractmethod
class ModelProvider(ABC):
@abstractmethod
async def generate(self, prompt: str, **kwargs) -> str: ...
class OpenAIProvider(ModelProvider): ...
class AnthropicProvider(ModelProvider): ...
class BedrockProvider(ModelProvider): ...
class ModelRouter:
def __init__(self, providers: dict):
self.providers = providers
self.routes = {
'complex': ['anthropic', 'openai'],
'quick': ['openai-mini', 'anthropic-haiku'],
'vision': ['openai', 'anthropic'],
}
async def route(self, task_type: str, prompt: str):
for provider_name in self.routes[task_type]:
try:
return await self.providers[provider_name].generate(prompt)
except Exception:
continue
raise RuntimeError("All providers failed")
COST_PER_1K_TOKENS = {
'gpt-4o': 0.010,
'claude-sonnet': 0.008,
'haiku': 0.001,
'4o-mini': 0.0005,
}
def estimate_cost(model: str, tokens: int) -> float:
return COST_PER_1K_TOKENS.get(model, 0) * (tokens / 1000)
import asyncio
async def with_fallback(providers, prompt, max_retries=3):
for provider in providers:
for attempt in range(max_retries):
try:
return await provider.generate(prompt)
except Exception:
await asyncio.sleep(2 ** attempt)
raise RuntimeError("All providers exhausted")
import boto3
client = boto3.client('bedrock-runtime', region_name='us-east-1')
async def invoke_bedrock(model_id: str, prompt: str):
response = client.invoke_model(
modelId=model_id,
body=json.dumps({'prompt': prompt})
)
return json.loads(response['body'].read())['output']