@openrouter/ai-sdk-provider 1.1.2 → 1.2.1
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 +15 -1
- package/dist/index.d.mts +36 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +287 -147
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +287 -147
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +36 -0
- package/dist/internal/index.d.ts +36 -0
- package/dist/internal/index.js +255 -140
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +255 -140
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
The [OpenRouter](https://openrouter.ai/) provider for the [Vercel AI SDK](https://sdk.vercel.ai/docs) gives access to over 300 large language models on the OpenRouter chat and completion APIs.
|
|
4
4
|
|
|
5
|
-
## Setup
|
|
5
|
+
## Setup for AI SDK v5
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
# For pnpm
|
|
@@ -15,6 +15,20 @@ npm install @openrouter/ai-sdk-provider
|
|
|
15
15
|
yarn add @openrouter/ai-sdk-provider
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
+
## (LEGACY) Setup for AI SDK v4
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# For pnpm
|
|
22
|
+
pnpm add @openrouter/ai-sdk-provider@ai-sdk-v4
|
|
23
|
+
|
|
24
|
+
# For npm
|
|
25
|
+
npm install @openrouter/ai-sdk-provider@ai-sdk-v4
|
|
26
|
+
|
|
27
|
+
# For yarn
|
|
28
|
+
yarn add @openrouter/ai-sdk-provider@ai-sdk-v4
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
|
|
18
32
|
## Provider Instance
|
|
19
33
|
|
|
20
34
|
You can import the default provider instance `openrouter` from `@openrouter/ai-sdk-provider`:
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { LanguageModelV2, LanguageModelV2CallOptions, LanguageModelV2Content, LanguageModelV2FinishReason, LanguageModelV2Usage, LanguageModelV2CallWarning, LanguageModelV2ResponseMetadata, SharedV2Headers, LanguageModelV2StreamPart } from '@ai-sdk/provider';
|
|
2
2
|
export { LanguageModelV2, LanguageModelV2Prompt } from '@ai-sdk/provider';
|
|
3
|
+
import { z } from 'zod/v4';
|
|
3
4
|
|
|
4
5
|
type OpenRouterChatModelId = string;
|
|
5
6
|
type OpenRouterChatSettings = {
|
|
@@ -208,6 +209,40 @@ type OpenRouterCompletionSettings = {
|
|
|
208
209
|
suffix?: string;
|
|
209
210
|
} & OpenRouterSharedSettings;
|
|
210
211
|
|
|
212
|
+
declare enum ReasoningFormat {
|
|
213
|
+
Unknown = "unknown",
|
|
214
|
+
OpenAIResponsesV1 = "openai-responses-v1",
|
|
215
|
+
XAIResponsesV1 = "xai-responses-v1",
|
|
216
|
+
AnthropicClaudeV1 = "anthropic-claude-v1"
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
declare enum ReasoningDetailType {
|
|
220
|
+
Summary = "reasoning.summary",
|
|
221
|
+
Encrypted = "reasoning.encrypted",
|
|
222
|
+
Text = "reasoning.text"
|
|
223
|
+
}
|
|
224
|
+
declare const ReasoningDetailUnionSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
225
|
+
type: z.ZodLiteral<ReasoningDetailType.Summary>;
|
|
226
|
+
summary: z.ZodString;
|
|
227
|
+
id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
228
|
+
format: z.ZodOptional<z.ZodNullable<z.ZodEnum<typeof ReasoningFormat>>>;
|
|
229
|
+
index: z.ZodOptional<z.ZodNumber>;
|
|
230
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
231
|
+
type: z.ZodLiteral<ReasoningDetailType.Encrypted>;
|
|
232
|
+
data: z.ZodString;
|
|
233
|
+
id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
234
|
+
format: z.ZodOptional<z.ZodNullable<z.ZodEnum<typeof ReasoningFormat>>>;
|
|
235
|
+
index: z.ZodOptional<z.ZodNumber>;
|
|
236
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
237
|
+
type: z.ZodLiteral<ReasoningDetailType.Text>;
|
|
238
|
+
text: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
239
|
+
signature: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
240
|
+
id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
241
|
+
format: z.ZodOptional<z.ZodNullable<z.ZodEnum<typeof ReasoningFormat>>>;
|
|
242
|
+
index: z.ZodOptional<z.ZodNumber>;
|
|
243
|
+
}, z.core.$strip>]>;
|
|
244
|
+
type ReasoningDetailUnion = z.infer<typeof ReasoningDetailUnionSchema>;
|
|
245
|
+
|
|
211
246
|
type OpenRouterChatConfig = {
|
|
212
247
|
provider: string;
|
|
213
248
|
compatibility: 'strict' | 'compatible';
|
|
@@ -237,6 +272,7 @@ declare class OpenRouterChatLanguageModel implements LanguageModelV2 {
|
|
|
237
272
|
providerMetadata?: {
|
|
238
273
|
openrouter: {
|
|
239
274
|
provider: string;
|
|
275
|
+
reasoning_details?: ReasoningDetailUnion[];
|
|
240
276
|
usage: OpenRouterUsageAccounting;
|
|
241
277
|
};
|
|
242
278
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { LanguageModelV2, LanguageModelV2CallOptions, LanguageModelV2Content, LanguageModelV2FinishReason, LanguageModelV2Usage, LanguageModelV2CallWarning, LanguageModelV2ResponseMetadata, SharedV2Headers, LanguageModelV2StreamPart } from '@ai-sdk/provider';
|
|
2
2
|
export { LanguageModelV2, LanguageModelV2Prompt } from '@ai-sdk/provider';
|
|
3
|
+
import { z } from 'zod/v4';
|
|
3
4
|
|
|
4
5
|
type OpenRouterChatModelId = string;
|
|
5
6
|
type OpenRouterChatSettings = {
|
|
@@ -208,6 +209,40 @@ type OpenRouterCompletionSettings = {
|
|
|
208
209
|
suffix?: string;
|
|
209
210
|
} & OpenRouterSharedSettings;
|
|
210
211
|
|
|
212
|
+
declare enum ReasoningFormat {
|
|
213
|
+
Unknown = "unknown",
|
|
214
|
+
OpenAIResponsesV1 = "openai-responses-v1",
|
|
215
|
+
XAIResponsesV1 = "xai-responses-v1",
|
|
216
|
+
AnthropicClaudeV1 = "anthropic-claude-v1"
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
declare enum ReasoningDetailType {
|
|
220
|
+
Summary = "reasoning.summary",
|
|
221
|
+
Encrypted = "reasoning.encrypted",
|
|
222
|
+
Text = "reasoning.text"
|
|
223
|
+
}
|
|
224
|
+
declare const ReasoningDetailUnionSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
225
|
+
type: z.ZodLiteral<ReasoningDetailType.Summary>;
|
|
226
|
+
summary: z.ZodString;
|
|
227
|
+
id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
228
|
+
format: z.ZodOptional<z.ZodNullable<z.ZodEnum<typeof ReasoningFormat>>>;
|
|
229
|
+
index: z.ZodOptional<z.ZodNumber>;
|
|
230
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
231
|
+
type: z.ZodLiteral<ReasoningDetailType.Encrypted>;
|
|
232
|
+
data: z.ZodString;
|
|
233
|
+
id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
234
|
+
format: z.ZodOptional<z.ZodNullable<z.ZodEnum<typeof ReasoningFormat>>>;
|
|
235
|
+
index: z.ZodOptional<z.ZodNumber>;
|
|
236
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
237
|
+
type: z.ZodLiteral<ReasoningDetailType.Text>;
|
|
238
|
+
text: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
239
|
+
signature: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
240
|
+
id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
241
|
+
format: z.ZodOptional<z.ZodNullable<z.ZodEnum<typeof ReasoningFormat>>>;
|
|
242
|
+
index: z.ZodOptional<z.ZodNumber>;
|
|
243
|
+
}, z.core.$strip>]>;
|
|
244
|
+
type ReasoningDetailUnion = z.infer<typeof ReasoningDetailUnionSchema>;
|
|
245
|
+
|
|
211
246
|
type OpenRouterChatConfig = {
|
|
212
247
|
provider: string;
|
|
213
248
|
compatibility: 'strict' | 'compatible';
|
|
@@ -237,6 +272,7 @@ declare class OpenRouterChatLanguageModel implements LanguageModelV2 {
|
|
|
237
272
|
providerMetadata?: {
|
|
238
273
|
openrouter: {
|
|
239
274
|
provider: string;
|
|
275
|
+
reasoning_details?: ReasoningDetailUnion[];
|
|
240
276
|
usage: OpenRouterUsageAccounting;
|
|
241
277
|
};
|
|
242
278
|
};
|