@openrouter/ai-sdk-provider 1.2.0 → 1.2.2

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.
@@ -1,5 +1,41 @@
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';
4
+ import * as models from '@openrouter/sdk/models';
5
+
6
+ declare enum ReasoningFormat {
7
+ Unknown = "unknown",
8
+ OpenAIResponsesV1 = "openai-responses-v1",
9
+ XAIResponsesV1 = "xai-responses-v1",
10
+ AnthropicClaudeV1 = "anthropic-claude-v1"
11
+ }
12
+
13
+ declare enum ReasoningDetailType {
14
+ Summary = "reasoning.summary",
15
+ Encrypted = "reasoning.encrypted",
16
+ Text = "reasoning.text"
17
+ }
18
+ declare const ReasoningDetailUnionSchema: z.ZodUnion<readonly [z.ZodObject<{
19
+ type: z.ZodLiteral<ReasoningDetailType.Summary>;
20
+ summary: z.ZodString;
21
+ id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
22
+ format: z.ZodOptional<z.ZodNullable<z.ZodEnum<typeof ReasoningFormat>>>;
23
+ index: z.ZodOptional<z.ZodNumber>;
24
+ }, z.core.$strip>, z.ZodObject<{
25
+ type: z.ZodLiteral<ReasoningDetailType.Encrypted>;
26
+ data: z.ZodString;
27
+ id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
28
+ format: z.ZodOptional<z.ZodNullable<z.ZodEnum<typeof ReasoningFormat>>>;
29
+ index: z.ZodOptional<z.ZodNumber>;
30
+ }, z.core.$strip>, z.ZodObject<{
31
+ type: z.ZodLiteral<ReasoningDetailType.Text>;
32
+ text: z.ZodOptional<z.ZodNullable<z.ZodString>>;
33
+ signature: z.ZodOptional<z.ZodNullable<z.ZodString>>;
34
+ id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
35
+ format: z.ZodOptional<z.ZodNullable<z.ZodEnum<typeof ReasoningFormat>>>;
36
+ index: z.ZodOptional<z.ZodNumber>;
37
+ }, z.core.$strip>]>;
38
+ type ReasoningDetailUnion = z.infer<typeof ReasoningDetailUnionSchema>;
3
39
 
