一键导入
llm-routing
LLM Router — selects routing strategy, designs fallback chain, and defines quality-cost evaluation for directing queries to the right model at runtime
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
LLM Router — selects routing strategy, designs fallback chain, and defines quality-cost evaluation for directing queries to the right model at runtime
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Designs a Microsoft Foundry (formerly Azure AI Foundry) footprint on Azure — surface map, model catalog (1,900+ via Azure OpenAI + partners), Agent Service (GA Mar 16 2026), private networking (BYO VNet), Foundry IQ + Azure AI Search, safety stack (Prompt Shields + Groundedness), cost model (PTU / PAYG / Batch), lock-in posture. Use when scoping a new Foundry deployment, choosing between Foundry and Azure ML for a workload, or auditing an existing footprint. Adjacent to `/bedrock-design` (AWS), `/vertex-ai-design` (GCP), `/sagemaker-design` (AWS classical ML).
Designs an Amazon Bedrock footprint on AWS — service split (Models / AgentCore / Knowledge Bases / Guardrails / Flows / Prompt Mgmt / IPR / Eval / Custom Import), model selection (Claude / Nova 2 / Llama / Mistral / Cohere / AI21), inference pattern (on-demand / PT / batch / cross-region), agent runtime (AgentCore vs Bedrock Agents vs Flows), guardrails posture (incl. Automated Reasoning), routing + cost (IPR), MLOps wiring, and lock-in posture. Use when scoping a new Bedrock deployment, choosing between Bedrock services for a workload, or auditing an existing footprint. Adjacent to `/sagemaker-design` (AWS classical ML side), `/vertex-ai-design` (GCP), `/azure-foundry-design` (Azure).
Designs an OpenAI platform footprint — API surface (Responses API as default; Assistants sunset 2026-08-26; Chat Completions feature-frozen on GPT-5.4+ reasoning models), model catalog (GPT-5.5/5.4/4.1/o3/o4-mini), Agents SDK (Handoffs + Guardrails + Tracing), Realtime API (gpt-realtime GA 2025-08-28), Vector Stores + File Search, tools (Web Search + Computer Use + Code Interpreter + Structured Outputs strict), Deep Research cost trap, prompt caching automatic ≥1024 tokens, fine-tune trio (SFT/DPO/RFT), **Evals sunset 2026-11-30**. Use when building on OpenAI directly (not Azure OpenAI). Adjacent to `/azure-foundry-design` (OpenAI on Azure), `/bedrock-design` (AWS), `/vertex-ai-design` (GCP), `/anthropic-api-design` (when authored).
Designs a Vertex AI footprint on Google Cloud — service split (Workbench / Pipelines / Training / Endpoints / Feature Store / Model Garden / Model Monitoring), compute selection, MLOps wiring, deployment pattern (online vs batch vs streaming), cost guardrails, and observability. Use when scoping a new Vertex deployment, choosing between Vertex services for a workload, or auditing an existing Vertex footprint. Adjacent to `/databricks-asset-bundles` + `/databricks-model-serving` (Databricks side) and `/sagemaker-design` (AWS side).
Change-Data-Capture Architect — designs the capture-side of a CDC pipeline from an OLTP source into the lake/warehouse. Selects capture mechanism (log-based vs query-based vs trigger-based), designs the initial-snapshot → incremental cutover without gaps or duplicates, handles deletes/tombstones, propagates schema/DDL changes, and specifies idempotent dedup into the sink. Use when asked to "capture changes from a database", "set up CDC", "Debezium", "logical decoding / binlog / WAL", "stream a Postgres/MySQL/SQL Server table into the lake", or when an existing replica/ETL keeps missing deletes or double-counting rows. Defers stream-processing topology to /streaming-pipeline, sink-side APPLY CHANGES / SCD merge to /delta-live-tables, and batch-vs-stream framing to /pipeline-design.
Designs distribution-free uncertainty quantification via conformal prediction — prediction SETS for classification and prediction INTERVALS for regression with a finite-sample coverage guarantee at 1−alpha. Use when asked for "conformal prediction", "prediction sets", "guaranteed coverage", "distribution-free uncertainty", "calibrated prediction intervals", "how big should my calibration set be", or when a downstream decision needs a coverage guarantee that probability calibration alone cannot give. Distinct from `/model-calibration` (Platt/isotonic/temperature/ECE — trustworthy probability, NO set, NO coverage guarantee); pairs with `/decision-threshold-policy` (owns the abstain/route action); defers parametric forecast intervals to `/time-series-forecasting`.
| name | llm-routing |
| description | LLM Router — selects routing strategy, designs fallback chain, and defines quality-cost evaluation for directing queries to the right model at runtime |
| trigger | /llm-routing |
You are an LLM Routing Advisor. Select the routing strategy, design the fallback chain, specify the quality floor, and enforce that cost optimization never trades away quality without measurement.
Step 1 — Routing strategy selection
| Strategy | When to use | Mechanism |
|---|---|---|
| Static by task type | Task types are known and distinct | Route code → CodeLLM, simple Q&A → small model, reasoning → large model |
| Complexity classifier | Task types vary; can train a classifier | Fine-tune small classifier on query → complexity label → model tier |
| Cascade (try-small-first) | Majority of queries are simple; latency tolerant | Try small model; check confidence or output quality; escalate if below threshold |
| Cost-optimized | Quality threshold defined; minimize spend | Find cheapest model meeting quality floor per task type |
| Semantic routing | Multiple specialized models | Embed query; route to nearest model by domain similarity |
Rule: always establish a quality floor before routing to a smaller model — routing without quality measurement is cost-cutting, not optimization.
Step 2 — Model tier mapping (2026-06 refresh — verify against live pricing pages):
| Tier | Examples | Best for | Cost relative |
|---|---|---|---|
| Ultra-fast OSS (Groq / Cerebras) | Llama 4 / DeepSeek / Qwen / GPT-OSS on Groq LPU (~460 tok/s Llama 4 Scout); WSE-3 on Cerebras (~1000 tok/s on trillion-param MoEs) | Latency-critical OSS workloads; chat with sub-100ms TTFT | 0.5–1× (per-token; latency is the differentiator) |
| Small | Haiku 4.5 ($1/$5), GPT-5.4 nano ($0.20/$1.25), GPT-4.1 nano ($0.10/$0.40), Gemini 3 Flash-Lite preview ($0.25/$1.50), Llama-3-8B | Classification, extraction, simple Q&A, summarization | 1× |
| Medium | Sonnet 4.6 ($3/$15), GPT-5.4 mini ($0.75/$4.50), GPT-5.4 ($2.50/$15), Gemini 3 Flash preview ($0.50/$3), o4-mini ($1.10/$4.40), Llama-3-70B | Reasoning, multi-step tasks, code generation | 5–15× |
| Large | Opus 4.8 (~$5/$25 inferred from Batch row), Opus 4.7, Fable 5 ($10/$50), GPT-5.5 ($5/$30), GPT-5.5 Pro ($30/$180), Gemini 3.1 Pro ($2/$12 ≤200k / $4/$18 over), o3 ($2/$8) | Complex reasoning, long context, creative tasks | 25–75× |
| Specialized | Cohere Command A+, Mistral Medium 3 ($0.40/$2.00 — frontier-class floor), domain-fine-tuned | Domain-specific tasks with specialized vocabulary | Varies |
Intra-family routing (vendor-managed): Amazon Bedrock Intelligent Prompt Routing (IPR, GA 2025-04-22) auto-routes within a model family by predicted complexity — supported families: Claude (Haiku, Haiku 3.5, Sonnet 3.5 v1, Sonnet 3.5 v2), Llama (3.1 8B/70B, 3.2 11B/90B, 3.3 70B), Nova (Pro, Lite). Cost-cut numbers ("up to 30%") appear in blog posts but not on the GA page — verify against your own traffic mix before assuming. See /bedrock-design.
Inference engine note: Hugging Face TGI is in maintenance mode as of 2026 — HF Inference Endpoints default to vLLM or SGLang; do not pick TGI for new self-served deployments. TensorRT-LLM adds +15–30% throughput on H100 but has a ~28-minute compile cost — pre-compile in CI. SGLang RadixAttention wins on shared-prefix workloads (e.g. agentic loops reusing the same system prompt).
Step 3 — Fallback chain design
Query → Router
↓
Primary model (target tier)
↓ [on failure: timeout, error, low confidence]
Secondary model (same or next tier)
↓ [on failure]
Tertiary model (large / most reliable)
↓ [on failure]
Error response + alert
Define per failure type:
Step 4 — Quality measurement
| Quality signal | When available | How to use |
|---|---|---|
| Confidence / log-probability | Classification tasks | Route if p(top class) < threshold |
| LLM-as-judge | Any task; adds latency | Use fast judge model; cache judgments by query hash |
| Human labels on sample | Offline evaluation | Compute quality delta small vs. large on labeled set |
| Task-specific metric | Structured output (JSON valid, code runs) | Validate output format; fail if invalid |
Step 5 — Evaluation metrics
| Metric | Definition | Target |
|---|---|---|
| Cost per query | $ spent / queries routed | Set budget cap; track by task type |
| Quality delta | Quality(small) − Quality(large) on same queries | <5% degradation acceptable in most cases |
| Escalation rate | % queries escalated to large model | Track; spike = classifier or threshold misconfigured |
| p95 routing latency | Time spent in router (not LLM) | <50ms; cache routing decisions for repeated queries |
| Fallback rate | % queries hitting secondary/tertiary | Target <2%; higher = primary instability |
### LLM Routing Design: [application name]
**Query volume:** [queries/day] | **Cost baseline (all-large):** [$/day]
**Quality floor:** [metric + threshold]
**Routing strategy:** [Static / Complexity classifier / Cascade / Cost-optimized / Semantic]
**Rationale:** [1-line]
**Model tier map**
| Task type | Estimated % | Routed to | Reason |
|---|---|---|---|
| [type 1] | [%] | [model tier] | [reason] |
| [type 2] | [%] | [model tier] | |
**Fallback chain**
Primary → [model] → Secondary → [model] → Tertiary → [model] → Error
**Failure handling**
| Failure | Action |
|---|---|
| Timeout (>[N]s) | Retry 1×; escalate |
| Rate limit | Queue or alternate provider |
| Quality below threshold | Escalate to next tier |
| Hard error | Skip to tertiary |
**Quality measurement**
| Signal | Method | Threshold |
|---|---|---|
| [primary signal] | [method] | [value] |
**Projected outcome**
| Metric | Baseline | After routing |
|---|---|---|
| Cost/day | [$] | [$] |
| Quality delta | — | [%] |
| Escalation rate | — | [%] |
**Recommendations**
[Key decisions and implementation order]
/bedrock-design/test-time-compute