Skip to content
PluginStats

ai-lcr weekly downloads statistics

By ai-lcr · npm · AI SDKs

Least Cost Routing for LLMs — route every model call to the cheapest available provider, fall back automatically, and track real cost. Built for the Vercel AI SDK.

View on npm Fresh · Oct 29, 2026

ai-lcr has 832 recorded weekly downloads on npm, ranking #1592 of 2,667 tracked listings.

Weekly downloads
832
Official API · Oct 27, 2026
7-day growth
—
Insufficient history
30-day growth
—
Insufficient history
90-day growth
—
Insufficient history
Rank
#1592
Among tracked npm listings

About ai-lcr

AI-LCR — AI Least Cost Routing

<p align="center"> <b>English</b> · <a href="./README.zh-CN.md">简体中文</a> </p> <p align="center"> <b>Automatic least-cost routing for LLM calls. One line to cut your AI bill.</b> </p> <p align="center"> <a href="https://www.npmjs.com/package/ai-lcr"><img src="https://img.shields.io/npm/v/ai-lcr.svg" alt="npm version"/></a> <img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="MIT license"/> <a href="https://ai-sdk.dev"><img src="https://img.shields.io/badge/built%20for-Vercel%20AI%20SDK-black?logo=vercel&logoColor=white" alt="built for Vercel AI SDK"/></a> </p> <p align="center"> <img src="assets/ai-lcr-hero.svg" alt="ai-lcr routes DeepSeek V4.1 Flash through Tokenify at peak (50% less for fresh input), fails over to DeepSeek direct on error, and returns after recovery" width="720"> </p>

The same model costs different amounts on different providers — and no single provider is cheapest for everything. ai-lcr keeps a cheapest-first list per model, routes to the cheapest healthy one (⭐ below), and falls through on failure — the way phone carriers have done Least Cost Routing for decades.

Install

npm install ai-lcr

ai (the Vercel AI SDK) is a peer dependency.

Quick start

import { createLCR } from "ai-lcr";
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
import { generateText } from "ai";

const kunavo = createOpenAICompatible({
  name: "kunavo",
  baseURL: "https://api.kunavo.com/v1",
  apiKey: process.env.KUNAVO_API_KEY,
});
const openrouter = createOpenAICompatible({
  name: "openrouter",
  baseURL: "https://openrouter.ai/api/v1",
  apiKey: process.env.OPENROUTER_API_KEY,
});

const lcr = createLCR({
  autoSort: true, // sort each model's providers cheapest-first by `cost`
  models: {
    // One logical model, served cheapest-first across providers.
    "gemini-3-flash": [
      { model: kunavo("gemini-3-flash"), label: "kunavo", cost: { input: 0.40, output: 2.40 } },
      { model: openrouter("google/gemini-3-flash-preview"), label: "openrouter", cost: { input: 0.5, output: 3.0 } },
    ],
  },
  // See exactly what each call cost, on whichever provider served it.
  onCost: ({ provider, costUsd }) => console.log(`${provider}: $${costUsd.toFixed(6)}`),
});

const { text } = await generateText({
  model: lcr("gemini-3-flash"),
  prompt: "Explain Least Cost Routing in one sentence.",
});

cost and label are optional — pass bare models (kunavo("gemini-3-flash")) if you don't need cost accounting or autoSort. lcr("gemini-3-flash") returns a standard AI SDK model, so it works with generateText, streamText, generateObject, tools, and agents.

Route to a model vendor's own API (native providers)

A "provider" doesn't have to be an aggregator. A model vendor's own official API is just another entry in the list. Any AI SDK provider package returns a standard model, so a vendor's native API and an OpenAI-compatible reseller sit side by side in the same list:

import { createLCR, DEFAULT_PROVIDERS } from "ai-lcr";
import { createDeepSeek } from "@ai-sdk/deepseek";          // DeepSeek's own API
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";

const deepseek = createDeepSeek({ apiKey: process.env.DEEPSEEK_API_KEY });
const tokenify = createOpenAICompatible({
  name: "tokenify",
  baseURL: DEFAULT_PROVIDERS.tokenify.baseURL,
  apiKey: process.env[DEFAULT_PROVIDERS.tokenify.apiKeyEnv],
});

const lcr = createLCR({
  models: {
    "deepseek-v4.1-flash": [
      { model: tokenify("deepseek/deepseek-v4.1-flash"), label: "tokenify" },
      { model: deepseek("deepseek-flash"), label: "deepseek" },
    ],
  },
});

