Skip to content
PluginStats

ai-sdk-llama-cpp weekly downloads statistics

By lgrammel · npm · AI SDKs

A minimal llama.cpp provider for the Vercel AI SDK implementing LanguageModelV3 and EmbeddingModelV3

View on npm Outdated · Nov 1, 2026

ai-sdk-llama-cpp has 188 recorded weekly downloads on npm, a decrease of 21.0% over the past 30 days, ranking #2512 of 3,247 tracked listings.

Weekly downloads
188
Official API · Dec 5, 2026
7-day growth
-61.8%
-304 weekly downloads
30-day growth
-21.0%
-50 weekly downloads
90-day growth
+7.4%
+13 weekly downloads
Rank
#2512
▼ 346 in 7 days

About ai-sdk-llama-cpp

ai-sdk-llama-cpp

Alpha Software - This package is in early development. The API may change between versions without notice.

macOS Only - This package currently only supports macOS with Apple Silicon or Intel processors.

A minimal llama.cpp provider for the Vercel AI SDK, implementing the LanguageModelV3 interface.

This package loads llama.cpp directly into Node.js memory via native C++ bindings, enabling local LLM inference without requiring an external server.

Features

  • Native Performance: Direct C++ bindings using node-addon-api (N-API)
  • GPU Acceleration: Automatic Metal support on macOS
  • Streaming & Non-streaming: Full support for both generateText and streamText
  • Structured Output: Generate JSON objects with schema validation using generateObject
  • Tool/Function Calling: Support for AI SDK tools with automatic tool call detection
  • Chat Templates: Automatic or configurable chat template formatting (llama3, chatml, gemma, etc.)
  • ESM Only: Modern ECMAScript modules, no CommonJS
  • GGUF Support: Load any GGUF-format model

Prerequisites

Before installing, ensure you have the following:

  • macOS (Apple Silicon or Intel)
  • Node.js >= 18.0.0
  • CMake >= 3.15
  • Xcode Command Line Tools
# Install Xcode Command Line Tools (includes Clang)
xcode-select --install

# Install CMake via Homebrew
brew install cmake

Installation

npm install ai-sdk-llama-cpp

The installation will automatically:

  1. Detect macOS and verify platform compatibility
  2. Compile llama.cpp as a static library with Metal support
  3. Build the native Node.js addon

Note: Installation on Windows or Linux will fail with an error. Only macOS is supported.

Usage

Basic Example
import { generateText } from "ai";
import { llamaCpp } from "ai-sdk-llama-cpp";

const model = llamaCpp({
  modelPath: "./models/llama-3.2-1b-instruct.Q4_K_M.gguf",
});

try {
  const { text } = await generateText({
    model,
    prompt: "Explain quantum computing in simple terms.",
  });

  console.log(text);
} finally {
  await model.dispose();
}
Streaming Example
import { streamText } from "ai";
import { llamaCpp } from "ai-sdk-llama-cpp";

const model = llamaCpp({
  modelPath: "./models/llama-3.2-1b-instruct.Q4_K_M.gguf",
});

try {
  const result = streamText({
    model,
    prompt: "Write a haiku about programming.",
  });

  for await (const chunk of result.textStream) {
    process.stdout.write(chunk);
  }
} finally {
  await model.dispose();
}
Structured Output

Generate type-safe JSON objects that conform to a schema using generateObject:

import { generateObject } from "ai";
import { z } from "zod";
import { llamaCpp } from "ai-sdk-llama-cpp";

const model = llamaCpp({
  modelPath: "./models/your-model.gguf",
});

try {
  const { object: recipe } = await generateObject({
    model,
    schema: z.object({
      name: z.string(),
      ingredients: z.array(
        z.object({
          name: z.string(),
          amount: z.string(),
        })
      ),
      steps: z.array(z.string()),
    }),
    prompt: "Generate a recipe for chocolate chip cookies.",
  });

  // recipe is fully typed as { name: string, ingredients: {...}[], steps: string[] }
  console.log(recipe.name);
  console.log(recipe.ingredients);
  console.log(recipe.steps);
} finally {
  await model.dispose();
}

The structured output feature uses GBNF grammar constraints to ensure the model generates valid JSON that conforms to your schema. This works with:

  • Primitive types: string, number, integer, boolean, null
  • Objects: With properties, required, and additionalProperties
  • Arrays: With items, minItems, maxItems
  • Enums and constants: enum, const
  • Composition: oneOf, anyOf, allOf
  • String constraints: minLength, maxLength, pattern
  • Number constraints: minimum, maximum (for integers)
  • String formats: date, time, date-time, uuid
  • References: Local $ref to $defs/definitions
