JavaScript LLM libraries

Updated Nov 2026

JavaScript LLM libraries send prompts to large language models and return their text, tool calls, and structured output to an application. A provider SDK calls one company's model API, while a toolkit wraps several providers behind one interface. These libraries connect the chat assistants, AI agents, and summarization features in web apps to the models behind them.

Popularity

Anthropic has the most monthly downloads in this comparison, at 261.6M.

LibraryMonthly downloadsStarsLast releaseLicense
Anthropic
261.6M
2.2KNov 2026Apache-2.0
OpenAI
223.6M
11.3KNov 2026Apache-2.0
AI SDK
172.3M
28.1KNov 2026Apache-2.0
Google Gen AI
120.4M
1.7KNov 2026Apache-2.0
@aws-sdk/client-bedrock-runtime
85.5M
3.7KNov 2026Apache-2.0
Mistral
27.0M
161Nov 2026Apache-2.0
@langchain/openai
19.9M
18.4KNov 2026MIT
Transformers.js
19.1M
16.4KOct 2026Apache-2.0
Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Libraries and code examples

Anthropic

Connects server-side JavaScript and TypeScript applications to the Claude API.

Downloads / mo
261.6M
Stars
2.2K
Last release
1.10.0
License
Apache-2.0

Strengths

  • Parses typed structured responses. Use schema helpers to validate and parse structured JSON responses.
  • Runs registered tool functions. Pass runnable functions to the beta toolRunner helper.

Limitations

  • Eager tools outlive interrupted replies. Defer non-repeatable calls with deferToolCall before they start.

Quickstart

From README.md
$ npm install @anthropic-ai/sdk
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic();
const message = await client.messages.create({
  model: "claude-opus-5-5", max_tokens: 128,
  messages: [{ role: "user", content: "Say hello." }],
});
console.log(message.content);

Provides TypeScript and JavaScript access to the OpenAI REST API.

Downloads / mo
223.6M
Stars
11.3K
Last release
7.60.0
License
Apache-2.0

Strengths

  • Parses schema-shaped response data. Use JSON Schema or Zod to define the expected response shape.
  • Counts inputs before generation. Use the input-token endpoint before sending a generation request.

Limitations

  • Response history needs complete output. Preserve reasoning and tool-call items, in order, between requests.
  • Refusals can bypass schema output. Handle refusals and incomplete responses before using structured fields.

Quickstart

From README.md
$ npm install openai
import OpenAI from "openai";

const client = new OpenAI();
const response = await client.responses.create({
  model: "gpt-5.5", input: "Say hello.",
});
console.log(response.output_text);

OpenAI examples

From open-source projects on GitHub

AI SDK

Generates and streams text from many model providers through one TypeScript toolkit.

Downloads / mo
172.3M
Stars
28.1K
Last release
7.0.177
License
Apache-2.0

Strengths

  • Works across UI frameworks. The toolkit runs in Next.js, React, Svelte, Vue, Angular, and Node.js.
  • Tools build on text generation. Tool calling and structured data generation build on the same text functions.

Quickstart

From Generating text docs
$ npm install ai @ai-sdk/openai
import { generateText } from "ai";
import { openai } from "@ai-sdk/openai";

const { text } = await generateText({
  model: openai("gpt-5.5"), prompt: "Say hello.",
});
console.log(text);

Google Gen AI

Uses one GoogleGenAI client interface for both supported Gemini services.

Downloads / mo
120.4M
Stars
1.7K
Last release
3.6.1
License
Apache-2.0

Strengths

  • Supports API-key and cloud authentication. Choose an API key or configure a cloud project and region.
  • Streams content as chunks. Consume generateContentStream with asynchronous iteration.

Limitations

  • Available APIs depend on backend. File APIs and image generation use different Google backends.
  • Schema mode supports a subset. Keep response schemas within Gemini’s supported JSON Schema subset.
  • Custom functions need application execution. Execute requested functions and return results to the model.

Quickstart

