OpenRouterTeam/ai-sdk-provider
The OpenRouter provider for the Vercel AI SDK contains support for hundreds of models through the OpenRouter chat and completion APIs.
What it solves
This project provides a bridge between the Vercel AI SDK and OpenRouter, allowing developers to access over 300 large language models and various embedding models through a single, standardized interface. It eliminates the need to write custom integration code for every individual model provider available on OpenRouter.
How it works
It acts as a provider instance for the Vercel AI SDK. By importing the openrouter provider, developers can specify OpenRouter model identifiers (e.g., openai/gpt-4o) within the SDK's standard functions like generateText, streamText, and embed. It supports advanced configuration options such as passing extra request bodies, enabling Anthropic-specific prompt caching and beta features (like fine-grained tool streaming), and integrating with OpenRouter-specific plugins like Response Healing.
Who it’s for
JavaScript and TypeScript developers using the Vercel AI SDK who want to easily switch between or utilize a vast array of different LLMs and embedding models without changing their core application logic.
Highlights
- Massive Model Access: Access to 300+ LLMs and multiple embedding models via one SDK.
- Structured Output Support: Integration with the Response Healing plugin to automatically repair malformed JSON responses.
- Advanced Model Control: Support for Anthropic prompt caching and fine-grained tool streaming for reduced latency in large JSON structures.
- Detailed Usage Tracking: Built-in support for usage accounting, including cost and token breakdown, including BYOK (Bring Your Own Key) scenarios.
- Debugging Tools: A debug mode that echoes the upstream request body to help troubleshoot API calls.
Related
- Project
- Project
- Project
- Project
- Project