DeepSeek's official rates change between peak and off-peak hours. The example above favors Tokenify for V4.1 Flash, with direct access as a fallback. To attach the right price to every request, use createTimeRoutedModel with isDeepSeekPeak and two createLCR configurations with the matching DEEPSEEK_PRICES values; see the copyable Tokenify setup. Static autoSort alone cannot select by time of day.

The same pattern works for any vendor's native SDK provider — @ai-sdk/anthropic, @ai-sdk/google, @ai-sdk/openai, @ai-sdk/xai, and so on. ProviderEntry accepts AnyLanguageModel — a duck-typed interface (doGenerate + doStream + provider + modelId) that any AI SDK model satisfies regardless of spec version (V2 or V3), so you never need as-casts at the integration boundary. Native APIs are narrow (only that vendor's models) but featureful; aggregators are broad.

If you prefer the same "no copied env-var names" style as DEFAULT_PROVIDERS, use the optional native-provider loader. Install only the official SDKs you route to:

npm i @ai-sdk/anthropic
import { createLCR, createOfficialProvider } from "ai-lcr";

const anthropic = await createOfficialProvider("anthropic");

const lcr = createLCR({
  autoPrice: true,
  models: {
    "claude-sonnet": [
      { model: anthropic("claude-sonnet-4-6"), label: "anthropic" },
    ],
  },
});

Supported native keys: anthropic, openai, google, xai, mistral, deepseek, cohere, groq, perplexity, fireworks, togetherai, cerebras, azure, google-vertex, and amazon-bedrock. Their packages are optional peer dependencies, so unused vendors add no runtime requirement.…

Description from the npm listing.

  • ai
  • llm
  • vercel-ai-sdk
  • ai-sdk
  • router
  • least-cost-routing
  • lcr
  • fallback
  • openrouter
  • cost-optimization
  • openai-compatible

README badge

Show your rank in a README or on your website. The badge updates automatically.

Charts

Images: 30d · 1y · all time · 1600×900 dark

Adoption over time

ai-lcr weekly downloads on npm, last 90 days: 832 weekly downloads as of Oct 27, 2026.ai-lcrWeekly downloads on npm · Last 90 days832downloads / week740760780800820840860880900920Jul 29Aug 13Aug 28Sep 12Sep 27Oct 12Oct 27downloads / weekOct 27, 2026 – Oct 27, 2026 · 1 observations · Updated Oct 27, 2026pluginstats.com
ai-lcr weekly downloads on npm, last 90 days: 832 weekly downloads as of Oct 27, 2026.

7/30/90-day growth

ai-lcr weekly downloads growth on npm: 7-day growth unavailable, 30-day growth unavailable, 90-day growth unavailable.ai-lcrWeekly downloads growth on npm832downloads / week now7-day growthinsufficient historyInsufficient history30-day growthinsufficient historyInsufficient history90-day growthinsufficient historyInsufficient historyGrowth vs. nearest observation to each baseline date · Updated Oct 27, 2026pluginstats.com
ai-lcr weekly downloads growth on npm: 7-day growth unavailable, 30-day growth unavailable, 90-day growth unavailable.

Ranking history

ai-lcr npm ranking history: currently #1592 (by weekly downloads).ai-lcrnpm ranking · by weekly downloads · Last 90 days#1592current rank#1590#1591#1592#1593#1594Jul 31Aug 15Aug 30Sep 14Sep 29Oct 14Oct 29rankOct 29, 2026 – Oct 29, 2026 · 1 observations · Updated Oct 27, 2026pluginstats.com
ai-lcr npm ranking history: currently #1592 (by weekly downloads).

Listing placement

All npm2,667 listings · 134 pages · 1,334 shown · page 87, #11 (overall #1,731)
All npm: every listing in weekly downloads order

Listing placement

AI SDKs297 listings · 15 pages · page 10, #15 (overall #195)
AI SDKs: every listing in weekly downloads order

Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.

Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.

Recent observations

Full history (1)
Recent weekly downloads observations for ai-lcr
Date (UTC)Weekly downloadsChange vs. previous
832—

Similar npm AI SDKs plugins

All 20 ai-lcr alternatives

Data source

Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.

Listing: https://www.npmjs.com/package/ai-lcr. First seen Oct 29, 2026; last successful collection Oct 29, 2026. See the methodology.