From README.md
$ npm install @google/genai
import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });
const response = await ai.models.generateContent({
  model: "gemini-3.8-flash", contents: "Say hello.",
});
console.log(response.text);

Google Gen AI examples

From open-source projects on GitHub

@aws-sdk/client-bedrock-runtime

Calls Amazon Bedrock models from Node.js, browsers, and React Native.

Downloads / mo
85.5M
Stars
3.7K
Last release
3.1172.0
License
Apache-2.0

Strengths

  • One interface across models. The Converse operation sends messages to any Bedrock model that supports them.

Limitations

  • Model-specific parameters pass through. Parameters unique to one model go to that model alongside the shared request fields.

Quickstart

From Converse API docs
$ npm install @aws-sdk/client-bedrock-runtime
import { BedrockRuntimeClient, ConverseCommand } from "@aws-sdk/client-bedrock-runtime";

const client = new BedrockRuntimeClient({ region: "us-east-1" });
const response = await client.send(new ConverseCommand({
  modelId: "amazon.nova-lite-v1:0",
  messages: [{ role: "user", content: [{ text: "Say hello." }] }],
}));
console.log(response.output?.message?.content);

@aws-sdk/client-bedrock-runtime examples

From open-source projects on GitHub

Calls the Mistral AI chat completion and embeddings APIs from TypeScript.

Downloads / mo
27.0M
Stars
161
Last release
3.5.0
License
Apache-2.0

Strengths

  • Streams server-sent events. Responses can stream to the application as server-sent events.

Quickstart

From README.md
$ npm install @mistralai/mistralai
import { Mistral } from "@mistralai/mistralai";

const client = new Mistral({ apiKey: process.env.MISTRAL_API_KEY });
const response = await client.chat.complete({
  model: "mistral-large-latest",
  messages: [{ role: "user", content: "Say hello." }],
});
console.log(response.choices?.[0]?.message.content);

Mistral examples

From open-source projects on GitHub

@langchain/openai

Connects OpenAI chat models to LangChain.js through the ChatOpenAI class.

Downloads / mo
19.9M
Stars
18.4K
Last release
1.8.4
License
MIT

Quickstart

From ChatOpenAI docs
$ npm install @langchain/openai @langchain/core
import { ChatOpenAI } from "@langchain/openai";

const model = new ChatOpenAI({ model: "gpt-5.4-mini" });
console.log((await model.invoke("Say hello.")).content);

@langchain/openai examples

From open-source projects on GitHub

Transformers.js

Runs pretrained Hugging Face models in the browser without a server.

Downloads / mo
19.1M
Stars
16.4K
Last release
4.3.2
License
Apache-2.0

Strengths

  • Mirrors the Python API. The same pretrained models run through an API close to the Python transformers library.

Quickstart

From Pipelines docs
$ npm install @huggingface/transformers
import { pipeline } from "@huggingface/transformers";

const generator = await pipeline("text-generation", "onnx-community/SmolLM2-135M-ONNX");
console.log(await generator("Once upon a time,", { max_new_tokens: 8 }));

Transformers.js examples

From open-source projects on GitHub

FAQ

AI SDK is a provider-agnostic TypeScript toolkit for AI applications and agents in Next.js, React, Svelte, Vue, Angular, and Node.js. Its generateText and streamText functions generate or stream text from a supported model.

Anthropic is the official TypeScript library for the Claude API in server-side JavaScript and TypeScript. Its toolRunner invokes runnable tool helpers that the application registers.

Converse sends messages to an Amazon Bedrock model through one interface that works with every model that supports messages. @aws-sdk/client-bedrock-runtime calls it from Node.js, browsers, and React Native.

OpenAI parses a model response into data shaped by a supplied schema. Refusals and incomplete responses still need handling in application code.

AI SDK generates and streams text from many providers through one TypeScript interface. @langchain/openai connects OpenAI chat models to LangChain.js.

Transformers.js runs pretrained Hugging Face models directly in the browser without a server. Its API mirrors the Python transformers library.

For coding agents

Found your LLM library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official