OpenRouter AI SDK Provider

The official OpenRouter provider for the Vercel AI SDK, unlocking 300+ LLMs through one unified TypeScript client.

SDK
npm
v3.1.0
690 stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
83 /100 Excellent
Development Activity 84
Maintenance 88
Community 72
Maturity 48
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
86 /100 Excellent
Architecture 86
Code Quality 85
Innovation 88
Learning Curve 82

OpenRouter AI SDK Provider is the official adapter that plugs OpenRouter into the Vercel AI SDK, giving your application a single, type-safe entry point to more than 300 large language models from OpenAI, Anthropic, Google, Meta, and dozens of other providers. Instead of wiring up a separate SDK for each vendor, you import one openrouter instance and pass a model id like openai/gpt-4o or anthropic/claude-sonnet-4 to the AI SDK’s generateText, streamText, generateObject, and embed functions.

Because it implements the AI SDK provider interface, it drops into any existing AI SDK codebase without new call patterns, while exposing OpenRouter-specific capabilities such as usage accounting, prompt caching, provider routing, response healing, and per-request extra body. It is ESM-only, ships full TypeScript types, and tracks the AI SDK v7 release line.

What You Get

  • A drop-in Vercel AI SDK provider that exposes 300+ models through one import
  • Full TypeScript type definitions and ESM-only, tree-shakeable output
  • Chat, completion, embedding, image, and video model factories under one client
  • OpenRouter-native features: usage accounting, prompt caching, provider routing, and response healing
  • Per-request and per-model extra body plus custom header passthrough for provider-specific options

Common Use Cases

  • Switching between LLM vendors without rewriting application code
  • Building streaming chat and agentic tool-use features on top of the AI SDK
  • Generating structured JSON output with schema validation and response healing
  • Powering RAG and semantic search with OpenRouter embedding models

Under The Hood

Architecture — The package is organized by modality: src/facade.ts exposes a deprecated OpenRouter class while src/provider.ts builds the modern createOpenRouter factory that returns a callable OpenRouterProvider (invoking it directly returns a chat model). Each modality lives in its own directory (chat, completion, embedding, image, video), and every factory constructs a language-model class (e.g. OpenRouterChatLanguageModel) with a shared base config that lazily assembles auth and app-identity headers via loadApiKey, injecting X-OpenRouter-Title, HTTP-Referer, and optional X-Provider-API-Keys. src/index.ts re-exports the facade, provider, and types.

Tech Stack — Written in TypeScript (99% of the codebase), it declares peer dependencies on ai@^7.0.0 and zod, and builds against @ai-sdk/provider and @ai-sdk/provider-utils. It is bundled with tsup, linted and formatted with Biome, tested with Vitest across node, edge, e2e, and issues configs, and released via Changesets with npm provenance. Output is ESM-only, side-effect-free, and requires Node.js 22+.

Code Quality — The repo carries roughly 21 in-tree unit tests plus around 56 end-to-end tests, exercising node and edge runtimes with MSW-based request mocking. Public options are documented with JSDoc, types are strict, and deprecated surfaces (the OpenRouter class, embedding()) are clearly annotated with forward pointers to their replacements.

API Design — The developer experience is deliberately minimal: import { openrouter } and call openrouter('openai/gpt-4o'), or createOpenRouter({ apiKey }) for configuration. Model ids are typed, provider-specific behavior flows through providerOptions.openrouter, extraBody, and headers at either the factory or request level, and because it conforms to the AI SDK provider contract, existing generateText/streamText/generateObject/embed code works with zero new call patterns.

Used by 25 apps in this directory

TypeScript
100%
Other

Activepieces

AI Assistants · Automation · Mcp

25,195

Open-source AI automation platform that converts 280+ workflow integrations into MCP servers for LLMs, with no-code builders and TypeScript extensibility.

View details
92
Repo Health
85
Technical
64
Dependency
Built with
TypeScript 100%
Updated yesterday
TypeScript
89%
MIT

Amical

AI Assistants · Note Taking · Voice AI

1,567

Local-first AI dictation that understands your active app — private, offline, and built for speed.

View details
81
Repo Health
82
Technical
67
Dependency
Built with
TypeScript 89%
Updated 1 weeks ago
Rust
44%
MIT

Anarlog

AI Assistants · Note Taking · Productivity

9,565

Anarlog is an open-source, local-first AI meeting notetaker that records, transcribes, and summarizes meetings entirely on your device — no cloud lock-in, no mandatory account, and every note saved as a plain markdown file you own forever.

View details
86
Repo Health
77
Technical
65
Dependency
Built with
Rust 44%
TypeScript 41%
Updated today
TypeScript
92%
GPL 3.0

Blinko

Knowledge Management · Note Taking

11,107

A self-hosted, AI-powered card note-taking tool that lets you capture fleeting thoughts instantly and retrieve them with natural language search.

View details
69
Repo Health
69
Technical
63
Dependency
Built with
TypeScript 92%
Updated 1 months ago
TypeScript
40%
AGPL 3.0

BrowserOS

AI Assistants · Browser

14,082

The open-source agentic Chromium browser with native AI agents, MCP server, and visual workflow automation — your data never leaves your machine.

View details
87
Repo Health
82
Technical
67
Dependency
Built with
TypeScript 40%
Rust 34%
Python 16%
Updated today
TypeScript
99%
Other

byterover-cli

AI Agents · AI Code Assistants · AI Memory

4,948

A portable memory layer for AI coding agents — curate structured project knowledge into a version-controlled context tree that syncs across tools, machines, and teammates.

View details
49
Repo Health
83
Technical
70
Dependency
Built with
TypeScript 99%
Updated 4 months ago
TypeScript
99%
AGPL 3.0

Cherry Studio

AI Assistants

52,928

All-in-one AI desktop client with 300+ assistants and multi-model support

View details
89
Repo Health
84
Technical
70
Dependency
Built with
TypeScript 99%
Updated today
TypeScript
72%
AGPL 3.0

Firecrawl

AI Development · Developer Tools

194,745

Turn any website into clean, LLM-ready data with a single API call — no proxy headaches, no scraping complexity.

View details
89
Repo Health
83
Technical
65
Dependency
Built with
TypeScript 72%
Python 12%
Updated today
TypeScript
79%
AGPL 3.0

Ghostfolio

Invoicing Finance

9,565

Track your stocks, ETFs, and crypto with a privacy-first, self-hostable wealth management platform built for data-driven investors.

View details
93
Repo Health
79
Technical
67
Dependency
Built with
TypeScript 79%
HTML 19%
Updated yesterday

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers