# JavaScript LLM libraries

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

| Library | Monthly downloads | Stars | Last release | License |
| --- | --- | --- | --- | --- |
| [Anthropic](#anthropic) | 261.6M | 2.2K | Nov 2026 | Apache-2.0 |
| [OpenAI](#openai) | 223.6M | 11.3K | Nov 2026 | Apache-2.0 |
| [AI SDK](#ai) | 172.3M | 28.1K | Nov 2026 | Apache-2.0 |
| [Google Gen AI](#googlegenai) | 120.4M | 1.7K | Nov 2026 | Apache-2.0 |
| [@aws-sdk/client-bedrock-runtime](#aws-sdk-client-bedrock-runtime) | 85.5M | 3.7K | Nov 2026 | Apache-2.0 |
| [Mistral](#mistralai-mistralai) | 27.0M | 161 | Nov 2026 | Apache-2.0 |
| [@langchain/openai](#langchain-openai) | 19.9M | 18.4K | Nov 2026 | MIT |
| [Transformers.js](#huggingface-transformers) | 19.1M | 16.4K | Oct 2026 | Apache-2.0 |

Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

[Anthropic](#anthropic) has the most monthly downloads in this comparison, at 261.6M.

## Capabilities

| Library | Bundled local model runtime | SDK-managed tool loop |
| --- | --- | --- |
| [Anthropic](#anthropic) | No | Yes |
| [OpenAI](#openai) | No | Yes |
| [AI SDK](#ai) | No | Yes |
| [Google Gen AI](#googlegenai) | No | Yes |
| [@aws-sdk/client-bedrock-runtime](#aws-sdk-client-bedrock-runtime) | No | Undocumented |
| [Mistral](#mistralai-mistralai) | No | Undocumented |
| [@langchain/openai](#langchain-openai) | No | No |
| [Transformers.js](#huggingface-transformers) | Yes | No |

## Libraries

### Anthropic

[GitHub](https://github.com/anthropics/anthropic-sdk-typescript) · [npm](https://www.npmjs.com/package/@anthropic-ai/sdk)

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
- Capabilities: [From the Anthropic docs](https://github.com/anthropics/anthropic-sdk-typescript)

**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.

**Watch out for**

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

```sh
npm install @anthropic-ai/sdk
```

**Quickstart**

```typescript
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);

```

From [README.md](https://platform.claude.com/docs/en/api/sdks/typescript) · [Find projects using Anthropic →](https://dashboard.exa.ai/playground/search?q=JavaScript%20applications%20using%20%40anthropic-ai/sdk%20native%20model%20generation%20response%20streams%20tool%20calls%20schemas%20token%20counting%20and%20local%20service%20clients&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

### OpenAI

[GitHub](https://github.com/openai/openai-node) · [npm](https://www.npmjs.com/package/openai)

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
- Capabilities: [From the OpenAI docs](https://github.com/openai/openai-node)

**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.

**Watch out for**

- **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.

```sh
npm install openai
```

**cline/cline** (71.7K stars)

[cline/cline](https://github.com/cline/cline) 

```typescript
private async *createResponseStreamHttp(
		modelInfo: ModelInfo,
		params: OpenAI.Responses.ResponseCreateParamsStreaming,
	): ApiStream {
		const client = this.ensureClient()
		Logger.debug(`OpenAI Responses Input (HTTP): ${JSON.stringify(params.input)}`)
		const stream = await client.responses.create(params, { signal: this.abortController?.signal })
		yield* this.processResponsesEvents(stream, modelInfo)
	}

```

[src/core/api/providers/openai-native.ts](https://github.com/cline/cline/blob/9dea336cedccc52024bb0dd1641b4e4e0a9bc7f4/src/core/api/providers/openai-native.ts#L266-L274) · [More projects using OpenAI →](https://dashboard.exa.ai/playground/search?q=JavaScript%20applications%20using%20openai%20native%20model%20generation%20response%20streams%20tool%20calls%20schemas%20token%20counting%20and%20local%20service%20clients&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```typescript
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);

```

From [README.md](https://github.com/openai/openai-node)

### AI SDK

[GitHub](https://github.com/vercel/ai) · [npm](https://www.npmjs.com/package/ai)

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
- Capabilities: [From the AI SDK docs](https://github.com/vercel/ai)

**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.

```sh
npm install ai @ai-sdk/openai
```

**Quickstart**

```javascript
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);

```

From [Generating text docs](https://ai-sdk.dev/providers/ai-sdk-providers/openai) · [Find projects using AI SDK →](https://dashboard.exa.ai/playground/search?q=ai%20GitHub%20projects)

### Google Gen AI

[GitHub](https://github.com/googleapis/js-genai) · [npm](https://www.npmjs.com/package/@google/genai)

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
- Capabilities: [From the Google Gen AI docs](https://github.com/googleapis/js-genai)

**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.

**Watch out for**

- **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.

```sh
npm install @google/genai
```

**open-multi-agent/open-multi-agent** (7.1K stars)

[open-multi-agent/open-multi-agent](https://github.com/open-multi-agent/open-multi-agent) 

```typescript
async chat(messages: LLMMessage[], options: LLMChatOptions): Promise<LLMResponse> {
    assertValidMessages(messages)
    const id = generateId()
    const contents = toGeminiContents(messages, options)

    const response = await this.#client.models.generateContent({
      model: options.model,
      contents,
      config: buildConfig(options),
    })

    return fromGeminiResponse(response, id, options.model)
  }

```

[packages/core/src/llm/gemini.ts](https://github.com/open-multi-agent/open-multi-agent/blob/ad07d8664b28ea60e8f4a1a5b12da9a7a3b9fc44/packages/core/src/llm/gemini.ts#L474-L486) · [More projects using Google Gen AI →](https://dashboard.exa.ai/playground/search?q=JavaScript%20applications%20using%20%40google/genai%20native%20model%20generation%20response%20streams%20tool%20calls%20schemas%20token%20counting%20and%20local%20service%20clients&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```typescript
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);

```

From [README.md](https://github.com/googleapis/js-genai)

### @aws-sdk/client-bedrock-runtime

[GitHub](https://github.com/aws/aws-sdk-js-v3) · [npm](https://www.npmjs.com/package/@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
- Capabilities: [From the @aws-sdk/client-bedrock-runtime docs](https://github.com/aws/aws-sdk-js-v3)

**Strengths**

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

**Watch out for**

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

```sh
npm install @aws-sdk/client-bedrock-runtime
```

**langchain-ai/langchainjs** (18.4K stars)

[langchain-ai/langchainjs](https://github.com/langchain-ai/langchainjs) 

```javascript
async _generateNonStreaming(
    messages: BaseMessage[],
    options: Partial<this["ParsedCallOptions"]>,
    _runManager?: CallbackManagerForLLMRun
  ): Promise<ChatResult> {
    try {
      const { converseMessages, converseSystem } =
        convertToConverseMessages(messages);
      const params = this.invocationParams(options);
      applyCachePointsToConversePayload({
        cacheControl: options.cache_control,
        system: converseSystem,
        messages: converseMessages,
        params,
        modelId: this.applicationInferenceProfile ?? this.model,
      });

      const command = new ConverseCommand({
        modelId: this.applicationInferenceProfile ?? this.model,
        messages: converseMessages,
        ...(Array.isArray(converseSystem) && converseSystem.length > 0
          ? { system: converseSystem }
          : {}),
        requestMetadata: options.requestMetadata,
        ...params,
      });
      const response = await this.caller.callWithOptions(
        { signal: options.signal, maxRetries: options.maxRetries },
        async () => {
          try {
            return await this.client.send(command, {
              abortSignal: options.signal,
            });
          } catch (error) {
            throw normalizeBedrockError(error);
          }
        }
      );
      const { output, ...responseMetadata } = response;
      if (!output?.message) {
        throw new Error("No message found in Bedrock response.");
      }

      const message = convertConverseMessageToLangChainMessage(
        output.message,
        responseMetadata
      );
      return {
        generations: [
          {
            text: typeof message.content === "string" ? message.content : "",
            message,
          },
        ],
      };
    } catch (error) {
      throw normalizeBedrockError(error);
    }
  }

```

[libs/providers/langchain-aws/src/chat_models.ts](https://github.com/langchain-ai/langchainjs/blob/7309848b94f1c9940197e3ebfc9a63bf508b3f15/libs/providers/langchain-aws/src/chat_models.ts#L1077-L1135) · [More projects using @aws-sdk/client-bedrock-runtime →](https://dashboard.exa.ai/playground/search?q=%40aws-sdk/client-bedrock-runtime%20GitHub%20projects)

**Quickstart**

```javascript
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);

```

From [Converse API docs](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_Converse.html)

### Mistral

[GitHub](https://github.com/mistralai/client-ts) · [npm](https://www.npmjs.com/package/@mistralai/mistralai)

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
- Capabilities: [From the Mistral docs](https://github.com/mistralai/client-ts)

**Strengths**

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

```sh
npm install @mistralai/mistralai
```

**mem0ai/mem0** (69.2K stars)

[mem0ai/mem0](https://github.com/mem0ai/mem0) 

```javascript
async generateChat(messages: Message[]): Promise<LLMResponse> {
    await this.ensureClient();
    const formattedMessages = messages.map((msg) => ({
      role: msg.role as "system" | "user" | "assistant",
      content:
        typeof msg.content === "string"
          ? msg.content
          : JSON.stringify(msg.content),
    }));

    const response = await this.client.chat.complete({
      model: this.model,
      messages: formattedMessages,
    });

    if (!response || !response.choices || response.choices.length === 0) {
      return {
        content: "",
        role: "assistant",
      };
    }

    const message = response.choices[0].message;

    return {
      content: this.contentToString(message.content),
      role: message.role || "assistant",
    };
  }

```

[mem0-ts/src/oss/src/llms/mistral.ts](https://github.com/mem0ai/mem0/blob/fff8a6472512d1bc1a4bccab8c645b65a1df7fe5/mem0-ts/src/oss/src/llms/mistral.ts#L95-L123) · [More projects using Mistral →](https://dashboard.exa.ai/playground/search?q=%40mistralai/mistralai%20GitHub%20projects)

**Quickstart**

```javascript
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);

```

From [README.md](https://github.com/mistralai/client-ts)

### @langchain/openai

[GitHub](https://github.com/langchain-ai/langchainjs) · [npm](https://www.npmjs.com/package/@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
- Capabilities: [From the @langchain/openai docs](https://github.com/langchain-ai/langchainjs)

```sh
npm install @langchain/openai @langchain/core
```

**CopilotKit/CopilotKit** (38.8K stars)

[CopilotKit/CopilotKit](https://github.com/CopilotKit/CopilotKit) 

```javascript
async function chatNode(state: AgentState, config: RunnableConfig) {
  const model = makeChatOpenAI(config, {
    model: REASONING_MODEL,
    useResponsesApi: true,
    reasoning: { effort: "low", summary: "auto" },
    // Token-level streaming of the OpenAI Responses API is buggy in
    // @langchain/openai@1.4.4: the reasoning-summary delta (index =
    // summary_index = 0) and the answer output_text delta (index =
    // content_index = 0) are pushed to the SAME content-block index, so the
    // streaming reducer collapses them into a single `type: "reasoning"`
    // block whose `text` field silently swallows the answer. @ag-ui/langgraph
    // then reads `content[0].type === "reasoning"` for every chunk and routes
    // the whole turn (answer included) to REASONING_MESSAGE_* events — no
    // assistant TEXT_MESSAGE ever renders, so the D6 reasoning-display probe
    // reds with `text-unstable`. The NON-streaming Responses converter
    // (`convertResponsesMessageToAIMessage`) processes final output *items*
    // (not indexed deltas) and correctly yields TWO separate blocks — a
    // `reasoning` block and a `text` block. Disabling token streaming forces
    // that correct path; the bridge then emits both a reasoning message and
    // the assistant answer, matching langgraph-python's rendering.
    disableStreaming: true,
  });

  const response = await model.invoke(
    [new SystemMessage({ content: SYSTEM_PROMPT }), ...state.messages],
    config,
  );

  return { messages: response };
}

```

[showcase/integrations/langgraph-typescript/src/agent/reasoning-agent.ts](https://github.com/CopilotKit/CopilotKit/blob/567211b7edff7dde57cfc9b617655344004253c0/showcase/integrations/langgraph-typescript/src/agent/reasoning-agent.ts#L54-L83) · [More projects using @langchain/openai →](https://dashboard.exa.ai/playground/search?q=%40langchain/openai%20GitHub%20projects)

**Quickstart**

```javascript
import { ChatOpenAI } from "@langchain/openai";

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

```

From [ChatOpenAI docs](https://docs.langchain.com/oss/javascript/integrations/chat/openai)

### Transformers.js

[GitHub](https://github.com/huggingface/transformers.js) · [npm](https://www.npmjs.com/package/@huggingface/transformers)

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
- Capabilities: [From the Transformers.js docs](https://github.com/huggingface/transformers.js)

**Strengths**

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

```sh
npm install @huggingface/transformers
```

**huggingface/transformers.js-examples** (2.1K stars)

[huggingface/transformers.js-examples](https://github.com/huggingface/transformers.js-examples) 

```javascript
async function generate(messages) {
  // Retrieve the text-generation pipeline.
  const [tokenizer, model] = await TextGenerationPipeline.getInstance();

  const inputs = tokenizer.apply_chat_template(messages, {
    add_generation_prompt: true,
    return_dict: true,
  });

  let startTime;
  let numTokens = 0;
  let tps;
  const token_callback_function = () => {
    startTime ??= performance.now();

    if (numTokens++ > 0) {
      tps = (numTokens / (performance.now() - startTime)) * 1000;
    }
  };
  const callback_function = (output) => {
    self.postMessage({
      status: "update",
      output,
      tps,
      numTokens,
    });
  };

  const streamer = new TextStreamer(tokenizer, {
    skip_prompt: true,
    skip_special_tokens: true,
    callback_function,
    token_callback_function,
  });

  // Tell the main thread we are starting
  self.postMessage({ status: "start" });

  const { past_key_values, sequences } = await model.generate({
    ...inputs,
    past_key_values: past_key_values_cache,

    // Sampling
    do_sample: false,

    max_new_tokens: 1024,
    streamer,
    stopping_criteria,
    return_dict_in_generate: true,
  });
  past_key_values_cache = past_key_values;

  const decoded = tokenizer.batch_decode(sequences, {
    skip_special_tokens: true,
  });

  // Send the output back to the main thread
  self.postMessage({
    status: "complete",
    output: decoded,
  });
}

```

[llama-3.2-webgpu/src/worker.js](https://github.com/huggingface/transformers.js-examples/blob/204b0948e88cd2bdc046316e78b754359653caea/llama-3.2-webgpu/src/worker.js#L32-L93) · [More projects using Transformers.js →](https://dashboard.exa.ai/playground/search?q=%40huggingface/transformers%20GitHub%20projects)

**Quickstart**

```javascript
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 }));

```

From [Pipelines docs](https://huggingface.co/docs/transformers.js/api/pipelines)

## FAQ

### What is the Vercel AI SDK?

[AI SDK](#ai) 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.

### What is the Anthropic SDK?

[Anthropic](#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.

### What is the Bedrock Converse API?

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

### How do OpenAI structured outputs work?

[OpenAI](#openai) parses a model response into data shaped by a supplied schema. Refusals and incomplete responses still need handling in application code.

### AI SDK vs LangChain: what is the difference?

[AI SDK](#ai) generates and streams text from many providers through one TypeScript interface. [@langchain/openai](#langchain-openai) connects OpenAI chat models to LangChain.js.

### What is Transformers.js?

[Transformers.js](#huggingface-transformers) runs pretrained Hugging Face models directly in the browser without a server. Its API mirrors the Python transformers library.

## How this page was built

Data checked Nov 20, 2026.

Reproduce it with the Exa API:

```json
{
  "endpoint": "/search",
  "body": {
    "query": "Best JavaScript LLM API client libraries OpenAI Anthropic Google GenAI Ollama streaming tools structured responses code examples",
    "numResults": 5
  }
}
```

Docs: https://exa.ai/docs/reference/search
