Multi-model AI cascade for structured output generation. Tries the fastest model first, falls back through the chain until a valid response is obtained.
Used in ryze-agent to power the verdict and analytics endpoints.
Claude Haiku → GLM 4.5 Air → DeepSeek R1 → DeepSeek V3
Fastest first. Cheapest first. Falls through only on timeout or invalid output.
import { cascade } from "ai-cascade";
const { result, model_used, latency_ms } = await cascade(
"Analyze this token: ...",
(r) => r.includes("signal")
);| Env var | Default | Description |
|---|---|---|
OPENROUTER_API_KEY |
— | Your OpenRouter API key |
CASCADE_TIMEOUT_MS |
8000 | Per-model timeout |
MIT