Self-hosted inference server that serves embedding, reranking, OCR, extraction, safety and LLM models from one cluster through an OpenAI-compatible API.
OpenRouterTeam/ai-sdk-provider
A provider package that connects the Vercel AI SDK to OpenRouter, giving access to hundreds of LLMs through one API.
- Stars
- 695
- Forks
- 176
- Open issues
- 46
- Last commit
- 2 days ago
What is it?
This package is the OpenRouter provider for the Vercel AI SDK. It lets developers call hundreds of language models hosted on OpenRouter through the same AI SDK functions they already use, such as generateText and streamText, by switching the model argument to an OpenRouter model ID.
Beyond chat and completion, the package covers embeddings and reranking models, plus an experimental decision model for AI SDK evaluation. It also supports passing extra request fields to OpenRouter, sending image detail and video processing options for multimodal inputs, Anthropic prompt caching and beta headers, response healing for structured JSON output, and usage and cost accounting. The release line for AI SDK v7 requires Node.js 22 or newer and is ESM-only, and earlier releases remain available for AI SDK v5 and v6.
Key features
- 01Switch between hundreds of OpenRouter models by changing a single model ID.
- 02Provides embedding and reranking model interfaces for the AI SDK.
- 03Forwards extra request fields to OpenRouter via providerOptions or model settings.
- 04Supports image detail and video processing options for multimodal inputs.
- 05Includes Anthropic prompt caching and beta header support.
- 06Reports token usage and request cost in provider metadata.
Use cases
- Building a Next.js or Node.js app that lets users pick among many LLMs behind one integration.
- Adding semantic search or RAG features with embedding models through the AI SDK.
- Generating validated JSON output from models with response healing enabled.
- Tracking per-request cost and token usage in an AI-powered product.
Quick start
- 1
Install the package with npm
npm install @openrouter/ai-sdk-provider - 2
Import the default provider and call generateText with a model ID
Things to know
- Targets AI SDK v7 and requires Node.js 22 or newer.
- The package is ESM-only.
- The Decisions API used by the evaluation model is still in alpha and may change.
Topics
FAQ
- What is ai-sdk-provider?
- A provider package that connects the Vercel AI SDK to OpenRouter, giving access to hundreds of LLMs through one API. This package is the OpenRouter provider for the Vercel AI SDK. It lets developers call hundreds of language models hosted on OpenRouter through the same AI SDK functions they already use, such as generateText and streamText, by switching the model argument to an OpenRouter model ID.
- Is ai-sdk-provider free to use? What license does it have?
- ai-sdk-provider is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
- Is ai-sdk-provider still maintained?
- Actively maintained. The last commit to ai-sdk-provider was on Nov 4, 2026.
- What can I use ai-sdk-provider for?
- Building a Next.js or Node.js app that lets users pick among many LLMs behind one integration. Adding semantic search or RAG features with embedding models through the AI SDK. Generating validated JSON output from models with response healing enabled. Tracking per-request cost and token usage in an AI-powered product.
- How do I install ai-sdk-provider?
- Install the package with npm: npm install @openrouter/ai-sdk-provider Import the default provider and call generateText with a model ID
- Where can I get ai-sdk-provider?
- The source code and installation instructions are on GitHub: https://github.com/OpenRouterTeam/ai-sdk-provider
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A Rust/LibTorch serving engine that exposes embeddings, reranking, classification and typed decisions over a REST API.
Research code for QD-Rec, a quality-diversity method that evolves an archive of item-hypothesis pairs to produce diverse recommendations.
Open-source pipeline that renders web pages and PDFs as screenshots and retrieves them visually, so tables and charts survive for RAG.
A Rust-based embedding pipeline that ingests text, PDFs, images, audio and websites, generates embeddings locally or via cloud models, and streams them into vector databases.
An LLM plugin that gives the LLM command-line tool and Python library access to Google's Gemini models.