Vercel AI SDK
lcr("...") drops into every Vercel AI SDK call — generateText, streamText, generateObject, tools, and the Agent loop — unchanged.
lcr("...") returns a standard AI SDK LanguageModel, so it drops into every
AI SDK call: generateText, streamText, generateObject, streamObject,
tool calling, and the Agent loop.
import { streamText } from "ai";
const result = streamText({
model: lcr("smart"), // routed + fallback, same API
messages,
tools, // tool calling unaffected
});Because the routed model implements the same interface, streaming, structured output, and tools all keep working — a failover mid-stream is transparent to your code. See Migrate from plain AI SDK for the before/after on an existing call site.
Overview
lcr("...") returns a standard AI SDK model, so anything that accepts one works unchanged — the Vercel AI SDK itself, Mastra agents, and any framework built on the AI SDK.
Mastra
Mastra agents take a Vercel AI SDK model. ai-lcr returns one — so a Mastra agent gets cheapest-first routing and fallback by changing a single field.