Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@openrouter/ai-sdk-provider

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@openrouter/ai-sdk-provider

The [OpenRouter](https://openrouter.ai/) provider for the [Vercel AI SDK](https://sdk.vercel.ai/docs) contains 160+ language model support for the OpenRouter chat and completion APIs.

  • 0.0.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12K
increased by11.78%
Maintainers
0
Weekly downloads
 
Created
Source

OpenRouter Provider for Vercel AI SDK

The OpenRouter provider for the Vercel AI SDK contains 160+ language model support for the OpenRouter chat and completion APIs.

Setup

# For pnpm
pnpm add @openrouter/ai-sdk-provider

# For npm
npm install @openrouter/ai-sdk-provider

# For yarn
yarn add @openrouter/ai-sdk-provider

Provider Instance

You can import the default provider instance openrouter from @openrouter/ai-sdk-provider:

import { openrouter } from "@openrouter/ai-sdk-provider";

Example

import { openrouter } from "@openrouter/ai-sdk-provider";
import { generateText } from "ai";

const { text } = await generateText({
  model: openrouter("openai/gpt-4o"),
  prompt: "Write a vegetarian lasagna recipe for 4 people.",
});

Supported models

This list is not a definitive list of models supported by OpenRouter, as it constantly changes as we add new models (and deprecate old ones) to our system.
You can find the latest list of models supported by OpenRouter here.

ModelIDInput Price ($/1M tokens)Output Price ($/1M tokens)Context WindowModeration
Mistral: Mistral Nemomistralai/mistral-nemo$0.3$0.3128,000None
Mistral: Codestral Mambamistralai/codestral-mamba$0.25$0.25256,000None
OpenAI: GPT-4o-miniopenai/gpt-4o-mini$0.15$0.6128,000Moderated
OpenAI: GPT-4o-mini (2024-07-18)openai/gpt-4o-mini-2024-07-18$0.15$0.6128,000Moderated
Qwen 2 7B Instructqwen/qwen-2-7b-instruct$0.07$0.0732,768None
Google: Gemma 2 27Bgoogle/gemma-2-27b-it$0.27$0.278,192None
Nous: Hermes 2 Theta 8Bnousresearch/hermes-2-theta-llama-3-8b$0.1875 (25% off)$1.125 (25% off)16,384None
Magnum 72Balpindale/magnum-72b$3.75 (25% off)$4.5 (25% off)16,384None
Google: Gemma 2 9Bgoogle/gemma-2-9b-it$0.08$0.088,192None
Google: Gemma 2 9B (free)google/gemma-2-9b-it:free$0 (100% off)$0 (100% off)8,192None
Llama 3 Stheno 8B v3.3 32Ksao10k/l3-stheno-8b$0.25$1.532,000None
Flavor of The Weekopenrouter/flavor-of-the-week----32,000--
Yi Large01-ai/yi-large$3$332,768None
AI21: Jamba Instructai21/jamba-instruct$0.5$0.7256,000None
NVIDIA Nemotron-4 340B Instructnvidia/nemotron-4-340b-instruct$4.2$4.24,096None
Anthropic: Claude 3.5 Sonnetanthropic/claude-3.5-sonnet$3$15200,000Moderated
Anthropic: Claude 3.5 Sonnet (self-moderated)anthropic/claude-3.5-sonnet:beta$3$15200,000None
Llama 3 Euryale 70B v2.1sao10k/l3-euryale-70b$1.48$1.488,192None
Qwen 2 7B Instruct (free)qwen/qwen-2-7b-instruct:free$0 (100% off)$0 (100% off)32,768None
Phi-3 Medium 4K Instructmicrosoft/phi-3-medium-4k-instruct$0.14$0.144,000None
Dolphin 2.9.2 Mixtral 8x22B 🐬cognitivecomputations/dolphin-mixtral-8x22b$0.9$0.965,536None
Qwen 2 72B Instructqwen/qwen-2-72b-instruct$0.56$0.7732,768None
OpenChat 3.6 8Bopenchat/openchat-8b$0.064$0.0648,192None
Mistral: Mistral 7B Instructmistralai/mistral-7b-instruct$0.06$0.0632,768None
Mistral: Mistral 7B Instruct v0.3mistralai/mistral-7b-instruct-v0.3$0.06$0.0632,768None
NousResearch: Hermes 2 Pro - Llama-3 8Bnousresearch/hermes-2-pro-llama-3-8b$0.14$0.148,192None
Phi-3 Mini 128K Instructmicrosoft/phi-3-mini-128k-instruct$0.1$0.1128,000None
Phi-3 Mini 128K Instruct (free)microsoft/phi-3-mini-128k-instruct:free$0 (100% off)$0 (100% off)128,000None
Phi-3 Medium 128K Instructmicrosoft/phi-3-medium-128k-instruct$1$1128,000None
Phi-3 Medium 128K Instruct (free)microsoft/phi-3-medium-128k-instruct:free$0 (100% off)$0 (100% off)128,000None
Llama 3 Lumimaid 70Bneversleep/llama-3-lumimaid-70b$3.375 (25% off)$4.5 (25% off)8,192None
Google: Gemini Flash 1.5google/gemini-flash-1.5$0.25$0.752,800,000None
Perplexity: Llama3 Sonar 8Bperplexity/llama-3-sonar-small-32k-chat$0.2$0.232,768None
Perplexity: Llama3 Sonar 8B Onlineperplexity/llama-3-sonar-small-32k-online$0.2$0.228,000None
Perplexity: Llama3 Sonar 70Bperplexity/llama-3-sonar-large-32k-chat$1$132,768None
Perplexity: Llama3 Sonar 70B Onlineperplexity/llama-3-sonar-large-32k-online$1$128,000None
DeepSeek-V2 Chatdeepseek/deepseek-chat$0.14$0.28128,000None
DeepSeek-Coder-V2deepseek/deepseek-coder$0.14$0.28128,000None
OpenAI: GPT-4oopenai/gpt-4o$5$15128,000Moderated
OpenAI: GPT-4o (2024-05-13)openai/gpt-4o-2024-05-13$5$15128,000Moderated
Meta: Llama 3 8B (Base)meta-llama/llama-3-8b$0.18 (10% off)$0.18 (10% off)8,192None
Meta: Llama 3 70B (Base)meta-llama/llama-3-70b$0.81 (10% off)$0.81 (10% off)8,192None
Meta: LlamaGuard 2 8Bmeta-llama/llama-guard-2-8b$0.15$0.158,192None
OLMo 7B Instructallenai/olmo-7b-instruct$0.18 (10% off)$0.18 (10% off)2,048None
Qwen 1.5 110B Chatqwen/qwen-110b-chat$1.62 (10% off)$1.62 (10% off)32,768None
Qwen 1.5 72B Chatqwen/qwen-72b-chat$0.81 (10% off)$0.81 (10% off)32,768None
Qwen 1.5 32B Chatqwen/qwen-32b-chat$0.72 (10% off)$0.72 (10% off)32,768None
Qwen 1.5 14B Chatqwen/qwen-14b-chat$0.27 (10% off)$0.27 (10% off)32,768None
Qwen 1.5 7B Chatqwen/qwen-7b-chat$0.18 (10% off)$0.18 (10% off)32,768None
Qwen 1.5 4B Chatqwen/qwen-4b-chat$0.09 (10% off)$0.09 (10% off)32,768None
Meta: Llama 3 8B Instruct (free)meta-llama/llama-3-8b-instruct:free$0 (100% off)$0 (100% off)8,192None
Llama 3 Lumimaid 8Bneversleep/llama-3-lumimaid-8b$0.1875$1.12524,576None
Llama 3 Lumimaid 8B (extended)neversleep/llama-3-lumimaid-8b:extended$0.1875 (25% off)$1.125 (25% off)24,576None
Snowflake: Arctic Instructsnowflake/snowflake-arctic-instruct$2.16 (10% off)$2.16 (10% off)4,096None
FireLLaVA 13Bfireworks/firellava-13b$0.2$0.24,096None
Lynn: Llama 3 Soliloquy 8B v2lynn/soliloquy-l3$0.05$0.0524,576None
Fimbulvetr 11B v2sao10k/fimbulvetr-11b-v2$0.375 (25% off)$1.5 (25% off)8,192None
Meta: Llama 3 8B Instruct (extended)meta-llama/llama-3-8b-instruct:extended$0.1875 (25% off)$1.125 (25% off)16,384None
Meta: Llama 3 8B Instruct (nitro)meta-llama/llama-3-8b-instruct:nitro$0.18 (10% off)$0.18 (10% off)8,192None
Meta: Llama 3 70B Instruct (nitro)meta-llama/llama-3-70b-instruct:nitro$0.9$0.98,192None
Meta: Llama 3 8B Instructmeta-llama/llama-3-8b-instruct$0.06$0.068,192None
Meta: Llama 3 70B Instructmeta-llama/llama-3-70b-instruct$0.52$0.758,192None
Mistral: Mixtral 8x22B Instructmistralai/mixtral-8x22b-instruct$0.65$0.6565,536None
WizardLM-2 8x22Bmicrosoft/wizardlm-2-8x22b$0.63$0.6365,536None
WizardLM-2 7Bmicrosoft/wizardlm-2-7b$0.07$0.0732,000None
Toppy M 7B (nitro)undi95/toppy-m-7b:nitro$0.07$0.074,096None
Mistral: Mixtral 8x22B (base)mistralai/mixtral-8x22b$1.08 (10% off)$1.08 (10% off)65,536None
OpenAI: GPT-4 Turboopenai/gpt-4-turbo$10$30128,000Moderated
Google: Gemini Pro 1.5google/gemini-pro-1.5$2.5$7.52,800,000None
Cohere: Command R+cohere/command-r-plus$3$15128,000None
Databricks: DBRX 132B Instructdatabricks/dbrx-instruct$1.08 (10% off)$1.08 (10% off)32,768None
Midnight Rose 70Bsophosympatheia/midnight-rose-70b$0.8$0.84,096None
Cohere: Commandcohere/command$1$24,096None
Cohere: Command Rcohere/command-r$0.5$1.5128,000None
Anthropic: Claude 3 Haikuanthropic/claude-3-haiku$0.25$1.25200,000Moderated
Anthropic: Claude 3 Haiku (self-moderated)anthropic/claude-3-haiku:beta$0.25$1.25200,000None
Google: Gemma 7B (nitro)google/gemma-7b-it:nitro$0.07$0.078,192None
MythoMax 13B (nitro)gryphe/mythomax-l2-13b:nitro$0.2$0.24,096None
Anthropic: Claude 3 Opusanthropic/claude-3-opus$15$75200,000Moderated
Anthropic: Claude 3 Sonnetanthropic/claude-3-sonnet$3$15200,000Moderated
Anthropic: Claude 3 Opus (self-moderated)anthropic/claude-3-opus:beta$15$75200,000None
Anthropic: Claude 3 Sonnet (self-moderated)anthropic/claude-3-sonnet:beta$3$15200,000None
Mistral Largemistralai/mistral-large$8$2432,000None
Google: Gemma 7Bgoogle/gemma-7b-it$0.07$0.078,192None
Google: Gemma 7B (free)google/gemma-7b-it:free$0 (100% off)$0 (100% off)8,192None
Nous: Hermes 2 Mistral 7B DPOnousresearch/nous-hermes-2-mistral-7b-dpo$0.18 (10% off)$0.18 (10% off)8,192None
Meta: CodeLlama 70B Instructmeta-llama/codellama-70b-instruct$0.81 (10% off)$0.81 (10% off)2,048None
RWKV v5: Eagle 7Brecursal/eagle-7b$0$010,000None
OpenAI: GPT-3.5 Turbo (older v0613)openai/gpt-3.5-turbo-0613$1$24,095Moderated
OpenAI: GPT-4 Turbo Previewopenai/gpt-4-turbo-preview$10$30128,000Moderated
ReMM SLERP 13B (extended)undi95/remm-slerp-l2-13b:extended$1.125 (25% off)$1.125 (25% off)6,144None
Nous: Hermes 2 Mixtral 8x7B DPOnousresearch/nous-hermes-2-mixtral-8x7b-dpo$0.45$0.4532,768None
Nous: Hermes 2 Mixtral 8x7B SFTnousresearch/nous-hermes-2-mixtral-8x7b-sft$0.54 (10% off)$0.54 (10% off)32,768None
Mistral Tinymistralai/mistral-tiny$0.25$0.2532,000None
Mistral Smallmistralai/mistral-small$2$632,000None
Mistral Mediummistralai/mistral-medium$2.7$8.132,000None
Chronos Hermes 13B v2austism/chronos-hermes-13b$0.13$0.134,096None
Noromaid Mixtral 8x7B Instructneversleep/noromaid-mixtral-8x7b-instruct$8$88,000None
Nous: Hermes 2 Yi 34Bnousresearch/nous-hermes-yi-34b$0.72 (10% off)$0.72 (10% off)4,096None
Mistral: Mistral 7B Instruct v0.2mistralai/mistral-7b-instruct-v0.2$0.06$0.0632,768None
Dolphin 2.6 Mixtral 8x7B 🐬cognitivecomputations/dolphin-mixtral-8x7b$0.5$0.532,768None
Google: Gemini Pro 1.0google/gemini-pro$0.125$0.37591,728None
Google: Gemini Pro Vision 1.0google/gemini-pro-vision$0.125$0.37545,875None
Mixtral 8x7B (base)mistralai/mixtral-8x7b$0.54 (10% off)$0.54 (10% off)32,768None
Mixtral 8x7B Instructmistralai/mixtral-8x7b-instruct$0.24$0.2432,768None
RWKV v5 World 3Brwkv/rwkv-5-world-3b$0$010,000None
RWKV v5 3B AI Townrecursal/rwkv-5-3b-ai-town$0$010,000None
StripedHyena Nous 7Btogethercomputer/stripedhyena-nous-7b$0.18 (10% off)$0.18 (10% off)32,768None
StripedHyena Hessian 7B (base)togethercomputer/stripedhyena-hessian-7b$0.18 (10% off)$0.18 (10% off)32,768None
Psyfighter v2 13Bkoboldai/psyfighter-13b-2$1 (90% off)$1 (90% off)4,096None
Yi 34B Chat01-ai/yi-34b-chat$0.72 (10% off)$0.72 (10% off)4,096None
Yi 34B (base)01-ai/yi-34b$0.72 (10% off)$0.72 (10% off)4,096None
Yi 6B (base)01-ai/yi-6b$0.18 (10% off)$0.18 (10% off)4,096None
MythoMist 7Bgryphe/mythomist-7b$0.375 (25% off)$0.375 (25% off)32,768None
Nous: Capybara 7Bnousresearch/nous-capybara-7b$0.18 (10% off)$0.18 (10% off)8,192None
Nous: Capybara 7B (free)nousresearch/nous-capybara-7b:free$0 (100% off)$0 (100% off)8,192None
OpenChat 3.5 7Bopenchat/openchat-7b$0.07$0.078,192None
OpenChat 3.5 7B (free)openchat/openchat-7b:free$0 (100% off)$0 (100% off)8,192None
Noromaid 20Bneversleep/noromaid-20b$1.5 (25% off)$2.25 (25% off)8,192None
MythoMist 7B (free)gryphe/mythomist-7b:free$0 (100% off)$0 (100% off)32,768None
Neural Chat 7B v3.1intel/neural-chat-7b$5 (50% off)$5 (50% off)4,096None
Anthropic: Claude v2anthropic/claude-2$8$24200,000Moderated
Anthropic: Claude v2.1anthropic/claude-2.1$8$24200,000Moderated
Anthropic: Claude Instant v1.1anthropic/claude-instant-1.1$0.8$2.4100,000Moderated
Anthropic: Claude v2 (self-moderated)anthropic/claude-2:beta$8$24200,000None
Anthropic: Claude v2.1 (self-moderated)anthropic/claude-2.1:beta$8$24200,000None
OpenHermes 2.5 Mistral 7Bteknium/openhermes-2.5-mistral-7b$0.17$0.174,096None
OpenAI: GPT-4 Visionopenai/gpt-4-vision-preview$10$30128,000Moderated
lzlv 70Blizpreciatior/lzlv-70b-fp16-hf$0.58$0.784,096None
Toppy M 7Bundi95/toppy-m-7b$0.07$0.074,096None
Goliath 120Balpindale/goliath-120b$9.375 (25% off)$9.375 (25% off)6,144None
Toppy M 7B (free)undi95/toppy-m-7b:free$0 (100% off)$0 (100% off)4,096None
Auto (best for prompt)openrouter/auto----200,000--
OpenAI: GPT-3.5 Turbo 16k (older v1106)openai/gpt-3.5-turbo-1106$1$216,385Moderated
OpenAI: GPT-4 Turbo (older v1106)openai/gpt-4-1106-preview$10$30128,000Moderated
Hugging Face: Zephyr 7B (free)huggingfaceh4/zephyr-7b-beta:free$0 (100% off)$0 (100% off)4,096None
Google: PaLM 2 Chat 32kgoogle/palm-2-chat-bison-32k$0.25$0.591,750None
Google: PaLM 2 Code Chat 32kgoogle/palm-2-codechat-bison-32k$0.25$0.591,750None
OpenHermes 2 Mistral 7Bteknium/openhermes-2-mistral-7b$0.18 (10% off)$0.18 (10% off)8,192None
Mistral OpenOrca 7Bopen-orca/mistral-7b-openorca$0.18 (10% off)$0.18 (10% off)8,192None
Airoboros 70Bjondurbin/airoboros-l2-70b$0.5$0.54,096None
MythoMax 13B (extended)gryphe/mythomax-l2-13b:extended$1.125 (25% off)$1.125 (25% off)8,192None
Xwin 70Bxwin-lm/xwin-lm-70b$3.75 (25% off)$3.75 (25% off)8,192None
OpenAI: GPT-3.5 Turbo Instructopenai/gpt-3.5-turbo-instruct$1.5$24,095Moderated
Mistral: Mistral 7B Instruct v0.1mistralai/mistral-7b-instruct-v0.1$0.06$0.064,096None
Mistral: Mistral 7B Instruct (free)mistralai/mistral-7b-instruct:free$0 (100% off)$0 (100% off)32,768None
Pygmalion: Mythalion 13Bpygmalionai/mythalion-13b$1.125 (25% off)$1.125 (25% off)8,192None
OpenAI: GPT-3.5 Turbo 16kopenai/gpt-3.5-turbo-16k$3$416,385Moderated

Models with Tool Calling Capabilities Compatible with AI SDK

Last Update: 2024-08-19

This list is not a definitive list of tool-calling models supported by OpenRouter, as it constantly changes as we add new models (and deprecate old ones) to our system. You can find the latest list of tool-supported models supported by OpenRouter here. (Note: This list may contain models that are not compatible with the AI SDK.)

  • openai/gpt-3.5-turbo
  • openai/gpt-3.5-turbo-0125
  • openai/gpt-3.5-turbo-1106
  • openai/gpt-3.5-turbo-0613
  • openai/gpt-3.5-turbo-16k
  • openai/gpt-4o
  • openai/gpt-4o-2024-05-13
  • openai/gpt-4o-2024-08-06
  • openai/gpt-4o-mini
  • openai/gpt-4o-mini-2024-07-18
  • openai/gpt-4-turbo
  • openai/gpt-4-turbo-preview
  • openai/gpt-4-1106-preview
  • openai/gpt-4
  • openai/gpt-4-32k
  • openai/gpt-4-vision-preview
  • google/gemini-pro
  • google/gemini-pro-vision
  • google/gemini-pro-1.5
  • google/gemini-flash-1.5
  • mistralai/mistral-small
  • mistralai/mistral-large
  • 01-ai/yi-large-fc
  • anthropic/claude-3-opus
  • anthropic/claude-3-opus:beta
  • anthropic/claude-3-sonnet
  • anthropic/claude-3-sonnet:beta
  • anthropic/claude-3.5-sonnet
  • anthropic/claude-3.5-sonnet:beta
  • anthropic/claude-3-haiku
  • anthropic/claude-3-haiku:beta
  • meta-llama/llama-3-8b-instruct
  • mistralai/mixtral-8x22b-instruct

Passing Extra Body to OpenRouter

When you want to pass extra body to OpenRouter or to the upstream provider, you can do so by setting the extraBody property on the language model.

import { createOpenRouter } from "@ai-sdk/openrouter";

const provider = createOpenRouter({
  apiKey: "your-api-key",
  // Extra body to pass to OpenRouter
  extraBody: {
    custom_field: "custom_value",
    providers: {
      anthropic: {
        custom_field: "custom_value",
      },
    },
  },
});
const model = provider.chat("anthropic/claude-3.5-sonnet");
const response = await model.doStream({
  inputFormat: "prompt",
  mode: { type: "regular" },
  prompt: [{ role: "user", content: "Hello" }],
});

Keywords

FAQs

Package last updated on 21 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc