@openrouter/sdk 0.3.11 → 0.3.14

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.
Files changed (70) hide show
  1. package/esm/index.d.ts +1 -0
  2. package/esm/index.js +2 -0
  3. package/esm/lib/anthropic-compat.test.js +3 -0
  4. package/esm/lib/chat-compat.test.js +3 -0
  5. package/esm/lib/config.d.ts +2 -2
  6. package/esm/lib/config.js +2 -2
  7. package/esm/lib/model-result.d.ts +8 -3
  8. package/esm/lib/model-result.js +57 -35
  9. package/esm/lib/tool-event-broadcaster.d.ts +44 -0
  10. package/esm/lib/tool-event-broadcaster.js +146 -0
  11. package/esm/lib/tool-executor.d.ts +21 -6
  12. package/esm/lib/tool-executor.js +57 -8
  13. package/esm/lib/tool-types.d.ts +18 -18
  14. package/esm/lib/tool.d.ts +16 -16
  15. package/esm/models/chatgenerationparams.d.ts +93 -12
  16. package/esm/models/chatgenerationparams.js +75 -6
  17. package/esm/models/chatgenerationtokenusage.d.ts +1 -0
  18. package/esm/models/chatgenerationtokenusage.js +2 -0
  19. package/esm/models/chatmessagetokenlogprob.d.ts +4 -4
  20. package/esm/models/chatmessagetokenlogprob.js +4 -5
  21. package/esm/models/index.d.ts +7 -0
  22. package/esm/models/index.js +7 -0
  23. package/esm/models/openairesponsesinputunion.d.ts +15 -5
  24. package/esm/models/openairesponsesinputunion.js +5 -5
  25. package/esm/models/openresponseseasyinputmessage.d.ts +41 -16
  26. package/esm/models/openresponseseasyinputmessage.js +38 -13
  27. package/esm/models/openresponsesinputmessageitem.d.ts +37 -12
  28. package/esm/models/openresponsesinputmessageitem.js +33 -9
  29. package/esm/models/openresponsesnonstreamingresponse.d.ts +5 -2
  30. package/esm/models/openresponsesnonstreamingresponse.js +8 -2
  31. package/esm/models/openresponsesreasoning.d.ts +1 -0
  32. package/esm/models/openresponsesreasoning.js +1 -0
  33. package/esm/models/openresponsesrequest.d.ts +61 -24
  34. package/esm/models/openresponsesrequest.js +39 -6
  35. package/esm/models/operations/getgeneration.d.ts +4 -0
  36. package/esm/models/operations/getgeneration.js +1 -0
  37. package/esm/models/percentilelatencycutoffs.d.ts +33 -0
  38. package/esm/models/percentilelatencycutoffs.js +16 -0
  39. package/esm/models/percentilestats.d.ts +28 -0
  40. package/esm/models/percentilestats.js +17 -0
  41. package/esm/models/percentilethroughputcutoffs.d.ts +33 -0
  42. package/esm/models/percentilethroughputcutoffs.js +16 -0
  43. package/esm/models/preferredmaxlatency.d.ts +12 -0
  44. package/esm/models/preferredmaxlatency.js +12 -0
  45. package/esm/models/preferredminthroughput.d.ts +12 -0
  46. package/esm/models/preferredminthroughput.js +12 -0
  47. package/esm/models/providername.d.ts +3 -2
  48. package/esm/models/providername.js +3 -2
  49. package/esm/models/providerpreferences.d.ts +8 -20
  50. package/esm/models/providerpreferences.js +6 -6
  51. package/esm/models/publicendpoint.d.ts +6 -0
  52. package/esm/models/publicendpoint.js +5 -0
  53. package/esm/models/responseinputimage.d.ts +11 -3
  54. package/esm/models/responseinputimage.js +9 -2
  55. package/esm/models/responseinputvideo.d.ts +20 -0
  56. package/esm/models/responseinputvideo.js +19 -0
  57. package/esm/models/responseoutputtext.d.ts +38 -0
  58. package/esm/models/responseoutputtext.js +50 -0
  59. package/esm/models/responsesoutputitemreasoning.d.ts +30 -1
  60. package/esm/models/responsesoutputitemreasoning.js +22 -0
  61. package/esm/models/responsesoutputmodality.d.ts +10 -0
  62. package/esm/models/responsesoutputmodality.js +12 -0
  63. package/esm/models/schema0.d.ts +3 -2
  64. package/esm/models/schema0.js +3 -2
  65. package/esm/models/schema3.d.ts +1 -0
  66. package/esm/models/schema3.js +1 -0
  67. package/jsr.json +1 -1
  68. package/package.json +6 -7
  69. package/vitest.config.ts +25 -16
  70. package/.zed/settings.json +0 -10
@@ -1,4 +1,4 @@
1
- import type { ZodObject, ZodRawShape, ZodType, z } from 'zod';
1
+ import type { $ZodObject, $ZodShape, $ZodType, infer as zodInfer } from 'zod/v4/core';
2
2
  import type * as models from '../models/index.js';
3
3
  import type { OpenResponsesStreamEvent } from '../models/index.js';
4
4
  import type { ModelResult } from './model-result.js';