Tool Calling Example

Use AI SDK tools with local models. The model decides when to call tools based on the conversation context:

import { generateText, stepCountIs, tool } from "ai";
import { z } from "zod";
import { llamaCpp } from "ai-sdk-llama-cpp";

const model = llamaCpp({
  modelPath: "./models/your-model.gguf",
});

try {
  const result = await generateText({
    model,
    prompt: "What's the weather in Tokyo?",
    tools: {
      weather: tool({
        description: "Get the current weather for a location",
        parameters: z.object({
          location: z.string().describe("The location to get weather for"),
        }),
        execute: async ({ location }) => ({
          location,
          temperature: 72,
        }),
      }),
    },
    stopWhen: stepCountIs(3), // Limit steps to prevent infinite loops
  });

  console.log(result.text);
} finally {
  await model.dispose();
}

Tool calling also works with streamText. When tools are provided, the provider automatically detects tool call JSON output and emits proper tool-call events instead of streaming raw JSON as text.

Note: Tool calling quality depends heavily on the model. Models fine-tuned for function calling (e.g., Llama 3.1+, Hermes 2/3, Functionary, Qwen 2.5) work best. Generic models may produce inconsistent results.

Embedding Example
import { embed, embedMany } from "ai";
import { llamaCpp } from "ai-sdk-llama-cpp";

const model = llamaCpp.embedding({
  modelPath: "./models/nomic-embed-text-v1.5.Q4_K_M.gguf",
});

try {
  const { embedding } = await embed({
    model,
    value: "Hello, world!",
  });…

Description from the npm listing.

  • ai
  • llama
  • llama.cpp
  • vercel
  • ai-sdk
  • language-model
  • gguf

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-sdk-llama-cpp weekly downloads on npm, last 90 days: 188 weekly downloads as of Dec 5, 2026, +7.4% over 90 days.ai-sdk-llama-cppWeekly downloads on npm · Last 90 days188downloads / week+7.4% over 90 days05001K1.5K2KSep 6Sep 21Oct 6Oct 21Nov 5Nov 20Dec 5downloads / weekobservedarchived (Internet Archive)no observationsSep 7, 2026 – Dec 5, 2026 · 90 observations · Updated Dec …pluginstats.com
ai-sdk-llama-cpp weekly downloads on npm, last 90 days: 188 weekly downloads as of Dec 5, 2026, +7.4% over 90 days.

7/30/90-day growth

ai-sdk-llama-cpp weekly downloads growth on npm: -61.8% over 7 days, -21.0% over 30 days, +7.4% over 90 days.ai-sdk-llama-cppWeekly downloads growth on npm188downloads / week now7-day growth-304 weekly downloads-61.8%30-day growth-50 weekly downloads-21.0%90-day growth+13 weekly downloads+7.4%Growth vs. nearest observation to each baseline date · Updated Dec 5, 2026pluginstats.com
ai-sdk-llama-cpp weekly downloads growth on npm: -61.8% over 7 days, -21.0% over 30 days, +7.4% over 90 days.

Ranking history

ai-sdk-llama-cpp npm ranking history: currently #2512 (by weekly downloads).ai-sdk-llama-cppnpm ranking · by weekly downloads · Last 90 days#2512current rank#1600#1800#2000#2200#2400#2600Sep 7Sep 22Oct 7Oct 22Nov 6Nov 21Dec 6rankOct 18, 2026 – Dec 6, 2026 · 24 observations · Updated Dec 5, 2026pluginstats.com
ai-sdk-llama-cpp npm ranking history: currently #2512 (by weekly downloads).

Listing placement

All npm3,247 listings · 163 pages · 1,083 shown · page 126, #12 (overall #2,512)
All npm: every listing in weekly downloads order

Listing placement

AI SDKs378 listings · 19 pages · page 16, #3 (overall #303)
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 (170)
Recent weekly downloads observations for ai-sdk-llama-cpp
Date (UTC)Weekly downloadsChange vs. previous
188-31
219-231
450-121
5710
571+49
522+11
511+19
492-20
512+243
269+133
136-6
142-32
174-2
176—

Similar npm AI SDKs plugins

All 20 ai-sdk-llama-cpp 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-sdk-llama-cpp. First seen Oct 16, 2026; last successful collection Nov 1, 2026. See the methodology.