Vercel AI SDK provider for OpenRouter's API
Top 83.7% on sourcepulse
This package provides a provider for the Vercel AI SDK, enabling access to over 300 large language models via the OpenRouter API. It is designed for developers building AI-powered applications who want to leverage a wide variety of models without managing individual API integrations.
How It Works
The provider integrates with the Vercel AI SDK's generateText
and streamText
functions. It abstracts the complexities of the OpenRouter API, allowing users to specify models by their OpenRouter identifier (e.g., openai/gpt-4o
). The provider supports passing extra body parameters to the OpenRouter API through multiple configuration options, including providerOptions.openrouter
, extraBody
in model settings, or extraBody
in the model factory. It also handles Anthropic-specific prompt caching configurations.
Quick Start & Requirements
npm install @openrouter/ai-sdk-provider
or pnpm add @openrouter/ai-sdk-provider
or yarn add @openrouter/ai-sdk-provider
Highlighted Details
Maintenance & Community
Licensing & Compatibility
Limitations & Caveats
The list of supported models is dynamic and may include models not compatible with the AI SDK. The license and commercial use terms are not clearly stated in the provided README.
2 days ago
1 week