@@ -53,18 +53,18 @@ export type NextTurnParamsFunctions<TInput> = {
53
53
  /**
54
54
  * Base tool function interface with inputSchema
55
55
  */
56
- export interface BaseToolFunction<TInput extends ZodObject<ZodRawShape>> {
56
+ export interface BaseToolFunction<TInput extends $ZodObject<$ZodShape>> {
57
57
  name: string;
58
58
  description?: string;
59
59
  inputSchema: TInput;
60
- nextTurnParams?: NextTurnParamsFunctions<z.infer<TInput>>;
60
+ nextTurnParams?: NextTurnParamsFunctions<zodInfer<TInput>>;
61
61
  }
62
62
  /**
63
63
  * Regular tool with synchronous or asynchronous execute function and optional outputSchema
64
64
  */
65
- export interface ToolFunctionWithExecute<TInput extends ZodObject<ZodRawShape>, TOutput extends ZodType = ZodType<unknown>> extends BaseToolFunction<TInput> {
65
+ export interface ToolFunctionWithExecute<TInput extends $ZodObject<$ZodShape>, TOutput extends $ZodType = $ZodType<unknown>> extends BaseToolFunction<TInput> {
66
66
  outputSchema?: TOutput;
67
- execute: (params: z.infer<TInput>, context?: TurnContext) => Promise<z.infer<TOutput>> | z.infer<TOutput>;
67
+ execute: (params: zodInfer<TInput>, context?: TurnContext) => Promise<zodInfer<TOutput>> | zodInfer<TOutput>;
68
68
  }
69
69
  /**
70
70
  * Generator-based tool with async generator execute function
@@ -88,42 +88,42 @@ export interface ToolFunctionWithExecute<TInput extends ZodObject<ZodRawShape>,
88
88
  * }
89
89
  * ```
90
90
  */
91
- export interface ToolFunctionWithGenerator<TInput extends ZodObject<ZodRawShape>, TEvent extends ZodType = ZodType<unknown>, TOutput extends ZodType = ZodType<unknown>> extends BaseToolFunction<TInput> {
91
+ export interface ToolFunctionWithGenerator<TInput extends $ZodObject<$ZodShape>, TEvent extends $ZodType = $ZodType<unknown>, TOutput extends $ZodType = $ZodType<unknown>> extends BaseToolFunction<TInput> {
92
92
  eventSchema: TEvent;
93
93
  outputSchema: TOutput;
94
- execute: (params: z.infer<TInput>, context?: TurnContext) => AsyncGenerator<z.infer<TEvent> | z.infer<TOutput>>;
94
+ execute: (params: zodInfer<TInput>, context?: TurnContext) => AsyncGenerator<zodInfer<TEvent> | zodInfer<TOutput>>;
95
95
  }
96
96
  /**
97
97
  * Manual tool without execute function - requires manual handling by developer
98
98
  */
99
- export interface ManualToolFunction<TInput extends ZodObject<ZodRawShape>, TOutput extends ZodType = ZodType<unknown>> extends BaseToolFunction<TInput> {
99
+ export interface ManualToolFunction<TInput extends $ZodObject<$ZodShape>, TOutput extends $ZodType = $ZodType<unknown>> extends BaseToolFunction<TInput> {
100
100
  outputSchema?: TOutput;
101
101
  }
102
102
  /**
103
103
  * Tool with execute function (regular or generator)
104
104
  */
105
- export type ToolWithExecute<TInput extends ZodObject<ZodRawShape> = ZodObject<ZodRawShape>, TOutput extends ZodType = ZodType<unknown>> = {
105
+ export type ToolWithExecute<TInput extends $ZodObject<$ZodShape> = $ZodObject<$ZodShape>, TOutput extends $ZodType = $ZodType<unknown>> = {
106
106
  type: ToolType.Function;
107
107
  function: ToolFunctionWithExecute<TInput, TOutput>;
108
108
  };
109
109
  /**
110
110
  * Tool with generator execute function
111
111
  */
112
- export type ToolWithGenerator<TInput extends ZodObject<ZodRawShape> = ZodObject<ZodRawShape>, TEvent extends ZodType = ZodType<unknown>, TOutput extends ZodType = ZodType<unknown>> = {
112
+ export type ToolWithGenerator<TInput extends $ZodObject<$ZodShape> = $ZodObject<$ZodShape>, TEvent extends $ZodType = $ZodType<unknown>, TOutput extends $ZodType = $ZodType<unknown>> = {
113
113
  type: ToolType.Function;
114
114
  function: ToolFunctionWithGenerator<TInput, TEvent, TOutput>;
115
115
  };
116
116
  /**
117
117
  * Tool without execute function (manual handling)
118
118
  */
119
- export type ManualTool<TInput extends ZodObject<ZodRawShape> = ZodObject<ZodRawShape>, TOutput extends ZodType = ZodType<unknown>> = {
119
+ export type ManualTool<TInput extends $ZodObject<$ZodShape> = $ZodObject<$ZodShape>, TOutput extends $ZodType = $ZodType<unknown>> = {
120
120
  type: ToolType.Function;
121
121
  function: ManualToolFunction<TInput, TOutput>;
122
122
  };
123
123
  /**
124
124
  * Union type of all enhanced tool types
125
125
  */
126
- export type Tool = ToolWithExecute<ZodObject<ZodRawShape>, ZodType<unknown>> | ToolWithGenerator<ZodObject<ZodRawShape>, ZodType<unknown>, ZodType<unknown>> | ManualTool<ZodObject<ZodRawShape>, ZodType<unknown>>;
126
+ export type Tool = ToolWithExecute<$ZodObject<$ZodShape>, $ZodType<unknown>> | ToolWithGenerator<$ZodObject<$ZodShape>, $ZodType<unknown>, $ZodType<unknown>> | ManualTool<$ZodObject<$ZodShape>, $ZodType<unknown>>;
127
127
  /**
128
128
  * Extracts the input type from a tool definition
129
129
  */
@@ -131,7 +131,7 @@ export type InferToolInput<T> = T extends {
131
131
  function: {
132
132
  inputSchema: infer S;
133
133
  };
134
- } ? S extends ZodType ? z.infer<S> : unknown : unknown;
134
+ } ? S extends $ZodType ? zodInfer<S> : unknown : unknown;
135
135
  /**
136
136
  * Extracts the output type from a tool definition
137
137
  */
@@ -139,7 +139,7 @@ export type InferToolOutput<T> = T extends {
139
139
  function: {
140
140
  outputSchema: infer S;
141
141
  };
142
- } ? S extends ZodType ? z.infer<S> : unknown : unknown;
142
+ } ? S extends $ZodType ? zodInfer<S> : unknown : unknown;
143
143
  /**
144
144
  * A tool call with typed arguments based on the tool's inputSchema
145
145
  */
@@ -172,7 +172,7 @@ export type InferToolEvent<T> = T extends {
172
172
  function: {
173
173
  eventSchema: infer S;
174
174
  };
175
- } ? S extends ZodType ? z.infer<S> : never : never;
175
+ } ? S extends $ZodType ? zodInfer<S> : never : never;
176
176
  /**
177
177
  * Union of event types for all generator tools in a tuple
178
178
  * Filters out non-generator tools (which return `never`)
@@ -216,8 +216,8 @@ export interface ParsedToolCall<T extends Tool> {
216
216
  export interface ToolExecutionResult<T extends Tool> {
217
217
  toolCallId: string;
218
218
  toolName: string;
219
- result: T extends ToolWithExecute<any, infer O> | ToolWithGenerator<any, any, infer O> ? z.infer<O> : unknown;
220
- preliminaryResults?: T extends ToolWithGenerator<any, infer E, any> ? z.infer<E>[] : undefined;
219
+ result: T extends ToolWithExecute<any, infer O> | ToolWithGenerator<any, any, infer O> ? zodInfer<O> : unknown;
220
+ preliminaryResults?: T extends ToolWithGenerator<any, infer E, any> ? zodInfer<E>[] : undefined;
221
221
  error?: Error;
222
222
  }
223
223
  /**
@@ -237,7 +237,7 @@ export interface StepResult<TTools extends readonly Tool[] = readonly Tool[]> {
237
237
  readonly toolCalls: TypedToolCallUnion<TTools>[];
238
238
  readonly toolResults: ToolExecutionResultUnion<TTools>[];
239
239
  readonly response: models.OpenResponsesNonStreamingResponse;
240
- readonly usage?: models.OpenResponsesUsage | undefined;
240
+ readonly usage?: models.OpenResponsesUsage | null | undefined;
241
241
  readonly finishReason?: string | undefined;
242
242
  readonly warnings?: Warning[] | undefined;
243
243
  readonly experimental_providerMetadata?: Record<string, unknown> | undefined;
package/esm/lib/tool.d.ts CHANGED
@@ -1,49 +1,49 @@
1
- import type { ZodObject, ZodRawShape, ZodType, z } from "zod";
1
+ import type { $ZodObject, $ZodShape, $ZodType, infer as zodInfer } from 'zod/v4/core';
2
2
  import { type TurnContext, type ToolWithExecute, type ToolWithGenerator, type ManualTool, type NextTurnParamsFunctions } from "./tool-types.js";
3
3
  /**
4
4
  * Configuration for a regular tool with outputSchema
5
5
  */
6
- type RegularToolConfigWithOutput<TInput extends ZodObject<ZodRawShape>, TOutput extends ZodType> = {
6
+ type RegularToolConfigWithOutput<TInput extends $ZodObject<$ZodShape>, TOutput extends $ZodType> = {
7
7
  name: string;
8
8
  description?: string;
9
9
  inputSchema: TInput;
10
10
  outputSchema: TOutput;
11
11
  eventSchema?: undefined;
12
- nextTurnParams?: NextTurnParamsFunctions<z.infer<TInput>>;
13
- execute: (params: z.infer<TInput>, context?: TurnContext) => Promise<z.infer<TOutput>> | z.infer<TOutput>;
12
+ nextTurnParams?: NextTurnParamsFunctions<zodInfer<TInput>>;
13
+ execute: (params: zodInfer<TInput>, context?: TurnContext) => Promise<zodInfer<TOutput>> | zodInfer<TOutput>;
14
14
  };
15
15
  /**
16
16
  * Configuration for a regular tool without outputSchema (infers return type from execute)
17
17
  */
18
- type RegularToolConfigWithoutOutput<TInput extends ZodObject<ZodRawShape>, TReturn> = {
18
+ type RegularToolConfigWithoutOutput<TInput extends $ZodObject<$ZodShape>, TReturn> = {
19
19
  name: string;
20
20
  description?: string;
21
21
  inputSchema: TInput;
22
22
  outputSchema?: undefined;
23
23
  eventSchema?: undefined;
24
- nextTurnParams?: NextTurnParamsFunctions<z.infer<TInput>>;
25
- execute: (params: z.infer<TInput>, context?: TurnContext) => Promise<TReturn> | TReturn;
24
+ nextTurnParams?: NextTurnParamsFunctions<zodInfer<TInput>>;
25
+ execute: (params: zodInfer<TInput>, context?: TurnContext) => Promise<TReturn> | TReturn;
26
26
  };
27
27
  /**
28
28
  * Configuration for a generator tool (with eventSchema)
29
29
  */
30
- type GeneratorToolConfig<TInput extends ZodObject<ZodRawShape>, TEvent extends ZodType, TOutput extends ZodType> = {
30
+ type GeneratorToolConfig<TInput extends $ZodObject<$ZodShape>, TEvent extends $ZodType, TOutput extends $ZodType> = {
31
31
  name: string;
32
32
  description?: string;
33
33
  inputSchema: TInput;
34
34
  eventSchema: TEvent;
35
35
  outputSchema: TOutput;
36
- nextTurnParams?: NextTurnParamsFunctions<z.infer<TInput>>;
37
- execute: (params: z.infer<TInput>, context?: TurnContext) => AsyncGenerator<z.infer<TEvent> | z.infer<TOutput>>;
36
+ nextTurnParams?: NextTurnParamsFunctions<zodInfer<TInput>>;
37
+ execute: (params: zodInfer<TInput>, context?: TurnContext) => AsyncGenerator<zodInfer<TEvent> | zodInfer<TOutput>>;
38
38
  };
39
39
  /**
40
40
  * Configuration for a manual tool (execute: false, no eventSchema or outputSchema)
41
41
  */
42
- type ManualToolConfig<TInput extends ZodObject<ZodRawShape>> = {
42
+ type ManualToolConfig<TInput extends $ZodObject<$ZodShape>> = {
43
43
  name: string;
44
44
  description?: string;
45
45
  inputSchema: TInput;
46
- nextTurnParams?: NextTurnParamsFunctions<z.infer<TInput>>;
46
+ nextTurnParams?: NextTurnParamsFunctions<zodInfer<TInput>>;
47
47
  execute: false;
48
48
  };
49
49
  /**
@@ -91,9 +91,9 @@ type ManualToolConfig<TInput extends ZodObject<ZodRawShape>> = {
91
91
  * });
92
92
  * ```
93
93
  */
94
- export declare function tool<TInput extends ZodObject<ZodRawShape>, TEvent extends ZodType, TOutput extends ZodType>(config: GeneratorToolConfig<TInput, TEvent, TOutput>): ToolWithGenerator<TInput, TEvent, TOutput>;
95
- export declare function tool<TInput extends ZodObject<ZodRawShape>>(config: ManualToolConfig<TInput>): ManualTool<TInput>;
96
- export declare function tool<TInput extends ZodObject<ZodRawShape>, TOutput extends ZodType>(config: RegularToolConfigWithOutput<TInput, TOutput>): ToolWithExecute<TInput, TOutput>;
97
- export declare function tool<TInput extends ZodObject<ZodRawShape>, TReturn>(config: RegularToolConfigWithoutOutput<TInput, TReturn>): ToolWithExecute<TInput, ZodType<TReturn>>;
94
+ export declare function tool<TInput extends $ZodObject<$ZodShape>, TEvent extends $ZodType, TOutput extends $ZodType>(config: GeneratorToolConfig<TInput, TEvent, TOutput>): ToolWithGenerator<TInput, TEvent, TOutput>;
95
+ export declare function tool<TInput extends $ZodObject<$ZodShape>>(config: ManualToolConfig<TInput>): ManualTool<TInput>;
96
+ export declare function tool<TInput extends $ZodObject<$ZodShape>, TOutput extends $ZodType>(config: RegularToolConfigWithOutput<TInput, TOutput>): ToolWithExecute<TInput, TOutput>;
97
+ export declare function tool<TInput extends $ZodObject<$ZodShape>, TReturn>(config: RegularToolConfigWithoutOutput<TInput, TReturn>): ToolWithExecute<TInput, $ZodType<TReturn>>;
98
98
  export {};
99
99
  //# sourceMappingURL=tool.d.ts.map
@@ -35,6 +35,20 @@ export type ChatGenerationParamsMaxPrice = {
35
35
  audio?: any | undefined;
36
36
  request?: any | undefined;
37
37
  };
38
+ export type ChatGenerationParamsPreferredMinThroughput = {
39
+ p50?: number | null | undefined;
40
+ p75?: number | null | undefined;
41
+ p90?: number | null | undefined;
42
+ p99?: number | null | undefined;
43
+ };
44
+ export type ChatGenerationParamsPreferredMinThroughputUnion = number | ChatGenerationParamsPreferredMinThroughput;
45
+ export type ChatGenerationParamsPreferredMaxLatency = {
46
+ p50?: number | null | undefined;
47
+ p75?: number | null | undefined;
48
+ p90?: number | null | undefined;
49
+ p99?: number | null | undefined;
50
+ };
51
+ export type ChatGenerationParamsPreferredMaxLatencyUnion = number | ChatGenerationParamsPreferredMaxLatency;
38
52
  export type ChatGenerationParamsProvider = {
39
53
  /**
40
54
  * Whether to allow backup providers to serve requests
@@ -83,10 +97,14 @@ export type ChatGenerationParamsProvider = {
83
97
  * The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion.
84
98
  */
85
99
  maxPrice?: ChatGenerationParamsMaxPrice | undefined;
86
- preferredMinThroughput?: number | null | undefined;
87
- preferredMaxLatency?: number | null | undefined;
88
- minThroughput?: number | null | undefined;
89
- maxLatency?: number | null | undefined;
100
+ /**
101
+ * Preferred minimum throughput (in tokens per second). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints below the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold.
102
+ */
103
+ preferredMinThroughput?: number | ChatGenerationParamsPreferredMinThroughput | null | undefined;
104
+ /**
105
+ * Preferred maximum latency (in seconds). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints above the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold.
106
+ */
107
+ preferredMaxLatency?: number | ChatGenerationParamsPreferredMaxLatency | null | undefined;
90
108
  };
91
109
  export type ChatGenerationParamsPluginResponseHealing = {
92
110
  id: "response-healing";
@@ -121,7 +139,12 @@ export type ChatGenerationParamsPluginWeb = {
121
139
  export type ChatGenerationParamsPluginModeration = {
122
140
  id: "moderation";
123
141
  };
124
- export type ChatGenerationParamsPluginUnion = ChatGenerationParamsPluginModeration | ChatGenerationParamsPluginWeb | ChatGenerationParamsPluginFileParser | ChatGenerationParamsPluginResponseHealing;
142
+ export type ChatGenerationParamsPluginAutoRouter = {
143
+ id: "auto-router";
144
+ enabled?: boolean | undefined;
145
+ allowedModels?: Array<string> | undefined;
146
+ };
147
+ export type ChatGenerationParamsPluginUnion = ChatGenerationParamsPluginAutoRouter | ChatGenerationParamsPluginModeration | ChatGenerationParamsPluginWeb | ChatGenerationParamsPluginFileParser | ChatGenerationParamsPluginResponseHealing;
125
148
  export declare const Route: {
126
149
  readonly Fallback: "fallback";
127
150
  readonly Sort: "sort";
@@ -154,6 +177,12 @@ export type ChatGenerationParamsStop = string | Array<string>;
154
177
  export type Debug = {
155
178
  echoUpstreamBody?: boolean | undefined;
156
179
  };
180
+ export type ChatGenerationParamsImageConfig = string | number;
181
+ export declare const Modality: {
182
+ readonly Text: "text";
183
+ readonly Image: "image";
184
+ };
185
+ export type Modality = OpenEnum<typeof Modality>;
157
186
  export type ChatGenerationParams = {
158
187
  /**
159
188
  * When multiple model providers are available, optionally indicate your routing preference.
@@ -162,7 +191,7 @@ export type ChatGenerationParams = {
162
191
  /**
163
192
  * Plugins you want to enable for this request, including their settings.
164
193
  */
165
- plugins?: Array<ChatGenerationParamsPluginModeration | ChatGenerationParamsPluginWeb | ChatGenerationParamsPluginFileParser | ChatGenerationParamsPluginResponseHealing> | undefined;
194
+ plugins?: Array<ChatGenerationParamsPluginAutoRouter | ChatGenerationParamsPluginModeration | ChatGenerationParamsPluginWeb | ChatGenerationParamsPluginFileParser | ChatGenerationParamsPluginResponseHealing> | undefined;
166
195
  route?: Route | null | undefined;
167
196
  user?: string | undefined;
168
197
  /**
@@ -195,6 +224,10 @@ export type ChatGenerationParams = {
195
224
  tools?: Array<ToolDefinitionJson> | undefined;
196
225
  topP?: number | null | undefined;
197
226
  debug?: Debug | undefined;
227
+ imageConfig?: {
228
+ [k: string]: string | number;
229
+ } | undefined;
230
+ modalities?: Array<Modality> | undefined;
198
231
  };
199
232
  /** @internal */
200
233
  export declare const ChatGenerationParamsDataCollection$outboundSchema: z.ZodType<string, ChatGenerationParamsDataCollection>;
@@ -212,6 +245,36 @@ export type ChatGenerationParamsMaxPrice$Outbound = {
212
245
  export declare const ChatGenerationParamsMaxPrice$outboundSchema: z.ZodType<ChatGenerationParamsMaxPrice$Outbound, ChatGenerationParamsMaxPrice>;
213
246
  export declare function chatGenerationParamsMaxPriceToJSON(chatGenerationParamsMaxPrice: ChatGenerationParamsMaxPrice): string;
214
247
  /** @internal */
248
+ export type ChatGenerationParamsPreferredMinThroughput$Outbound = {
249
+ p50?: number | null | undefined;
250
+ p75?: number | null | undefined;
251
+ p90?: number | null | undefined;
252
+ p99?: number | null | undefined;
253
+ };
254
+ /** @internal */
255
+ export declare const ChatGenerationParamsPreferredMinThroughput$outboundSchema: z.ZodType<ChatGenerationParamsPreferredMinThroughput$Outbound, ChatGenerationParamsPreferredMinThroughput>;
256
+ export declare function chatGenerationParamsPreferredMinThroughputToJSON(chatGenerationParamsPreferredMinThroughput: ChatGenerationParamsPreferredMinThroughput): string;
257
+ /** @internal */
258
+ export type ChatGenerationParamsPreferredMinThroughputUnion$Outbound = number | ChatGenerationParamsPreferredMinThroughput$Outbound;
259
+ /** @internal */
260
+ export declare const ChatGenerationParamsPreferredMinThroughputUnion$outboundSchema: z.ZodType<ChatGenerationParamsPreferredMinThroughputUnion$Outbound, ChatGenerationParamsPreferredMinThroughputUnion>;
261
+ export declare function chatGenerationParamsPreferredMinThroughputUnionToJSON(chatGenerationParamsPreferredMinThroughputUnion: ChatGenerationParamsPreferredMinThroughputUnion): string;
262
+ /** @internal */
263
+ export type ChatGenerationParamsPreferredMaxLatency$Outbound = {
264
+ p50?: number | null | undefined;
265
+ p75?: number | null | undefined;
266
+ p90?: number | null | undefined;
267
+ p99?: number | null | undefined;
268
+ };
269
+ /** @internal */
270
+ export declare const ChatGenerationParamsPreferredMaxLatency$outboundSchema: z.ZodType<ChatGenerationParamsPreferredMaxLatency$Outbound, ChatGenerationParamsPreferredMaxLatency>;
271
+ export declare function chatGenerationParamsPreferredMaxLatencyToJSON(chatGenerationParamsPreferredMaxLatency: ChatGenerationParamsPreferredMaxLatency): string;
272
+ /** @internal */
273
+ export type ChatGenerationParamsPreferredMaxLatencyUnion$Outbound = number | ChatGenerationParamsPreferredMaxLatency$Outbound;
274
+ /** @internal */
275
+ export declare const ChatGenerationParamsPreferredMaxLatencyUnion$outboundSchema: z.ZodType<ChatGenerationParamsPreferredMaxLatencyUnion$Outbound, ChatGenerationParamsPreferredMaxLatencyUnion>;
276
+ export declare function chatGenerationParamsPreferredMaxLatencyUnionToJSON(chatGenerationParamsPreferredMaxLatencyUnion: ChatGenerationParamsPreferredMaxLatencyUnion): string;
277
+ /** @internal */
215
278
  export type ChatGenerationParamsProvider$Outbound = {
216
279
  allow_fallbacks?: boolean | null | undefined;
217
280
  require_parameters?: boolean | null | undefined;
@@ -224,10 +287,8 @@ export type ChatGenerationParamsProvider$Outbound = {
224
287
  quantizations?: Array<string> | null | undefined;
225
288
  sort?: ProviderSortUnion$Outbound | null | undefined;
226
289
  max_price?: ChatGenerationParamsMaxPrice$Outbound | undefined;
227
- preferred_min_throughput?: number | null | undefined;
228
- preferred_max_latency?: number | null | undefined;
229
- min_throughput?: number | null | undefined;
230
- max_latency?: number | null | undefined;
290
+ preferred_min_throughput?: number | ChatGenerationParamsPreferredMinThroughput$Outbound | null | undefined;
291
+ preferred_max_latency?: number | ChatGenerationParamsPreferredMaxLatency$Outbound | null | undefined;
231
292
  };
232
293
  /** @internal */
233
294
  export declare const ChatGenerationParamsProvider$outboundSchema: z.ZodType<ChatGenerationParamsProvider$Outbound, ChatGenerationParamsProvider>;
@@ -279,7 +340,16 @@ export type ChatGenerationParamsPluginModeration$Outbound = {
279
340
  export declare const ChatGenerationParamsPluginModeration$outboundSchema: z.ZodType<ChatGenerationParamsPluginModeration$Outbound, ChatGenerationParamsPluginModeration>;
280
341
  export declare function chatGenerationParamsPluginModerationToJSON(chatGenerationParamsPluginModeration: ChatGenerationParamsPluginModeration): string;
281
342
  /** @internal */
282
- export type ChatGenerationParamsPluginUnion$Outbound = ChatGenerationParamsPluginModeration$Outbound | ChatGenerationParamsPluginWeb$Outbound | ChatGenerationParamsPluginFileParser$Outbound | ChatGenerationParamsPluginResponseHealing$Outbound;
343
+ export type ChatGenerationParamsPluginAutoRouter$Outbound = {
344
+ id: "auto-router";
345
+ enabled?: boolean | undefined;
346
+ allowed_models?: Array<string> | undefined;
347
+ };
348
+ /** @internal */
349
+ export declare const ChatGenerationParamsPluginAutoRouter$outboundSchema: z.ZodType<ChatGenerationParamsPluginAutoRouter$Outbound, ChatGenerationParamsPluginAutoRouter>;
350
+ export declare function chatGenerationParamsPluginAutoRouterToJSON(chatGenerationParamsPluginAutoRouter: ChatGenerationParamsPluginAutoRouter): string;
351
+ /** @internal */
352
+ export type ChatGenerationParamsPluginUnion$Outbound = ChatGenerationParamsPluginAutoRouter$Outbound | ChatGenerationParamsPluginModeration$Outbound | ChatGenerationParamsPluginWeb$Outbound | ChatGenerationParamsPluginFileParser$Outbound | ChatGenerationParamsPluginResponseHealing$Outbound;
283
353
  /** @internal */
284
354
  export declare const ChatGenerationParamsPluginUnion$outboundSchema: z.ZodType<ChatGenerationParamsPluginUnion$Outbound, ChatGenerationParamsPluginUnion>;
285
355
  export declare function chatGenerationParamsPluginUnionToJSON(chatGenerationParamsPluginUnion: ChatGenerationParamsPluginUnion): string;
@@ -334,9 +404,16 @@ export type Debug$Outbound = {
334
404
  export declare const Debug$outboundSchema: z.ZodType<Debug$Outbound, Debug>;
335
405
  export declare function debugToJSON(debug: Debug): string;
336
406
  /** @internal */
407
+ export type ChatGenerationParamsImageConfig$Outbound = string | number;
408
+ /** @internal */
409
+ export declare const ChatGenerationParamsImageConfig$outboundSchema: z.ZodType<ChatGenerationParamsImageConfig$Outbound, ChatGenerationParamsImageConfig>;
410
+ export declare function chatGenerationParamsImageConfigToJSON(chatGenerationParamsImageConfig: ChatGenerationParamsImageConfig): string;
411
+ /** @internal */
412
+ export declare const Modality$outboundSchema: z.ZodType<string, Modality>;
413
+ /** @internal */
337
414
  export type ChatGenerationParams$Outbound = {
338
415
  provider?: ChatGenerationParamsProvider$Outbound | null | undefined;
339
- plugins?: Array<ChatGenerationParamsPluginModeration$Outbound | ChatGenerationParamsPluginWeb$Outbound | ChatGenerationParamsPluginFileParser$Outbound | ChatGenerationParamsPluginResponseHealing$Outbound> | undefined;
416
+ plugins?: Array<ChatGenerationParamsPluginAutoRouter$Outbound | ChatGenerationParamsPluginModeration$Outbound | ChatGenerationParamsPluginWeb$Outbound | ChatGenerationParamsPluginFileParser$Outbound | ChatGenerationParamsPluginResponseHealing$Outbound> | undefined;
340
417
  route?: string | null | undefined;
341
418
  user?: string | undefined;
342
419
  session_id?: string | undefined;
@@ -366,6 +443,10 @@ export type ChatGenerationParams$Outbound = {
366
443
  tools?: Array<ToolDefinitionJson$Outbound> | undefined;
367
444
  top_p?: number | null | undefined;
368
445
  debug?: Debug$Outbound | undefined;
446
+ image_config?: {
447
+ [k: string]: string | number;
448
+ } | undefined;
449
+ modalities?: Array<string> | undefined;
369
450
  };
370
451
  /** @internal */
371
452
  export declare const ChatGenerationParams$outboundSchema: z.ZodType<ChatGenerationParams$Outbound, ChatGenerationParams>;
@@ -49,6 +49,10 @@ export const Effort = {
49
49
  Minimal: "minimal",
50
50
  None: "none",
51
51
  };
52
+ export const Modality = {
53
+ Text: "text",
54
+ Image: "image",
55
+ };
52
56
  /** @internal */
53
57
  export const ChatGenerationParamsDataCollection$outboundSchema = openEnums.outboundSchema(ChatGenerationParamsDataCollection);
54
58
  /** @internal */
@@ -65,6 +69,42 @@ export function chatGenerationParamsMaxPriceToJSON(chatGenerationParamsMaxPrice)
65
69
  return JSON.stringify(ChatGenerationParamsMaxPrice$outboundSchema.parse(chatGenerationParamsMaxPrice));
66
70
  }
67
71
  /** @internal */
72
+ export const ChatGenerationParamsPreferredMinThroughput$outboundSchema = z.object({
73
+ p50: z.nullable(z.number()).optional(),
74
+ p75: z.nullable(z.number()).optional(),
75
+ p90: z.nullable(z.number()).optional(),
76
+ p99: z.nullable(z.number()).optional(),
77
+ });
78
+ export function chatGenerationParamsPreferredMinThroughputToJSON(chatGenerationParamsPreferredMinThroughput) {
79
+ return JSON.stringify(ChatGenerationParamsPreferredMinThroughput$outboundSchema.parse(chatGenerationParamsPreferredMinThroughput));
80
+ }
81
+ /** @internal */
82
+ export const ChatGenerationParamsPreferredMinThroughputUnion$outboundSchema = z.union([
83
+ z.number(),
84
+ z.lazy(() => ChatGenerationParamsPreferredMinThroughput$outboundSchema),
85
+ ]);
86
+ export function chatGenerationParamsPreferredMinThroughputUnionToJSON(chatGenerationParamsPreferredMinThroughputUnion) {
87
+ return JSON.stringify(ChatGenerationParamsPreferredMinThroughputUnion$outboundSchema.parse(chatGenerationParamsPreferredMinThroughputUnion));
88
+ }
89
+ /** @internal */
90
+ export const ChatGenerationParamsPreferredMaxLatency$outboundSchema = z.object({
91
+ p50: z.nullable(z.number()).optional(),
92
+ p75: z.nullable(z.number()).optional(),
93
+ p90: z.nullable(z.number()).optional(),
94
+ p99: z.nullable(z.number()).optional(),
95
+ });
96
+ export function chatGenerationParamsPreferredMaxLatencyToJSON(chatGenerationParamsPreferredMaxLatency) {
97
+ return JSON.stringify(ChatGenerationParamsPreferredMaxLatency$outboundSchema.parse(chatGenerationParamsPreferredMaxLatency));
98
+ }
99
+ /** @internal */
100
+ export const ChatGenerationParamsPreferredMaxLatencyUnion$outboundSchema = z.union([
101
+ z.number(),
102
+ z.lazy(() => ChatGenerationParamsPreferredMaxLatency$outboundSchema),
103
+ ]);
104
+ export function chatGenerationParamsPreferredMaxLatencyUnionToJSON(chatGenerationParamsPreferredMaxLatencyUnion) {
105
+ return JSON.stringify(ChatGenerationParamsPreferredMaxLatencyUnion$outboundSchema.parse(chatGenerationParamsPreferredMaxLatencyUnion));
106
+ }
107
+ /** @internal */
68
108
  export const ChatGenerationParamsProvider$outboundSchema = z.object({
69
109
  allowFallbacks: z.nullable(z.boolean()).optional(),
70
110
  requireParameters: z.nullable(z.boolean()).optional(),
@@ -79,10 +119,14 @@ export const ChatGenerationParamsProvider$outboundSchema = z.object({
79
119
  sort: z.nullable(ProviderSortUnion$outboundSchema).optional(),
80
120
  maxPrice: z.lazy(() => ChatGenerationParamsMaxPrice$outboundSchema)
81
121
  .optional(),
82
- preferredMinThroughput: z.nullable(z.number()).optional(),
83
- preferredMaxLatency: z.nullable(z.number()).optional(),
84
- minThroughput: z.nullable(z.number()).optional(),
85
- maxLatency: z.nullable(z.number()).optional(),
122
+ preferredMinThroughput: z.nullable(z.union([
123
+ z.number(),
124
+ z.lazy(() => ChatGenerationParamsPreferredMinThroughput$outboundSchema),
125
+ ])).optional(),
126
+ preferredMaxLatency: z.nullable(z.union([
127
+ z.number(),
128
+ z.lazy(() => ChatGenerationParamsPreferredMaxLatency$outboundSchema),
129
+ ])).optional(),
86
130
  }).transform((v) => {
87
131
  return remap$(v, {
88
132
  allowFallbacks: "allow_fallbacks",
@@ -92,8 +136,6 @@ export const ChatGenerationParamsProvider$outboundSchema = z.object({
92
136
  maxPrice: "max_price",
93
137
  preferredMinThroughput: "preferred_min_throughput",
94
138
  preferredMaxLatency: "preferred_max_latency",
95
- minThroughput: "min_throughput",
96
- maxLatency: "max_latency",
97
139
  });
98
140
  });
99
141
  export function chatGenerationParamsProviderToJSON(chatGenerationParamsProvider) {
@@ -153,7 +195,21 @@ export function chatGenerationParamsPluginModerationToJSON(chatGenerationParamsP
153
195
  return JSON.stringify(ChatGenerationParamsPluginModeration$outboundSchema.parse(chatGenerationParamsPluginModeration));
154
196
  }
155
197
  /** @internal */
198
+ export const ChatGenerationParamsPluginAutoRouter$outboundSchema = z.object({
199
+ id: z.literal("auto-router"),
200
+ enabled: z.boolean().optional(),
201
+ allowedModels: z.array(z.string()).optional(),
202
+ }).transform((v) => {
203
+ return remap$(v, {
204
+ allowedModels: "allowed_models",
205
+ });
206
+ });
207
+ export function chatGenerationParamsPluginAutoRouterToJSON(chatGenerationParamsPluginAutoRouter) {
208
+ return JSON.stringify(ChatGenerationParamsPluginAutoRouter$outboundSchema.parse(chatGenerationParamsPluginAutoRouter));
209
+ }
210
+ /** @internal */
156
211
  export const ChatGenerationParamsPluginUnion$outboundSchema = z.union([
212
+ z.lazy(() => ChatGenerationParamsPluginAutoRouter$outboundSchema),
157
213
  z.lazy(() => ChatGenerationParamsPluginModeration$outboundSchema),
158
214
  z.lazy(() => ChatGenerationParamsPluginWeb$outboundSchema),
159
215
  z.lazy(() => ChatGenerationParamsPluginFileParser$outboundSchema),
@@ -225,9 +281,18 @@ export function debugToJSON(debug) {
225
281
  return JSON.stringify(Debug$outboundSchema.parse(debug));
226
282
  }
227
283
  /** @internal */
284
+ export const ChatGenerationParamsImageConfig$outboundSchema = z.union([z.string(), z.number()]);
285
+ export function chatGenerationParamsImageConfigToJSON(chatGenerationParamsImageConfig) {
286
+ return JSON.stringify(ChatGenerationParamsImageConfig$outboundSchema.parse(chatGenerationParamsImageConfig));
287
+ }
288
+ /** @internal */
289
+ export const Modality$outboundSchema = openEnums
290
+ .outboundSchema(Modality);
291
+ /** @internal */
228
292
  export const ChatGenerationParams$outboundSchema = z.object({
229
293
  provider: z.nullable(z.lazy(() => ChatGenerationParamsProvider$outboundSchema)).optional(),
230
294
  plugins: z.array(z.union([
295
+ z.lazy(() => ChatGenerationParamsPluginAutoRouter$outboundSchema),
231
296
  z.lazy(() => ChatGenerationParamsPluginModeration$outboundSchema),
232
297
  z.lazy(() => ChatGenerationParamsPluginWeb$outboundSchema),
233
298
  z.lazy(() => ChatGenerationParamsPluginFileParser$outboundSchema),
@@ -264,6 +329,9 @@ export const ChatGenerationParams$outboundSchema = z.object({
264
329
  tools: z.array(ToolDefinitionJson$outboundSchema).optional(),
265
330
  topP: z.nullable(z.number()).optional(),
266
331
  debug: z.lazy(() => Debug$outboundSchema).optional(),
332
+ imageConfig: z.record(z.string(), z.union([z.string(), z.number()]))
333
+ .optional(),
334
+ modalities: z.array(Modality$outboundSchema).optional(),
267
335
  }).transform((v) => {
268
336
  return remap$(v, {
269
337
  sessionId: "session_id",
@@ -277,6 +345,7 @@ export const ChatGenerationParams$outboundSchema = z.object({
277
345
  streamOptions: "stream_options",
278
346
  toolChoice: "tool_choice",
279
347
  topP: "top_p",
348
+ imageConfig: "image_config",
280
349
  });
281
350
  });
282
351
  export function chatGenerationParamsToJSON(chatGenerationParams) {
@@ -9,6 +9,7 @@ export type CompletionTokensDetails = {
9
9
  };
10
10
  export type PromptTokensDetails = {
11
11
  cachedTokens?: number | undefined;
12
+ cacheWriteTokens?: number | undefined;
12
13
  audioTokens?: number | undefined;
13
14
  videoTokens?: number | undefined;
14
15
  };
@@ -25,11 +25,13 @@ export function completionTokensDetailsFromJSON(jsonString) {
25
25
  /** @internal */
26
26
  export const PromptTokensDetails$inboundSchema = z.object({
27
27
  cached_tokens: z.number().optional(),
28
+ cache_write_tokens: z.number().optional(),
28
29
  audio_tokens: z.number().optional(),
29
30
  video_tokens: z.number().optional(),
30
31
  }).transform((v) => {
31
32
  return remap$(v, {
32
33
  "cached_tokens": "cachedTokens",
34
+ "cache_write_tokens": "cacheWriteTokens",
33
35
  "audio_tokens": "audioTokens",
34
36
  "video_tokens": "videoTokens",
35
37
  });
@@ -1,7 +1,7 @@
1
1
  import * as z from "zod/v4";
2
2
  import { Result as SafeParseResult } from "../types/fp.js";
3
3
  import { SDKValidationError } from "./errors/sdkvalidationerror.js";
4
- export type TopLogprob = {
4
+ export type ChatMessageTokenLogprobTopLogprob = {
5
5
  token: string;
6
6
  logprob: number;
7
7
  bytes: Array<number> | null;
@@ -10,11 +10,11 @@ export type ChatMessageTokenLogprob = {
10
10
  token: string;
11
11
  logprob: number;
12
12
  bytes: Array<number> | null;
13
- topLogprobs: Array<TopLogprob>;
13
+ topLogprobs: Array<ChatMessageTokenLogprobTopLogprob>;
14
14
  };
15
15
  /** @internal */
16
- export declare const TopLogprob$inboundSchema: z.ZodType<TopLogprob, unknown>;
17
- export declare function topLogprobFromJSON(jsonString: string): SafeParseResult<TopLogprob, SDKValidationError>;
16
+ export declare const ChatMessageTokenLogprobTopLogprob$inboundSchema: z.ZodType<ChatMessageTokenLogprobTopLogprob, unknown>;
17
+ export declare function chatMessageTokenLogprobTopLogprobFromJSON(jsonString: string): SafeParseResult<ChatMessageTokenLogprobTopLogprob, SDKValidationError>;
18
18
  /** @internal */
19
19
  export declare const ChatMessageTokenLogprob$inboundSchema: z.ZodType<ChatMessageTokenLogprob, unknown>;
20
20
  export declare function chatMessageTokenLogprobFromJSON(jsonString: string): SafeParseResult<ChatMessageTokenLogprob, SDKValidationError>;
@@ -6,21 +6,20 @@ import * as z from "zod/v4";
6
6
  import { remap as remap$ } from "../lib/primitives.js";
7
7
  import { safeParse } from "../lib/schemas.js";
8
8
  /** @internal */
9
- export const TopLogprob$inboundSchema = z
10
- .object({
9
+ export const ChatMessageTokenLogprobTopLogprob$inboundSchema = z.object({
11
10
  token: z.string(),
12
11
  logprob: z.number(),
13
12
  bytes: z.nullable(z.array(z.number())),
14
13
  });
15
- export function topLogprobFromJSON(jsonString) {
16
- return safeParse(jsonString, (x) => TopLogprob$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TopLogprob' from JSON`);
14
+ export function chatMessageTokenLogprobTopLogprobFromJSON(jsonString) {
15
+ return safeParse(jsonString, (x) => ChatMessageTokenLogprobTopLogprob$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ChatMessageTokenLogprobTopLogprob' from JSON`);
17
16
  }
18
17
  /** @internal */
19
18
  export const ChatMessageTokenLogprob$inboundSchema = z.object({
20
19
  token: z.string(),
21
20
  logprob: z.number(),
22
21
  bytes: z.nullable(z.array(z.number())),
23
- top_logprobs: z.array(z.lazy(() => TopLogprob$inboundSchema)),
22
+ top_logprobs: z.array(z.lazy(() => ChatMessageTokenLogprobTopLogprob$inboundSchema)),
24
23
  }).transform((v) => {
25
24
  return remap$(v, {
26
25
  "top_logprobs": "topLogprobs",
@@ -97,7 +97,12 @@ export * from "./payloadtoolargeresponseerrordata.js";
97
97
  export * from "./paymentrequiredresponseerrordata.js";
98
98
  export * from "./pdfparserengine.js";
99
99
  export * from "./pdfparseroptions.js";
100
+ export * from "./percentilelatencycutoffs.js";
101
+ export * from "./percentilestats.js";
102
+ export * from "./percentilethroughputcutoffs.js";
100
103
  export * from "./perrequestlimits.js";
104
+ export * from "./preferredmaxlatency.js";
105
+ export * from "./preferredminthroughput.js";
101
106
  export * from "./providername.js";
102
107
  export * from "./provideroverloadedresponseerrordata.js";
103
108
  export * from "./providerpreferences.js";
@@ -118,6 +123,7 @@ export * from "./responseinputaudio.js";
118
123
  export * from "./responseinputfile.js";
119
124
  export * from "./responseinputimage.js";
120
125
  export * from "./responseinputtext.js";
126
+ export * from "./responseinputvideo.js";
121
127
  export * from "./responseoutputtext.js";
122
128
  export * from "./responseserrorfield.js";
123
129
  export * from "./responsesformatjsonobject.js";
@@ -129,6 +135,7 @@ export * from "./responsesoutputitemfilesearchcall.js";
129
135
  export * from "./responsesoutputitemfunctioncall.js";
130
136
  export * from "./responsesoutputitemreasoning.js";
131
137
  export * from "./responsesoutputmessage.js";
138
+ export * from "./responsesoutputmodality.js";
132
139
  export * from "./responsessearchcontextsize.js";
133
140
  export * from "./responseswebsearchcalloutput.js";
134
141
  export * from "./responseswebsearchuserlocation.js";