Skip to main content

TypeScript API Reference

cascadeflow provides three TypeScript packages for different integration patterns.

Quick Start

Packages

Install

Core Concepts

Speculative execution — the cheaper model (drafter) runs first. If its response passes quality validation, cascadeflow returns it without calling the expensive model. If not, the verifier model runs as fallback. Quality validation — configurable confidence threshold, minimum token count, and optional semantic validation determine whether a draft is accepted. Cost tracking — every response includes totalCost and savingsPercentage so you can measure optimization impact.

Integration Patterns

Standalone Agent

Use @cascadeflow/core directly for full control:

Vercel AI SDK

Use @cascadeflow/vercel-ai for Next.js and Edge deployments:

LangChain

Use @cascadeflow/langchain for LCEL chains and pipelines:

Runtime Support

All packages work in Node.js, Browser, and Edge Functions (Vercel Edge, Cloudflare Workers).