4
40
  type OpenRouterProviderOptions = {
5
41
  models?: string[];
@@ -158,18 +194,21 @@ type OpenRouterChatSettings = {
158
194
  */
159
195
  user?: string;
160
196
  /**
161
- * Web search plugin configuration for enabling web search capabilities
197
+ * Plugin configurations for enabling various capabilities
162
198
  */
163
199
  plugins?: Array<{
164
- id: 'web';
165
- /**
166
- * Maximum number of search results to include (default: 5)
167
- */
200
+ id: models.IdWeb;
168
201
  max_results?: number;
169
- /**
170
- * Custom search prompt to guide the search query
171
- */
172
202
  search_prompt?: string;
203
+ engine?: models.Engine;
204
+ } | {
205
+ id: models.IdFileParser;
206
+ max_files?: number;
207
+ pdf?: {
208
+ engine?: models.PdfEngine;
209
+ };
210
+ } | {
211
+ id: models.IdModeration;
173
212
  }>;
174
213
  /**
175
214
  * Built-in web search options for models that support native web search
@@ -203,7 +242,7 @@ type OpenRouterChatSettings = {
203
242
  /**
204
243
  * Control whether to use providers that may store data
205
244
  */
206
- data_collection?: 'allow' | 'deny';
245
+ data_collection?: models.DataCollection;
207
246
  /**
208
247
  * List of provider slugs to allow for this request
209
248
  */
@@ -215,11 +254,11 @@ type OpenRouterChatSettings = {
215
254
  /**
216
255
  * List of quantization levels to filter by (e.g. ["int4", "int8"])
217
256
  */
218
- quantizations?: Array<'int4' | 'int8' | 'fp4' | 'fp6' | 'fp8' | 'fp16' | 'bf16' | 'fp32' | 'unknown'>;
257
+ quantizations?: Array<models.Quantization>;
219
258
  /**
220
259
  * Sort providers by price, throughput, or latency
221
260
  */
222
- sort?: 'price' | 'throughput' | 'latency';
261
+ sort?: models.Sort;
223
262
  /**
224
263
  * Maximum pricing you want to pay for this request
225
264
  */
@@ -262,6 +301,7 @@ declare class OpenRouterChatLanguageModel implements LanguageModelV2 {
262
301
  providerMetadata?: {
263
302
  openrouter: {
264
303
  provider: string;
304
+ reasoning_details?: ReasoningDetailUnion[];
265
305
  usage: OpenRouterUsageAccounting;
266
306
  };
267
307
  };
@@ -1,5 +1,41 @@
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';
4
+ import * as models from '@openrouter/sdk/models';
5
+
6
+ declare enum ReasoningFormat {
7
+ Unknown = "unknown",
8
+ OpenAIResponsesV1 = "openai-responses-v1",
9
+ XAIResponsesV1 = "xai-responses-v1",
10
+ AnthropicClaudeV1 = "anthropic-claude-v1"
11
+ }
12
+
13
+ declare enum ReasoningDetailType {
14
+ Summary = "reasoning.summary",
15
+ Encrypted = "reasoning.encrypted",
16
+ Text = "reasoning.text"
17
+ }
18
+ declare const ReasoningDetailUnionSchema: z.ZodUnion<readonly [z.ZodObject<{
19
+ type: z.ZodLiteral<ReasoningDetailType.Summary>;
20
+ summary: z.ZodString;
21
+ id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
22
+ format: z.ZodOptional<z.ZodNullable<z.ZodEnum<typeof ReasoningFormat>>>;
23
+ index: z.ZodOptional<z.ZodNumber>;
24
+ }, z.core.$strip>, z.ZodObject<{
25
+ type: z.ZodLiteral<ReasoningDetailType.Encrypted>;
26
+ data: z.ZodString;
27
+ id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
28
+ format: z.ZodOptional<z.ZodNullable<z.ZodEnum<typeof ReasoningFormat>>>;
29
+ index: z.ZodOptional<z.ZodNumber>;
30
+ }, z.core.$strip>, z.ZodObject<{
31
+ type: z.ZodLiteral<ReasoningDetailType.Text>;
32
+ text: z.ZodOptional<z.ZodNullable<z.ZodString>>;
33
+ signature: z.ZodOptional<z.ZodNullable<z.ZodString>>;
34
+ id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
35
+ format: z.ZodOptional<z.ZodNullable<z.ZodEnum<typeof ReasoningFormat>>>;
36
+ index: z.ZodOptional<z.ZodNumber>;
37
+ }, z.core.$strip>]>;
38
+ type ReasoningDetailUnion = z.infer<typeof ReasoningDetailUnionSchema>;
3
39
 
4
40
  type OpenRouterProviderOptions = {
5
41
  models?: string[];
@@ -158,18 +194,21 @@ type OpenRouterChatSettings = {
158
194
  */
159
195
  user?: string;
160
196
  /**
161
- * Web search plugin configuration for enabling web search capabilities
197
+ * Plugin configurations for enabling various capabilities
162
198
  */
163
199
  plugins?: Array<{
164
- id: 'web';
165
- /**
166
- * Maximum number of search results to include (default: 5)
167
- */
200
+ id: models.IdWeb;
168
201
  max_results?: number;
169
- /**
170
- * Custom search prompt to guide the search query
171
- */
172
202
  search_prompt?: string;
203
+ engine?: models.Engine;
204
+ } | {
205
+ id: models.IdFileParser;
206
+ max_files?: number;
207
+ pdf?: {
208
+ engine?: models.PdfEngine;
209
+ };
210
+ } | {
211
+ id: models.IdModeration;
173
212
  }>;
174
213
  /**
175
214
  * Built-in web search options for models that support native web search
@@ -203,7 +242,7 @@ type OpenRouterChatSettings = {
203
242
  /**
204
243
  * Control whether to use providers that may store data
205
244
  */
206
- data_collection?: 'allow' | 'deny';
245
+ data_collection?: models.DataCollection;
207
246
  /**
208
247
  * List of provider slugs to allow for this request
209
248
  */
@@ -215,11 +254,11 @@ type OpenRouterChatSettings = {
215
254
  /**
216
255
  * List of quantization levels to filter by (e.g. ["int4", "int8"])
217
256
  */
218
- quantizations?: Array<'int4' | 'int8' | 'fp4' | 'fp6' | 'fp8' | 'fp16' | 'bf16' | 'fp32' | 'unknown'>;
257
+ quantizations?: Array<models.Quantization>;
219
258
  /**
220
259
  * Sort providers by price, throughput, or latency
221
260
  */
222
- sort?: 'price' | 'throughput' | 'latency';
261
+ sort?: models.Sort;
223
262
  /**
224
263
  * Maximum pricing you want to pay for this request
225
264
  */
@@ -262,6 +301,7 @@ declare class OpenRouterChatLanguageModel implements LanguageModelV2 {
262
301
  providerMetadata?: {
263
302
  openrouter: {
264
303
  provider: string;
304
+ reasoning_details?: ReasoningDetailUnion[];
265
305
  usage: OpenRouterUsageAccounting;
266
306
  };
267
307
  };