@openrouter/ai-sdk-provider 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -213
- package/dist/index.d.mts +40 -41
- package/dist/index.d.ts +40 -41
- package/dist/index.js +16 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -14
- package/dist/index.mjs.map +1 -1
- package/internal/dist/index.d.mts +18 -19
- package/internal/dist/index.d.ts +18 -19
- package/internal/dist/index.js +16 -11
- package/internal/dist/index.js.map +1 -1
- package/internal/dist/index.mjs +17 -14
- package/internal/dist/index.mjs.map +1 -1
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# OpenRouter Provider for Vercel AI SDK
|
|
2
2
|
|
|
3
|
-
The [OpenRouter](https://openrouter.ai/) provider for the [Vercel AI SDK](https://sdk.vercel.ai/docs)
|
|
4
|
-
contains 160+ language model support for the OpenRouter chat and completion APIs.
|
|
3
|
+
The [OpenRouter](https://openrouter.ai/) provider for the [Vercel AI SDK](https://sdk.vercel.ai/docs) gives access to over 300 large language model on the OpenRouter chat and completion APIs.
|
|
5
4
|
|
|
6
5
|
## Setup
|
|
7
6
|
|
|
@@ -21,18 +20,18 @@ yarn add @openrouter/ai-sdk-provider
|
|
|
21
20
|
You can import the default provider instance `openrouter` from `@openrouter/ai-sdk-provider`:
|
|
22
21
|
|
|
23
22
|
```ts
|
|
24
|
-
import { openrouter } from
|
|
23
|
+
import { openrouter } from '@openrouter/ai-sdk-provider';
|
|
25
24
|
```
|
|
26
25
|
|
|
27
26
|
## Example
|
|
28
27
|
|
|
29
28
|
```ts
|
|
30
|
-
import { openrouter } from
|
|
31
|
-
import { generateText } from
|
|
29
|
+
import { openrouter } from '@openrouter/ai-sdk-provider';
|
|
30
|
+
import { generateText } from 'ai';
|
|
32
31
|
|
|
33
32
|
const { text } = await generateText({
|
|
34
|
-
model: openrouter(
|
|
35
|
-
prompt:
|
|
33
|
+
model: openrouter('openai/gpt-4o'),
|
|
34
|
+
prompt: 'Write a vegetarian lasagna recipe for 4 people.',
|
|
36
35
|
});
|
|
37
36
|
```
|
|
38
37
|
|
|
@@ -41,229 +40,31 @@ const { text } = await generateText({
|
|
|
41
40
|
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.
|
|
42
41
|
You can find the latest list of models supported by OpenRouter [here](https://openrouter.ai/models).
|
|
43
42
|
|
|
44
|
-
| Model | ID | Input Price ($/1M tokens) | Output Price ($/1M tokens) | Context Window | Moderation |
|
|
45
|
-
| -------------------------------------------------------------------------------------------------------------- | ------------------------------------------- | ------------------------- | -------------------------- | -------------- | ---------- |
|
|
46
|
-
| [Mistral: Mistral Nemo](https://openrouter.ai/models/mistralai/mistral-nemo) | mistralai/mistral-nemo | $0.3 | $0.3 | 128,000 | None |
|
|
47
|
-
| [Mistral: Codestral Mamba](https://openrouter.ai/models/mistralai/codestral-mamba) | mistralai/codestral-mamba | $0.25 | $0.25 | 256,000 | None |
|
|
48
|
-
| [OpenAI: GPT-4o-mini](https://openrouter.ai/models/openai/gpt-4o-mini) | openai/gpt-4o-mini | $0.15 | $0.6 | 128,000 | Moderated |
|
|
49
|
-
| [OpenAI: GPT-4o-mini (2024-07-18)](https://openrouter.ai/models/openai/gpt-4o-mini-2024-07-18) | openai/gpt-4o-mini-2024-07-18 | $0.15 | $0.6 | 128,000 | Moderated |
|
|
50
|
-
| [Qwen 2 7B Instruct](https://openrouter.ai/models/qwen/qwen-2-7b-instruct) | qwen/qwen-2-7b-instruct | $0.07 | $0.07 | 32,768 | None |
|
|
51
|
-
| [Google: Gemma 2 27B](https://openrouter.ai/models/google/gemma-2-27b-it) | google/gemma-2-27b-it | $0.27 | $0.27 | 8,192 | None |
|
|
52
|
-
| [Nous: Hermes 2 Theta 8B](https://openrouter.ai/models/nousresearch/hermes-2-theta-llama-3-8b) | nousresearch/hermes-2-theta-llama-3-8b | $0.1875 (25% off) | $1.125 (25% off) | 16,384 | None |
|
|
53
|
-
| [Magnum 72B](https://openrouter.ai/models/alpindale/magnum-72b) | alpindale/magnum-72b | $3.75 (25% off) | $4.5 (25% off) | 16,384 | None |
|
|
54
|
-
| [Google: Gemma 2 9B](https://openrouter.ai/models/google/gemma-2-9b-it) | google/gemma-2-9b-it | $0.08 | $0.08 | 8,192 | None |
|
|
55
|
-
| [Google: Gemma 2 9B (free)](https://openrouter.ai/models/google/gemma-2-9b-it:free) | google/gemma-2-9b-it:free | $0 (100% off) | $0 (100% off) | 8,192 | None |
|
|
56
|
-
| [Llama 3 Stheno 8B v3.3 32K](https://openrouter.ai/models/sao10k/l3-stheno-8b) | sao10k/l3-stheno-8b | $0.25 | $1.5 | 32,000 | None |
|
|
57
|
-
| [Flavor of The Week](https://openrouter.ai/models/openrouter/flavor-of-the-week) | openrouter/flavor-of-the-week | -- | -- | 32,000 | -- |
|
|
58
|
-
| [Yi Large](https://openrouter.ai/models/01-ai/yi-large) | 01-ai/yi-large | $3 | $3 | 32,768 | None |
|
|
59
|
-
| [AI21: Jamba Instruct](https://openrouter.ai/models/ai21/jamba-instruct) | ai21/jamba-instruct | $0.5 | $0.7 | 256,000 | None |
|
|
60
|
-
| [NVIDIA Nemotron-4 340B Instruct](https://openrouter.ai/models/nvidia/nemotron-4-340b-instruct) | nvidia/nemotron-4-340b-instruct | $4.2 | $4.2 | 4,096 | None |
|
|
61
|
-
| [Anthropic: Claude 3.5 Sonnet](https://openrouter.ai/models/anthropic/claude-3.5-sonnet) | anthropic/claude-3.5-sonnet | $3 | $15 | 200,000 | Moderated |
|
|
62
|
-
| [Anthropic: Claude 3.5 Sonnet (self-moderated)](https://openrouter.ai/models/anthropic/claude-3.5-sonnet:beta) | anthropic/claude-3.5-sonnet:beta | $3 | $15 | 200,000 | None |
|
|
63
|
-
| [Llama 3 Euryale 70B v2.1](https://openrouter.ai/models/sao10k/l3-euryale-70b) | sao10k/l3-euryale-70b | $1.48 | $1.48 | 8,192 | None |
|
|
64
|
-
| [Qwen 2 7B Instruct (free)](https://openrouter.ai/models/qwen/qwen-2-7b-instruct:free) | qwen/qwen-2-7b-instruct:free | $0 (100% off) | $0 (100% off) | 32,768 | None |
|
|
65
|
-
| [Phi-3 Medium 4K Instruct](https://openrouter.ai/models/microsoft/phi-3-medium-4k-instruct) | microsoft/phi-3-medium-4k-instruct | $0.14 | $0.14 | 4,000 | None |
|
|
66
|
-
| [Dolphin 2.9.2 Mixtral 8x22B 🐬](https://openrouter.ai/models/cognitivecomputations/dolphin-mixtral-8x22b) | cognitivecomputations/dolphin-mixtral-8x22b | $0.9 | $0.9 | 65,536 | None |
|
|
67
|
-
| [Qwen 2 72B Instruct](https://openrouter.ai/models/qwen/qwen-2-72b-instruct) | qwen/qwen-2-72b-instruct | $0.56 | $0.77 | 32,768 | None |
|
|
68
|
-
| [OpenChat 3.6 8B](https://openrouter.ai/models/openchat/openchat-8b) | openchat/openchat-8b | $0.064 | $0.064 | 8,192 | None |
|
|
69
|
-
| [Mistral: Mistral 7B Instruct](https://openrouter.ai/models/mistralai/mistral-7b-instruct) | mistralai/mistral-7b-instruct | $0.06 | $0.06 | 32,768 | None |
|
|
70
|
-
| [Mistral: Mistral 7B Instruct v0.3](https://openrouter.ai/models/mistralai/mistral-7b-instruct-v0.3) | mistralai/mistral-7b-instruct-v0.3 | $0.06 | $0.06 | 32,768 | None |
|
|
71
|
-
| [NousResearch: Hermes 2 Pro - Llama-3 8B](https://openrouter.ai/models/nousresearch/hermes-2-pro-llama-3-8b) | nousresearch/hermes-2-pro-llama-3-8b | $0.14 | $0.14 | 8,192 | None |
|
|
72
|
-
| [Phi-3 Mini 128K Instruct](https://openrouter.ai/models/microsoft/phi-3-mini-128k-instruct) | microsoft/phi-3-mini-128k-instruct | $0.1 | $0.1 | 128,000 | None |
|
|
73
|
-
| [Phi-3 Mini 128K Instruct (free)](https://openrouter.ai/models/microsoft/phi-3-mini-128k-instruct:free) | microsoft/phi-3-mini-128k-instruct:free | $0 (100% off) | $0 (100% off) | 128,000 | None |
|
|
74
|
-
| [Phi-3 Medium 128K Instruct](https://openrouter.ai/models/microsoft/phi-3-medium-128k-instruct) | microsoft/phi-3-medium-128k-instruct | $1 | $1 | 128,000 | None |
|
|
75
|
-
| [Phi-3 Medium 128K Instruct (free)](https://openrouter.ai/models/microsoft/phi-3-medium-128k-instruct:free) | microsoft/phi-3-medium-128k-instruct:free | $0 (100% off) | $0 (100% off) | 128,000 | None |
|
|
76
|
-
| [Llama 3 Lumimaid 70B](https://openrouter.ai/models/neversleep/llama-3-lumimaid-70b) | neversleep/llama-3-lumimaid-70b | $3.375 (25% off) | $4.5 (25% off) | 8,192 | None |
|
|
77
|
-
| [Google: Gemini Flash 1.5](https://openrouter.ai/models/google/gemini-flash-1.5) | google/gemini-flash-1.5 | $0.25 | $0.75 | 2,800,000 | None |
|
|
78
|
-
| [Perplexity: Llama3 Sonar 8B](https://openrouter.ai/models/perplexity/llama-3-sonar-small-32k-chat) | perplexity/llama-3-sonar-small-32k-chat | $0.2 | $0.2 | 32,768 | None |
|
|
79
|
-
| [Perplexity: Llama3 Sonar 8B Online](https://openrouter.ai/models/perplexity/llama-3-sonar-small-32k-online) | perplexity/llama-3-sonar-small-32k-online | $0.2 | $0.2 | 28,000 | None |
|
|
80
|
-
| [Perplexity: Llama3 Sonar 70B](https://openrouter.ai/models/perplexity/llama-3-sonar-large-32k-chat) | perplexity/llama-3-sonar-large-32k-chat | $1 | $1 | 32,768 | None |
|
|
81
|
-
| [Perplexity: Llama3 Sonar 70B Online](https://openrouter.ai/models/perplexity/llama-3-sonar-large-32k-online) | perplexity/llama-3-sonar-large-32k-online | $1 | $1 | 28,000 | None |
|
|
82
|
-
| [DeepSeek-V2 Chat](https://openrouter.ai/models/deepseek/deepseek-chat) | deepseek/deepseek-chat | $0.14 | $0.28 | 128,000 | None |
|
|
83
|
-
| [DeepSeek-Coder-V2](https://openrouter.ai/models/deepseek/deepseek-coder) | deepseek/deepseek-coder | $0.14 | $0.28 | 128,000 | None |
|
|
84
|
-
| [OpenAI: GPT-4o](https://openrouter.ai/models/openai/gpt-4o) | openai/gpt-4o | $5 | $15 | 128,000 | Moderated |
|
|
85
|
-
| [OpenAI: GPT-4o (2024-05-13)](https://openrouter.ai/models/openai/gpt-4o-2024-05-13) | openai/gpt-4o-2024-05-13 | $5 | $15 | 128,000 | Moderated |
|
|
86
|
-
| [Meta: Llama 3 8B (Base)](https://openrouter.ai/models/meta-llama/llama-3-8b) | meta-llama/llama-3-8b | $0.18 (10% off) | $0.18 (10% off) | 8,192 | None |
|
|
87
|
-
| [Meta: Llama 3 70B (Base)](https://openrouter.ai/models/meta-llama/llama-3-70b) | meta-llama/llama-3-70b | $0.81 (10% off) | $0.81 (10% off) | 8,192 | None |
|
|
88
|
-
| [Meta: LlamaGuard 2 8B](https://openrouter.ai/models/meta-llama/llama-guard-2-8b) | meta-llama/llama-guard-2-8b | $0.15 | $0.15 | 8,192 | None |
|
|
89
|
-
| [OLMo 7B Instruct](https://openrouter.ai/models/allenai/olmo-7b-instruct) | allenai/olmo-7b-instruct | $0.18 (10% off) | $0.18 (10% off) | 2,048 | None |
|
|
90
|
-
| [Qwen 1.5 110B Chat](https://openrouter.ai/models/qwen/qwen-110b-chat) | qwen/qwen-110b-chat | $1.62 (10% off) | $1.62 (10% off) | 32,768 | None |
|
|
91
|
-
| [Qwen 1.5 72B Chat](https://openrouter.ai/models/qwen/qwen-72b-chat) | qwen/qwen-72b-chat | $0.81 (10% off) | $0.81 (10% off) | 32,768 | None |
|
|
92
|
-
| [Qwen 1.5 32B Chat](https://openrouter.ai/models/qwen/qwen-32b-chat) | qwen/qwen-32b-chat | $0.72 (10% off) | $0.72 (10% off) | 32,768 | None |
|
|
93
|
-
| [Qwen 1.5 14B Chat](https://openrouter.ai/models/qwen/qwen-14b-chat) | qwen/qwen-14b-chat | $0.27 (10% off) | $0.27 (10% off) | 32,768 | None |
|
|
94
|
-
| [Qwen 1.5 7B Chat](https://openrouter.ai/models/qwen/qwen-7b-chat) | qwen/qwen-7b-chat | $0.18 (10% off) | $0.18 (10% off) | 32,768 | None |
|
|
95
|
-
| [Qwen 1.5 4B Chat](https://openrouter.ai/models/qwen/qwen-4b-chat) | qwen/qwen-4b-chat | $0.09 (10% off) | $0.09 (10% off) | 32,768 | None |
|
|
96
|
-
| [Meta: Llama 3 8B Instruct (free)](https://openrouter.ai/models/meta-llama/llama-3-8b-instruct:free) | meta-llama/llama-3-8b-instruct:free | $0 (100% off) | $0 (100% off) | 8,192 | None |
|
|
97
|
-
| [Llama 3 Lumimaid 8B](https://openrouter.ai/models/neversleep/llama-3-lumimaid-8b) | neversleep/llama-3-lumimaid-8b | $0.1875 | $1.125 | 24,576 | None |
|
|
98
|
-
| [Llama 3 Lumimaid 8B (extended)](https://openrouter.ai/models/neversleep/llama-3-lumimaid-8b:extended) | neversleep/llama-3-lumimaid-8b:extended | $0.1875 (25% off) | $1.125 (25% off) | 24,576 | None |
|
|
99
|
-
| [Snowflake: Arctic Instruct](https://openrouter.ai/models/snowflake/snowflake-arctic-instruct) | snowflake/snowflake-arctic-instruct | $2.16 (10% off) | $2.16 (10% off) | 4,096 | None |
|
|
100
|
-
| [FireLLaVA 13B](https://openrouter.ai/models/fireworks/firellava-13b) | fireworks/firellava-13b | $0.2 | $0.2 | 4,096 | None |
|
|
101
|
-
| [Lynn: Llama 3 Soliloquy 8B v2](https://openrouter.ai/models/lynn/soliloquy-l3) | lynn/soliloquy-l3 | $0.05 | $0.05 | 24,576 | None |
|
|
102
|
-
| [Fimbulvetr 11B v2](https://openrouter.ai/models/sao10k/fimbulvetr-11b-v2) | sao10k/fimbulvetr-11b-v2 | $0.375 (25% off) | $1.5 (25% off) | 8,192 | None |
|
|
103
|
-
| [Meta: Llama 3 8B Instruct (extended)](https://openrouter.ai/models/meta-llama/llama-3-8b-instruct:extended) | meta-llama/llama-3-8b-instruct:extended | $0.1875 (25% off) | $1.125 (25% off) | 16,384 | None |
|
|
104
|
-
| [Meta: Llama 3 8B Instruct (nitro)](https://openrouter.ai/models/meta-llama/llama-3-8b-instruct:nitro) | meta-llama/llama-3-8b-instruct:nitro | $0.18 (10% off) | $0.18 (10% off) | 8,192 | None |
|
|
105
|
-
| [Meta: Llama 3 70B Instruct (nitro)](https://openrouter.ai/models/meta-llama/llama-3-70b-instruct:nitro) | meta-llama/llama-3-70b-instruct:nitro | $0.9 | $0.9 | 8,192 | None |
|
|
106
|
-
| [Meta: Llama 3 8B Instruct](https://openrouter.ai/models/meta-llama/llama-3-8b-instruct) | meta-llama/llama-3-8b-instruct | $0.06 | $0.06 | 8,192 | None |
|
|
107
|
-
| [Meta: Llama 3 70B Instruct](https://openrouter.ai/models/meta-llama/llama-3-70b-instruct) | meta-llama/llama-3-70b-instruct | $0.52 | $0.75 | 8,192 | None |
|
|
108
|
-
| [Mistral: Mixtral 8x22B Instruct](https://openrouter.ai/models/mistralai/mixtral-8x22b-instruct) | mistralai/mixtral-8x22b-instruct | $0.65 | $0.65 | 65,536 | None |
|
|
109
|
-
| [WizardLM-2 8x22B](https://openrouter.ai/models/microsoft/wizardlm-2-8x22b) | microsoft/wizardlm-2-8x22b | $0.63 | $0.63 | 65,536 | None |
|
|
110
|
-
| [WizardLM-2 7B](https://openrouter.ai/models/microsoft/wizardlm-2-7b) | microsoft/wizardlm-2-7b | $0.07 | $0.07 | 32,000 | None |
|
|
111
|
-
| [Toppy M 7B (nitro)](https://openrouter.ai/models/undi95/toppy-m-7b:nitro) | undi95/toppy-m-7b:nitro | $0.07 | $0.07 | 4,096 | None |
|
|
112
|
-
| [Mistral: Mixtral 8x22B (base)](https://openrouter.ai/models/mistralai/mixtral-8x22b) | mistralai/mixtral-8x22b | $1.08 (10% off) | $1.08 (10% off) | 65,536 | None |
|
|
113
|
-
| [OpenAI: GPT-4 Turbo](https://openrouter.ai/models/openai/gpt-4-turbo) | openai/gpt-4-turbo | $10 | $30 | 128,000 | Moderated |
|
|
114
|
-
| [Google: Gemini Pro 1.5](https://openrouter.ai/models/google/gemini-pro-1.5) | google/gemini-pro-1.5 | $2.5 | $7.5 | 2,800,000 | None |
|
|
115
|
-
| [Cohere: Command R+](https://openrouter.ai/models/cohere/command-r-plus) | cohere/command-r-plus | $3 | $15 | 128,000 | None |
|
|
116
|
-
| [Databricks: DBRX 132B Instruct](https://openrouter.ai/models/databricks/dbrx-instruct) | databricks/dbrx-instruct | $1.08 (10% off) | $1.08 (10% off) | 32,768 | None |
|
|
117
|
-
| [Midnight Rose 70B](https://openrouter.ai/models/sophosympatheia/midnight-rose-70b) | sophosympatheia/midnight-rose-70b | $0.8 | $0.8 | 4,096 | None |
|
|
118
|
-
| [Cohere: Command](https://openrouter.ai/models/cohere/command) | cohere/command | $1 | $2 | 4,096 | None |
|
|
119
|
-
| [Cohere: Command R](https://openrouter.ai/models/cohere/command-r) | cohere/command-r | $0.5 | $1.5 | 128,000 | None |
|
|
120
|
-
| [Anthropic: Claude 3 Haiku](https://openrouter.ai/models/anthropic/claude-3-haiku) | anthropic/claude-3-haiku | $0.25 | $1.25 | 200,000 | Moderated |
|
|
121
|
-
| [Anthropic: Claude 3 Haiku (self-moderated)](https://openrouter.ai/models/anthropic/claude-3-haiku:beta) | anthropic/claude-3-haiku:beta | $0.25 | $1.25 | 200,000 | None |
|
|
122
|
-
| [Google: Gemma 7B (nitro)](https://openrouter.ai/models/google/gemma-7b-it:nitro) | google/gemma-7b-it:nitro | $0.07 | $0.07 | 8,192 | None |
|
|
123
|
-
| [MythoMax 13B (nitro)](https://openrouter.ai/models/gryphe/mythomax-l2-13b:nitro) | gryphe/mythomax-l2-13b:nitro | $0.2 | $0.2 | 4,096 | None |
|
|
124
|
-
| [Anthropic: Claude 3 Opus](https://openrouter.ai/models/anthropic/claude-3-opus) | anthropic/claude-3-opus | $15 | $75 | 200,000 | Moderated |
|
|
125
|
-
| [Anthropic: Claude 3 Sonnet](https://openrouter.ai/models/anthropic/claude-3-sonnet) | anthropic/claude-3-sonnet | $3 | $15 | 200,000 | Moderated |
|
|
126
|
-
| [Anthropic: Claude 3 Opus (self-moderated)](https://openrouter.ai/models/anthropic/claude-3-opus:beta) | anthropic/claude-3-opus:beta | $15 | $75 | 200,000 | None |
|
|
127
|
-
| [Anthropic: Claude 3 Sonnet (self-moderated)](https://openrouter.ai/models/anthropic/claude-3-sonnet:beta) | anthropic/claude-3-sonnet:beta | $3 | $15 | 200,000 | None |
|
|
128
|
-
| [Mistral Large](https://openrouter.ai/models/mistralai/mistral-large) | mistralai/mistral-large | $8 | $24 | 32,000 | None |
|
|
129
|
-
| [Google: Gemma 7B](https://openrouter.ai/models/google/gemma-7b-it) | google/gemma-7b-it | $0.07 | $0.07 | 8,192 | None |
|
|
130
|
-
| [Google: Gemma 7B (free)](https://openrouter.ai/models/google/gemma-7b-it:free) | google/gemma-7b-it:free | $0 (100% off) | $0 (100% off) | 8,192 | None |
|
|
131
|
-
| [Nous: Hermes 2 Mistral 7B DPO](https://openrouter.ai/models/nousresearch/nous-hermes-2-mistral-7b-dpo) | nousresearch/nous-hermes-2-mistral-7b-dpo | $0.18 (10% off) | $0.18 (10% off) | 8,192 | None |
|
|
132
|
-
| [Meta: CodeLlama 70B Instruct](https://openrouter.ai/models/meta-llama/codellama-70b-instruct) | meta-llama/codellama-70b-instruct | $0.81 (10% off) | $0.81 (10% off) | 2,048 | None |
|
|
133
|
-
| [RWKV v5: Eagle 7B](https://openrouter.ai/models/recursal/eagle-7b) | recursal/eagle-7b | $0 | $0 | 10,000 | None |
|
|
134
|
-
| [OpenAI: GPT-3.5 Turbo (older v0613)](https://openrouter.ai/models/openai/gpt-3.5-turbo-0613) | openai/gpt-3.5-turbo-0613 | $1 | $2 | 4,095 | Moderated |
|
|
135
|
-
| [OpenAI: GPT-4 Turbo Preview](https://openrouter.ai/models/openai/gpt-4-turbo-preview) | openai/gpt-4-turbo-preview | $10 | $30 | 128,000 | Moderated |
|
|
136
|
-
| [ReMM SLERP 13B (extended)](https://openrouter.ai/models/undi95/remm-slerp-l2-13b:extended) | undi95/remm-slerp-l2-13b:extended | $1.125 (25% off) | $1.125 (25% off) | 6,144 | None |
|
|
137
|
-
| [Nous: Hermes 2 Mixtral 8x7B DPO](https://openrouter.ai/models/nousresearch/nous-hermes-2-mixtral-8x7b-dpo) | nousresearch/nous-hermes-2-mixtral-8x7b-dpo | $0.45 | $0.45 | 32,768 | None |
|
|
138
|
-
| [Nous: Hermes 2 Mixtral 8x7B SFT](https://openrouter.ai/models/nousresearch/nous-hermes-2-mixtral-8x7b-sft) | nousresearch/nous-hermes-2-mixtral-8x7b-sft | $0.54 (10% off) | $0.54 (10% off) | 32,768 | None |
|
|
139
|
-
| [Mistral Tiny](https://openrouter.ai/models/mistralai/mistral-tiny) | mistralai/mistral-tiny | $0.25 | $0.25 | 32,000 | None |
|
|
140
|
-
| [Mistral Small](https://openrouter.ai/models/mistralai/mistral-small) | mistralai/mistral-small | $2 | $6 | 32,000 | None |
|
|
141
|
-
| [Mistral Medium](https://openrouter.ai/models/mistralai/mistral-medium) | mistralai/mistral-medium | $2.7 | $8.1 | 32,000 | None |
|
|
142
|
-
| [Chronos Hermes 13B v2](https://openrouter.ai/models/austism/chronos-hermes-13b) | austism/chronos-hermes-13b | $0.13 | $0.13 | 4,096 | None |
|
|
143
|
-
| [Noromaid Mixtral 8x7B Instruct](https://openrouter.ai/models/neversleep/noromaid-mixtral-8x7b-instruct) | neversleep/noromaid-mixtral-8x7b-instruct | $8 | $8 | 8,000 | None |
|
|
144
|
-
| [Nous: Hermes 2 Yi 34B](https://openrouter.ai/models/nousresearch/nous-hermes-yi-34b) | nousresearch/nous-hermes-yi-34b | $0.72 (10% off) | $0.72 (10% off) | 4,096 | None |
|
|
145
|
-
| [Mistral: Mistral 7B Instruct v0.2](https://openrouter.ai/models/mistralai/mistral-7b-instruct-v0.2) | mistralai/mistral-7b-instruct-v0.2 | $0.06 | $0.06 | 32,768 | None |
|
|
146
|
-
| [Dolphin 2.6 Mixtral 8x7B 🐬](https://openrouter.ai/models/cognitivecomputations/dolphin-mixtral-8x7b) | cognitivecomputations/dolphin-mixtral-8x7b | $0.5 | $0.5 | 32,768 | None |
|
|
147
|
-
| [Google: Gemini Pro 1.0](https://openrouter.ai/models/google/gemini-pro) | google/gemini-pro | $0.125 | $0.375 | 91,728 | None |
|
|
148
|
-
| [Google: Gemini Pro Vision 1.0](https://openrouter.ai/models/google/gemini-pro-vision) | google/gemini-pro-vision | $0.125 | $0.375 | 45,875 | None |
|
|
149
|
-
| [Mixtral 8x7B (base)](https://openrouter.ai/models/mistralai/mixtral-8x7b) | mistralai/mixtral-8x7b | $0.54 (10% off) | $0.54 (10% off) | 32,768 | None |
|
|
150
|
-
| [Mixtral 8x7B Instruct](https://openrouter.ai/models/mistralai/mixtral-8x7b-instruct) | mistralai/mixtral-8x7b-instruct | $0.24 | $0.24 | 32,768 | None |
|
|
151
|
-
| [RWKV v5 World 3B](https://openrouter.ai/models/rwkv/rwkv-5-world-3b) | rwkv/rwkv-5-world-3b | $0 | $0 | 10,000 | None |
|
|
152
|
-
| [RWKV v5 3B AI Town](https://openrouter.ai/models/recursal/rwkv-5-3b-ai-town) | recursal/rwkv-5-3b-ai-town | $0 | $0 | 10,000 | None |
|
|
153
|
-
| [StripedHyena Nous 7B](https://openrouter.ai/models/togethercomputer/stripedhyena-nous-7b) | togethercomputer/stripedhyena-nous-7b | $0.18 (10% off) | $0.18 (10% off) | 32,768 | None |
|
|
154
|
-
| [StripedHyena Hessian 7B (base)](https://openrouter.ai/models/togethercomputer/stripedhyena-hessian-7b) | togethercomputer/stripedhyena-hessian-7b | $0.18 (10% off) | $0.18 (10% off) | 32,768 | None |
|
|
155
|
-
| [Psyfighter v2 13B](https://openrouter.ai/models/koboldai/psyfighter-13b-2) | koboldai/psyfighter-13b-2 | $1 (90% off) | $1 (90% off) | 4,096 | None |
|
|
156
|
-
| [Yi 34B Chat](https://openrouter.ai/models/01-ai/yi-34b-chat) | 01-ai/yi-34b-chat | $0.72 (10% off) | $0.72 (10% off) | 4,096 | None |
|
|
157
|
-
| [Yi 34B (base)](https://openrouter.ai/models/01-ai/yi-34b) | 01-ai/yi-34b | $0.72 (10% off) | $0.72 (10% off) | 4,096 | None |
|
|
158
|
-
| [Yi 6B (base)](https://openrouter.ai/models/01-ai/yi-6b) | 01-ai/yi-6b | $0.18 (10% off) | $0.18 (10% off) | 4,096 | None |
|
|
159
|
-
| [MythoMist 7B](https://openrouter.ai/models/gryphe/mythomist-7b) | gryphe/mythomist-7b | $0.375 (25% off) | $0.375 (25% off) | 32,768 | None |
|
|
160
|
-
| [Nous: Capybara 7B](https://openrouter.ai/models/nousresearch/nous-capybara-7b) | nousresearch/nous-capybara-7b | $0.18 (10% off) | $0.18 (10% off) | 8,192 | None |
|
|
161
|
-
| [Nous: Capybara 7B (free)](https://openrouter.ai/models/nousresearch/nous-capybara-7b:free) | nousresearch/nous-capybara-7b:free | $0 (100% off) | $0 (100% off) | 8,192 | None |
|
|
162
|
-
| [OpenChat 3.5 7B](https://openrouter.ai/models/openchat/openchat-7b) | openchat/openchat-7b | $0.07 | $0.07 | 8,192 | None |
|
|
163
|
-
| [OpenChat 3.5 7B (free)](https://openrouter.ai/models/openchat/openchat-7b:free) | openchat/openchat-7b:free | $0 (100% off) | $0 (100% off) | 8,192 | None |
|
|
164
|
-
| [Noromaid 20B](https://openrouter.ai/models/neversleep/noromaid-20b) | neversleep/noromaid-20b | $1.5 (25% off) | $2.25 (25% off) | 8,192 | None |
|
|
165
|
-
| [MythoMist 7B (free)](https://openrouter.ai/models/gryphe/mythomist-7b:free) | gryphe/mythomist-7b:free | $0 (100% off) | $0 (100% off) | 32,768 | None |
|
|
166
|
-
| [Neural Chat 7B v3.1](https://openrouter.ai/models/intel/neural-chat-7b) | intel/neural-chat-7b | $5 (50% off) | $5 (50% off) | 4,096 | None |
|
|
167
|
-
| [Anthropic: Claude v2](https://openrouter.ai/models/anthropic/claude-2) | anthropic/claude-2 | $8 | $24 | 200,000 | Moderated |
|
|
168
|
-
| [Anthropic: Claude v2.1](https://openrouter.ai/models/anthropic/claude-2.1) | anthropic/claude-2.1 | $8 | $24 | 200,000 | Moderated |
|
|
169
|
-
| [Anthropic: Claude Instant v1.1](https://openrouter.ai/models/anthropic/claude-instant-1.1) | anthropic/claude-instant-1.1 | $0.8 | $2.4 | 100,000 | Moderated |
|
|
170
|
-
| [Anthropic: Claude v2 (self-moderated)](https://openrouter.ai/models/anthropic/claude-2:beta) | anthropic/claude-2:beta | $8 | $24 | 200,000 | None |
|
|
171
|
-
| [Anthropic: Claude v2.1 (self-moderated)](https://openrouter.ai/models/anthropic/claude-2.1:beta) | anthropic/claude-2.1:beta | $8 | $24 | 200,000 | None |
|
|
172
|
-
| [OpenHermes 2.5 Mistral 7B](https://openrouter.ai/models/teknium/openhermes-2.5-mistral-7b) | teknium/openhermes-2.5-mistral-7b | $0.17 | $0.17 | 4,096 | None |
|
|
173
|
-
| [OpenAI: GPT-4 Vision](https://openrouter.ai/models/openai/gpt-4-vision-preview) | openai/gpt-4-vision-preview | $10 | $30 | 128,000 | Moderated |
|
|
174
|
-
| [lzlv 70B](https://openrouter.ai/models/lizpreciatior/lzlv-70b-fp16-hf) | lizpreciatior/lzlv-70b-fp16-hf | $0.58 | $0.78 | 4,096 | None |
|
|
175
|
-
| [Toppy M 7B](https://openrouter.ai/models/undi95/toppy-m-7b) | undi95/toppy-m-7b | $0.07 | $0.07 | 4,096 | None |
|
|
176
|
-
| [Goliath 120B](https://openrouter.ai/models/alpindale/goliath-120b) | alpindale/goliath-120b | $9.375 (25% off) | $9.375 (25% off) | 6,144 | None |
|
|
177
|
-
| [Toppy M 7B (free)](https://openrouter.ai/models/undi95/toppy-m-7b:free) | undi95/toppy-m-7b:free | $0 (100% off) | $0 (100% off) | 4,096 | None |
|
|
178
|
-
| [Auto (best for prompt)](https://openrouter.ai/models/openrouter/auto) | openrouter/auto | -- | -- | 200,000 | -- |
|
|
179
|
-
| [OpenAI: GPT-3.5 Turbo 16k (older v1106)](https://openrouter.ai/models/openai/gpt-3.5-turbo-1106) | openai/gpt-3.5-turbo-1106 | $1 | $2 | 16,385 | Moderated |
|
|
180
|
-
| [OpenAI: GPT-4 Turbo (older v1106)](https://openrouter.ai/models/openai/gpt-4-1106-preview) | openai/gpt-4-1106-preview | $10 | $30 | 128,000 | Moderated |
|
|
181
|
-
| [Hugging Face: Zephyr 7B (free)](https://openrouter.ai/models/huggingfaceh4/zephyr-7b-beta:free) | huggingfaceh4/zephyr-7b-beta:free | $0 (100% off) | $0 (100% off) | 4,096 | None |
|
|
182
|
-
| [Google: PaLM 2 Chat 32k](https://openrouter.ai/models/google/palm-2-chat-bison-32k) | google/palm-2-chat-bison-32k | $0.25 | $0.5 | 91,750 | None |
|
|
183
|
-
| [Google: PaLM 2 Code Chat 32k](https://openrouter.ai/models/google/palm-2-codechat-bison-32k) | google/palm-2-codechat-bison-32k | $0.25 | $0.5 | 91,750 | None |
|
|
184
|
-
| [OpenHermes 2 Mistral 7B](https://openrouter.ai/models/teknium/openhermes-2-mistral-7b) | teknium/openhermes-2-mistral-7b | $0.18 (10% off) | $0.18 (10% off) | 8,192 | None |
|
|
185
|
-
| [Mistral OpenOrca 7B](https://openrouter.ai/models/open-orca/mistral-7b-openorca) | open-orca/mistral-7b-openorca | $0.18 (10% off) | $0.18 (10% off) | 8,192 | None |
|
|
186
|
-
| [Airoboros 70B](https://openrouter.ai/models/jondurbin/airoboros-l2-70b) | jondurbin/airoboros-l2-70b | $0.5 | $0.5 | 4,096 | None |
|
|
187
|
-
| [MythoMax 13B (extended)](https://openrouter.ai/models/gryphe/mythomax-l2-13b:extended) | gryphe/mythomax-l2-13b:extended | $1.125 (25% off) | $1.125 (25% off) | 8,192 | None |
|
|
188
|
-
| [Xwin 70B](https://openrouter.ai/models/xwin-lm/xwin-lm-70b) | xwin-lm/xwin-lm-70b | $3.75 (25% off) | $3.75 (25% off) | 8,192 | None |
|
|
189
|
-
| [OpenAI: GPT-3.5 Turbo Instruct](https://openrouter.ai/models/openai/gpt-3.5-turbo-instruct) | openai/gpt-3.5-turbo-instruct | $1.5 | $2 | 4,095 | Moderated |
|
|
190
|
-
| [Mistral: Mistral 7B Instruct v0.1](https://openrouter.ai/models/mistralai/mistral-7b-instruct-v0.1) | mistralai/mistral-7b-instruct-v0.1 | $0.06 | $0.06 | 4,096 | None |
|
|
191
|
-
| [Mistral: Mistral 7B Instruct (free)](https://openrouter.ai/models/mistralai/mistral-7b-instruct:free) | mistralai/mistral-7b-instruct:free | $0 (100% off) | $0 (100% off) | 32,768 | None |
|
|
192
|
-
| [Pygmalion: Mythalion 13B](https://openrouter.ai/models/pygmalionai/mythalion-13b) | pygmalionai/mythalion-13b | $1.125 (25% off) | $1.125 (25% off) | 8,192 | None |
|
|
193
|
-
| [OpenAI: GPT-3.5 Turbo 16k](https://openrouter.ai/models/openai/gpt-3.5-turbo-16k) | openai/gpt-3.5-turbo-16k | $3 | $4 | 16,385 | Moderated |
|
|
194
|
-
|
|
195
|
-
## Models with Tool Calling Capabilities Compatible with AI SDK
|
|
196
|
-
|
|
197
|
-
_Last Update: 2024-08-24_
|
|
198
|
-
|
|
199
|
-
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.
|
|
200
43
|
You can find the latest list of tool-supported models supported by OpenRouter [here](https://openrouter.ai/models?order=newest&supported_parameters=tools). (Note: This list may contain models that are not compatible with the AI SDK.)
|
|
201
44
|
|
|
202
|
-
- [openai/gpt-3.5-turbo](https://openrouter.ai/models/openai/gpt-3.5-turbo)
|
|
203
|
-
- [openai/gpt-3.5-turbo-0125](https://openrouter.ai/models/openai/gpt-3.5-turbo-0125)
|
|
204
|
-
- [openai/gpt-3.5-turbo-1106](https://openrouter.ai/models/openai/gpt-3.5-turbo-1106)
|
|
205
|
-
- [openai/gpt-3.5-turbo-0613](https://openrouter.ai/models/openai/gpt-3.5-turbo-0613)
|
|
206
|
-
- [openai/gpt-3.5-turbo-16k](https://openrouter.ai/models/openai/gpt-3.5-turbo-16k)
|
|
207
|
-
- [openai/gpt-4o](https://openrouter.ai/models/openai/gpt-4o)
|
|
208
|
-
- [openai/gpt-4o-2024-05-13](https://openrouter.ai/models/openai/gpt-4o-2024-05-13)
|
|
209
|
-
- [openai/gpt-4o-2024-08-06](https://openrouter.ai/models/openai/gpt-4o-2024-08-06)
|
|
210
|
-
- [openai/gpt-4o-mini](https://openrouter.ai/models/openai/gpt-4o-mini)
|
|
211
|
-
- [openai/gpt-4o-mini-2024-07-18](https://openrouter.ai/models/openai/gpt-4o-mini-2024-07-18)
|
|
212
|
-
- [openai/gpt-4-turbo](https://openrouter.ai/models/openai/gpt-4-turbo)
|
|
213
|
-
- [openai/gpt-4-turbo-preview](https://openrouter.ai/models/openai/gpt-4-turbo-preview)
|
|
214
|
-
- [openai/gpt-4-1106-preview](https://openrouter.ai/models/openai/gpt-4-1106-preview)
|
|
215
|
-
- [openai/gpt-4](https://openrouter.ai/models/openai/gpt-4)
|
|
216
|
-
- [openai/gpt-4-32k](https://openrouter.ai/models/openai/gpt-4-32k)
|
|
217
|
-
- [openai/gpt-4-vision-preview](https://openrouter.ai/models/openai/gpt-4-vision-preview)
|
|
218
|
-
- [google/gemini-pro](https://openrouter.ai/models/google/gemini-pro)
|
|
219
|
-
- [google/gemini-pro-vision](https://openrouter.ai/models/google/gemini-pro-vision)
|
|
220
|
-
- [google/gemini-pro-1.5](https://openrouter.ai/models/google/gemini-pro-1.5)
|
|
221
|
-
- [google/gemini-flash-1.5](https://openrouter.ai/models/google/gemini-flash-1.5)
|
|
222
|
-
- [mistralai/mistral-small](https://openrouter.ai/models/mistralai/mistral-small)
|
|
223
|
-
- [mistralai/mistral-large](https://openrouter.ai/models/mistralai/mistral-large)
|
|
224
|
-
- [01-ai/yi-large-fc](https://openrouter.ai/models/01-ai/yi-large-fc)
|
|
225
|
-
- [anthropic/claude-3-opus](https://openrouter.ai/models/anthropic/claude-3-opus)
|
|
226
|
-
- [anthropic/claude-3-opus:beta](https://openrouter.ai/models/anthropic/claude-3-opus:beta)
|
|
227
|
-
- [anthropic/claude-3-sonnet](https://openrouter.ai/models/anthropic/claude-3-sonnet)
|
|
228
|
-
- [anthropic/claude-3-sonnet:beta](https://openrouter.ai/models/anthropic/claude-3-sonnet:beta)
|
|
229
|
-
- [anthropic/claude-3.5-sonnet](https://openrouter.ai/models/anthropic/claude-3.5-sonnet)
|
|
230
|
-
- [anthropic/claude-3.5-sonnet:beta](https://openrouter.ai/models/anthropic/claude-3.5-sonnet:beta)
|
|
231
|
-
- [anthropic/claude-3-haiku](https://openrouter.ai/models/anthropic/claude-3-haiku)
|
|
232
|
-
- [anthropic/claude-3-haiku:beta](https://openrouter.ai/models/anthropic/claude-3-haiku:beta)
|
|
233
|
-
- [meta-llama/llama-3-8b-instruct](https://openrouter.ai/models/meta-llama/llama-3-8b-instruct)
|
|
234
|
-
- [meta-llama/llama-3-70b-instruct](https://openrouter.ai/models/meta-llama/llama-3-70b-instruct)
|
|
235
|
-
- [meta-llama/llama-3.1-8b-instruct](https://openrouter.ai/models/meta-llama/llama-3.1-8b-instruct)
|
|
236
|
-
- [meta-llama/llama-3.1-70b-instruct](https://openrouter.ai/models/meta-llama/llama-3.1-70b-instruct)
|
|
237
|
-
- [meta-llama/llama-3.1-405b-instruct](https://openrouter.ai/models/meta-llama/llama-3.1-405b-instruct)
|
|
238
|
-
- [mistralai/mixtral-8x7b-instruct](https://openrouter.ai/models/mistralai/mixtral-8x7b-instruct)
|
|
239
|
-
- [mistralai/mistral-nemo](https://openrouter.ai/models/mistralai/mistral-nemo)
|
|
240
|
-
- [mistralai/mistral-7b-instruct](https://openrouter.ai/models/mistralai/mistral-7b-instruct)
|
|
241
|
-
- [mistralai/mistral-7b-instruct-v0.3](https://openrouter.ai/models/mistralai/mistral-7b-instruct-v0.3)
|
|
242
|
-
- [mistralai/mixtral-8x22b-instruct](https://openrouter.ai/models/mistralai/mixtral-8x22b-instruct)
|
|
243
|
-
|
|
244
45
|
## Passing Extra Body to OpenRouter
|
|
245
46
|
|
|
246
47
|
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.
|
|
247
48
|
|
|
248
49
|
```typescript
|
|
249
|
-
import { createOpenRouter } from
|
|
50
|
+
import { createOpenRouter } from '@openrouter/ai-sdk-provider';
|
|
250
51
|
|
|
251
52
|
const provider = createOpenRouter({
|
|
252
|
-
apiKey:
|
|
53
|
+
apiKey: 'your-api-key',
|
|
253
54
|
// Extra body to pass to OpenRouter
|
|
254
55
|
extraBody: {
|
|
255
|
-
custom_field:
|
|
56
|
+
custom_field: 'custom_value',
|
|
256
57
|
providers: {
|
|
257
58
|
anthropic: {
|
|
258
|
-
custom_field:
|
|
59
|
+
custom_field: 'custom_value',
|
|
259
60
|
},
|
|
260
61
|
},
|
|
261
62
|
},
|
|
262
63
|
});
|
|
263
|
-
const model = provider.chat(
|
|
64
|
+
const model = provider.chat('anthropic/claude-3.5-sonnet');
|
|
264
65
|
const response = await model.doStream({
|
|
265
|
-
inputFormat:
|
|
266
|
-
mode: { type:
|
|
267
|
-
prompt: [{ role:
|
|
66
|
+
inputFormat: 'prompt',
|
|
67
|
+
mode: { type: 'regular' },
|
|
68
|
+
prompt: [{ role: 'user', content: 'Hello' }],
|
|
268
69
|
});
|
|
269
70
|
```
|
package/dist/index.d.mts
CHANGED
|
@@ -2,15 +2,8 @@ import { LanguageModelV1 } from '@ai-sdk/provider';
|
|
|
2
2
|
export { LanguageModelV1 } from '@ai-sdk/provider';
|
|
3
3
|
|
|
4
4
|
type OpenRouterLanguageModel = LanguageModelV1;
|
|
5
|
-
type
|
|
6
|
-
/**
|
|
7
|
-
* List of model IDs to try in order if the primary model fails, e.g. ["anthropic/claude-2","gryphe/mythomax-l2-13b"]
|
|
8
|
-
*/
|
|
5
|
+
type OpenRouterProviderOptions = {
|
|
9
6
|
models?: string[];
|
|
10
|
-
/**
|
|
11
|
-
* @deprecated use `reasoning` instead
|
|
12
|
-
*/
|
|
13
|
-
includeReasoning?: boolean;
|
|
14
7
|
/**
|
|
15
8
|
* https://openrouter.ai/docs/use-cases/reasoning-tokens
|
|
16
9
|
* One of `max_tokens` or `effort` is required.
|
|
@@ -21,15 +14,21 @@ type OpenRouterSharedSettings = {
|
|
|
21
14
|
} & ({
|
|
22
15
|
max_tokens: number;
|
|
23
16
|
} | {
|
|
24
|
-
effort:
|
|
17
|
+
effort: 'high' | 'medium' | 'low';
|
|
25
18
|
});
|
|
26
|
-
extraBody?: Record<string, any>;
|
|
27
19
|
/**
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
* A unique identifier representing your end-user, which can
|
|
21
|
+
* help OpenRouter to monitor and detect abuse.
|
|
30
22
|
*/
|
|
31
23
|
user?: string;
|
|
32
24
|
};
|
|
25
|
+
type OpenRouterSharedSettings = OpenRouterProviderOptions & {
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated use `reasoning` instead
|
|
28
|
+
*/
|
|
29
|
+
includeReasoning?: boolean;
|
|
30
|
+
extraBody?: Record<string, any>;
|
|
31
|
+
};
|
|
33
32
|
|
|
34
33
|
type OpenRouterChatModelId = string;
|
|
35
34
|
type OpenRouterChatSettings = {
|
|
@@ -71,30 +70,6 @@ type OpenRouterChatSettings = {
|
|
|
71
70
|
user?: string;
|
|
72
71
|
} & OpenRouterSharedSettings;
|
|
73
72
|
|
|
74
|
-
type OpenRouterChatConfig = {
|
|
75
|
-
provider: string;
|
|
76
|
-
compatibility: "strict" | "compatible";
|
|
77
|
-
headers: () => Record<string, string | undefined>;
|
|
78
|
-
url: (options: {
|
|
79
|
-
modelId: string;
|
|
80
|
-
path: string;
|
|
81
|
-
}) => string;
|
|
82
|
-
fetch?: typeof fetch;
|
|
83
|
-
extraBody?: Record<string, unknown>;
|
|
84
|
-
};
|
|
85
|
-
declare class OpenRouterChatLanguageModel implements LanguageModelV1 {
|
|
86
|
-
readonly specificationVersion = "v1";
|
|
87
|
-
readonly defaultObjectGenerationMode = "tool";
|
|
88
|
-
readonly modelId: OpenRouterChatModelId;
|
|
89
|
-
readonly settings: OpenRouterChatSettings;
|
|
90
|
-
private readonly config;
|
|
91
|
-
constructor(modelId: OpenRouterChatModelId, settings: OpenRouterChatSettings, config: OpenRouterChatConfig);
|
|
92
|
-
get provider(): string;
|
|
93
|
-
private getArgs;
|
|
94
|
-
doGenerate(options: Parameters<LanguageModelV1["doGenerate"]>[0]): Promise<Awaited<ReturnType<LanguageModelV1["doGenerate"]>>>;
|
|
95
|
-
doStream(options: Parameters<LanguageModelV1["doStream"]>[0]): Promise<Awaited<ReturnType<LanguageModelV1["doStream"]>>>;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
73
|
type OpenRouterCompletionModelId = string;
|
|
99
74
|
type OpenRouterCompletionSettings = {
|
|
100
75
|
/**
|
|
@@ -130,9 +105,33 @@ type OpenRouterCompletionSettings = {
|
|
|
130
105
|
suffix?: string;
|
|
131
106
|
} & OpenRouterSharedSettings;
|
|
132
107
|
|
|
108
|
+
type OpenRouterChatConfig = {
|
|
109
|
+
provider: string;
|
|
110
|
+
compatibility: 'strict' | 'compatible';
|
|
111
|
+
headers: () => Record<string, string | undefined>;
|
|
112
|
+
url: (options: {
|
|
113
|
+
modelId: string;
|
|
114
|
+
path: string;
|
|
115
|
+
}) => string;
|
|
116
|
+
fetch?: typeof fetch;
|
|
117
|
+
extraBody?: Record<string, unknown>;
|
|
118
|
+
};
|
|
119
|
+
declare class OpenRouterChatLanguageModel implements LanguageModelV1 {
|
|
120
|
+
readonly specificationVersion = "v1";
|
|
121
|
+
readonly defaultObjectGenerationMode = "tool";
|
|
122
|
+
readonly modelId: OpenRouterChatModelId;
|
|
123
|
+
readonly settings: OpenRouterChatSettings;
|
|
124
|
+
private readonly config;
|
|
125
|
+
constructor(modelId: OpenRouterChatModelId, settings: OpenRouterChatSettings, config: OpenRouterChatConfig);
|
|
126
|
+
get provider(): string;
|
|
127
|
+
private getArgs;
|
|
128
|
+
doGenerate(options: Parameters<LanguageModelV1['doGenerate']>[0]): Promise<Awaited<ReturnType<LanguageModelV1['doGenerate']>>>;
|
|
129
|
+
doStream(options: Parameters<LanguageModelV1['doStream']>[0]): Promise<Awaited<ReturnType<LanguageModelV1['doStream']>>>;
|
|
130
|
+
}
|
|
131
|
+
|
|
133
132
|
type OpenRouterCompletionConfig = {
|
|
134
133
|
provider: string;
|
|
135
|
-
compatibility:
|
|
134
|
+
compatibility: 'strict' | 'compatible';
|
|
136
135
|
headers: () => Record<string, string | undefined>;
|
|
137
136
|
url: (options: {
|
|
138
137
|
modelId: string;
|
|
@@ -150,8 +149,8 @@ declare class OpenRouterCompletionLanguageModel implements LanguageModelV1 {
|
|
|
150
149
|
constructor(modelId: OpenRouterCompletionModelId, settings: OpenRouterCompletionSettings, config: OpenRouterCompletionConfig);
|
|
151
150
|
get provider(): string;
|
|
152
151
|
private getArgs;
|
|
153
|
-
doGenerate(options: Parameters<LanguageModelV1[
|
|
154
|
-
doStream(options: Parameters<LanguageModelV1[
|
|
152
|
+
doGenerate(options: Parameters<LanguageModelV1['doGenerate']>[0]): Promise<Awaited<ReturnType<LanguageModelV1['doGenerate']>>>;
|
|
153
|
+
doStream(options: Parameters<LanguageModelV1['doStream']>[0]): Promise<Awaited<ReturnType<LanguageModelV1['doStream']>>>;
|
|
155
154
|
}
|
|
156
155
|
|
|
157
156
|
interface OpenRouterProvider {
|
|
@@ -190,7 +189,7 @@ interface OpenRouterProviderSettings {
|
|
|
190
189
|
and `compatible` when using 3rd party providers. In `compatible` mode, newer
|
|
191
190
|
information such as streamOptions are not being sent. Defaults to 'compatible'.
|
|
192
191
|
*/
|
|
193
|
-
compatibility?:
|
|
192
|
+
compatibility?: 'strict' | 'compatible';
|
|
194
193
|
/**
|
|
195
194
|
Custom fetch implementation. You can use it as a middleware to intercept requests,
|
|
196
195
|
or to provide a custom fetch implementation for e.g. testing.
|
|
@@ -237,4 +236,4 @@ declare class OpenRouter {
|
|
|
237
236
|
completion(modelId: OpenRouterCompletionModelId, settings?: OpenRouterCompletionSettings): OpenRouterCompletionLanguageModel;
|
|
238
237
|
}
|
|
239
238
|
|
|
240
|
-
export { OpenRouter, type OpenRouterCompletionSettings, type OpenRouterLanguageModel, type OpenRouterProvider, type OpenRouterProviderSettings, type OpenRouterSharedSettings, createOpenRouter, openrouter };
|
|
239
|
+
export { OpenRouter, type OpenRouterCompletionSettings, type OpenRouterLanguageModel, type OpenRouterProvider, type OpenRouterProviderOptions, type OpenRouterProviderSettings, type OpenRouterSharedSettings, createOpenRouter, openrouter };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,15 +2,8 @@ import { LanguageModelV1 } from '@ai-sdk/provider';
|
|
|
2
2
|
export { LanguageModelV1 } from '@ai-sdk/provider';
|
|
3
3
|
|
|
4
4
|
type OpenRouterLanguageModel = LanguageModelV1;
|
|
5
|
-
type
|
|
6
|
-
/**
|
|
7
|
-
* List of model IDs to try in order if the primary model fails, e.g. ["anthropic/claude-2","gryphe/mythomax-l2-13b"]
|
|
8
|
-
*/
|
|
5
|
+
type OpenRouterProviderOptions = {
|
|
9
6
|
models?: string[];
|
|
10
|
-
/**
|
|
11
|
-
* @deprecated use `reasoning` instead
|
|
12
|
-
*/
|
|
13
|
-
includeReasoning?: boolean;
|
|
14
7
|
/**
|
|
15
8
|
* https://openrouter.ai/docs/use-cases/reasoning-tokens
|
|
16
9
|
* One of `max_tokens` or `effort` is required.
|
|
@@ -21,15 +14,21 @@ type OpenRouterSharedSettings = {
|
|
|
21
14
|
} & ({
|
|
22
15
|
max_tokens: number;
|
|
23
16
|
} | {
|
|
24
|
-
effort:
|
|
17
|
+
effort: 'high' | 'medium' | 'low';
|
|
25
18
|
});
|
|
26
|
-
extraBody?: Record<string, any>;
|
|
27
19
|
/**
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
* A unique identifier representing your end-user, which can
|
|
21
|
+
* help OpenRouter to monitor and detect abuse.
|
|
30
22
|
*/
|
|
31
23
|
user?: string;
|
|
32
24
|
};
|
|
25
|
+
type OpenRouterSharedSettings = OpenRouterProviderOptions & {
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated use `reasoning` instead
|
|
28
|
+
*/
|
|
29
|
+
includeReasoning?: boolean;
|
|
30
|
+
extraBody?: Record<string, any>;
|
|
31
|
+
};
|
|
33
32
|
|
|
34
33
|
type OpenRouterChatModelId = string;
|
|
35
34
|
type OpenRouterChatSettings = {
|
|
@@ -71,30 +70,6 @@ type OpenRouterChatSettings = {
|
|
|
71
70
|
user?: string;
|
|
72
71
|
} & OpenRouterSharedSettings;
|
|
73
72
|
|
|
74
|
-
type OpenRouterChatConfig = {
|
|
75
|
-
provider: string;
|
|
76
|
-
compatibility: "strict" | "compatible";
|
|
77
|
-
headers: () => Record<string, string | undefined>;
|
|
78
|
-
url: (options: {
|
|
79
|
-
modelId: string;
|
|
80
|
-
path: string;
|
|
81
|
-
}) => string;
|
|
82
|
-
fetch?: typeof fetch;
|
|
83
|
-
extraBody?: Record<string, unknown>;
|
|
84
|
-
};
|
|
85
|
-
declare class OpenRouterChatLanguageModel implements LanguageModelV1 {
|
|
86
|
-
readonly specificationVersion = "v1";
|
|
87
|
-
readonly defaultObjectGenerationMode = "tool";
|
|
88
|
-
readonly modelId: OpenRouterChatModelId;
|
|
89
|
-
readonly settings: OpenRouterChatSettings;
|
|
90
|
-
private readonly config;
|
|
91
|
-
constructor(modelId: OpenRouterChatModelId, settings: OpenRouterChatSettings, config: OpenRouterChatConfig);
|
|
92
|
-
get provider(): string;
|
|
93
|
-
private getArgs;
|
|
94
|
-
doGenerate(options: Parameters<LanguageModelV1["doGenerate"]>[0]): Promise<Awaited<ReturnType<LanguageModelV1["doGenerate"]>>>;
|
|
95
|
-
doStream(options: Parameters<LanguageModelV1["doStream"]>[0]): Promise<Awaited<ReturnType<LanguageModelV1["doStream"]>>>;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
73
|
type OpenRouterCompletionModelId = string;
|
|
99
74
|
type OpenRouterCompletionSettings = {
|
|
100
75
|
/**
|
|
@@ -130,9 +105,33 @@ type OpenRouterCompletionSettings = {
|
|
|
130
105
|
suffix?: string;
|
|
131
106
|
} & OpenRouterSharedSettings;
|
|
132
107
|
|
|
108
|
+
type OpenRouterChatConfig = {
|
|
109
|
+
provider: string;
|
|
110
|
+
compatibility: 'strict' | 'compatible';
|
|
111
|
+
headers: () => Record<string, string | undefined>;
|
|
112
|
+
url: (options: {
|
|
113
|
+
modelId: string;
|
|
114
|
+
path: string;
|
|
115
|
+
}) => string;
|
|
116
|
+
fetch?: typeof fetch;
|
|
117
|
+
extraBody?: Record<string, unknown>;
|
|
118
|
+
};
|
|
119
|
+
declare class OpenRouterChatLanguageModel implements LanguageModelV1 {
|
|
120
|
+
readonly specificationVersion = "v1";
|
|
121
|
+
readonly defaultObjectGenerationMode = "tool";
|
|
122
|
+
readonly modelId: OpenRouterChatModelId;
|
|
123
|
+
readonly settings: OpenRouterChatSettings;
|
|
124
|
+
private readonly config;
|
|
125
|
+
constructor(modelId: OpenRouterChatModelId, settings: OpenRouterChatSettings, config: OpenRouterChatConfig);
|
|
126
|
+
get provider(): string;
|
|
127
|
+
private getArgs;
|
|
128
|
+
doGenerate(options: Parameters<LanguageModelV1['doGenerate']>[0]): Promise<Awaited<ReturnType<LanguageModelV1['doGenerate']>>>;
|
|
129
|
+
doStream(options: Parameters<LanguageModelV1['doStream']>[0]): Promise<Awaited<ReturnType<LanguageModelV1['doStream']>>>;
|
|
130
|
+
}
|
|
131
|
+
|
|
133
132
|
type OpenRouterCompletionConfig = {
|
|
134
133
|
provider: string;
|
|
135
|
-
compatibility:
|
|
134
|
+
compatibility: 'strict' | 'compatible';
|
|
136
135
|
headers: () => Record<string, string | undefined>;
|
|
137
136
|
url: (options: {
|
|
138
137
|
modelId: string;
|
|
@@ -150,8 +149,8 @@ declare class OpenRouterCompletionLanguageModel implements LanguageModelV1 {
|
|
|
150
149
|
constructor(modelId: OpenRouterCompletionModelId, settings: OpenRouterCompletionSettings, config: OpenRouterCompletionConfig);
|
|
151
150
|
get provider(): string;
|
|
152
151
|
private getArgs;
|
|
153
|
-
doGenerate(options: Parameters<LanguageModelV1[
|
|
154
|
-
doStream(options: Parameters<LanguageModelV1[
|
|
152
|
+
doGenerate(options: Parameters<LanguageModelV1['doGenerate']>[0]): Promise<Awaited<ReturnType<LanguageModelV1['doGenerate']>>>;
|
|
153
|
+
doStream(options: Parameters<LanguageModelV1['doStream']>[0]): Promise<Awaited<ReturnType<LanguageModelV1['doStream']>>>;
|
|
155
154
|
}
|
|
156
155
|
|
|
157
156
|
interface OpenRouterProvider {
|
|
@@ -190,7 +189,7 @@ interface OpenRouterProviderSettings {
|
|
|
190
189
|
and `compatible` when using 3rd party providers. In `compatible` mode, newer
|
|
191
190
|
information such as streamOptions are not being sent. Defaults to 'compatible'.
|
|
192
191
|
*/
|
|
193
|
-
compatibility?:
|
|
192
|
+
compatibility?: 'strict' | 'compatible';
|
|
194
193
|
/**
|
|
195
194
|
Custom fetch implementation. You can use it as a middleware to intercept requests,
|
|
196
195
|
or to provide a custom fetch implementation for e.g. testing.
|
|
@@ -237,4 +236,4 @@ declare class OpenRouter {
|
|
|
237
236
|
completion(modelId: OpenRouterCompletionModelId, settings?: OpenRouterCompletionSettings): OpenRouterCompletionLanguageModel;
|
|
238
237
|
}
|
|
239
238
|
|
|
240
|
-
export { OpenRouter, type OpenRouterCompletionSettings, type OpenRouterLanguageModel, type OpenRouterProvider, type OpenRouterProviderSettings, type OpenRouterSharedSettings, createOpenRouter, openrouter };
|
|
239
|
+
export { OpenRouter, type OpenRouterCompletionSettings, type OpenRouterLanguageModel, type OpenRouterProvider, type OpenRouterProviderOptions, type OpenRouterProviderSettings, type OpenRouterSharedSettings, createOpenRouter, openrouter };
|