ai-sdk-provider  by OpenRouterTeam

Vercel AI SDK provider for OpenRouter's API

created 1 year ago
332 stars

Top 83.7% on sourcepulse

GitHubView on GitHub
1 Expert Loves This Project
Project Summary

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

  • Install: npm install @openrouter/ai-sdk-provider or pnpm add @openrouter/ai-sdk-provider or yarn add @openrouter/ai-sdk-provider
  • Requires an OpenRouter API key.
  • Usage examples and documentation are available in the README.

Highlighted Details

  • Supports over 300 models through OpenRouter's chat and completion APIs.
  • Offers flexible methods for passing custom parameters to the OpenRouter API.
  • Includes support for Anthropic-specific message formatting and caching.

Maintenance & Community

  • Maintained by OpenRouterTeam.
  • Links to model lists and tool-supported model lists are provided in the README.

Licensing & Compatibility

  • The README does not explicitly state the license. Compatibility with commercial or closed-source projects is not specified.

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.

Health Check
Last commit

2 days ago

Responsiveness

1 week

Pull Requests (30d)
27
Issues (30d)
16
Star History
120 stars in the last 90 days

Explore Similar Projects

Feedback? Help us improve.