@openrouter/sdk 0.12.20 → 0.12.22

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 (66) hide show
  1. package/esm/lib/config.d.ts +2 -2
  2. package/esm/lib/config.js +2 -2
  3. package/esm/models/chatusage.d.ts +13 -0
  4. package/esm/models/chatusage.js +6 -0
  5. package/esm/models/costdetails.d.ts +15 -0
  6. package/esm/models/costdetails.js +24 -0
  7. package/esm/models/createworkspacerequest.d.ts +10 -0
  8. package/esm/models/createworkspacerequest.js +4 -0
  9. package/esm/models/generationresponse.d.ts +5 -0
  10. package/esm/models/generationresponse.js +3 -0
  11. package/esm/models/index.d.ts +1 -0
  12. package/esm/models/index.js +1 -0
  13. package/esm/models/inputsunion.d.ts +18 -4
  14. package/esm/models/inputsunion.js +42 -0
  15. package/esm/models/outputapplypatchservertoolitem.d.ts +21 -1
  16. package/esm/models/outputapplypatchservertoolitem.js +20 -2
  17. package/esm/models/outputbashservertoolitem.d.ts +23 -1
  18. package/esm/models/outputbashservertoolitem.js +22 -2
  19. package/esm/models/outputbrowseruseservertoolitem.d.ts +21 -1
  20. package/esm/models/outputbrowseruseservertoolitem.js +20 -2
  21. package/esm/models/outputcodeinterpretercallitem.d.ts +43 -1
  22. package/esm/models/outputcodeinterpretercallitem.js +52 -2
  23. package/esm/models/outputcodeinterpreterservertoolitem.d.ts +24 -1
  24. package/esm/models/outputcodeinterpreterservertoolitem.js +23 -2
  25. package/esm/models/outputcomputercallitem.d.ts +33 -2
  26. package/esm/models/outputcomputercallitem.js +36 -1
  27. package/esm/models/outputfilesearchservertoolitem.d.ts +20 -1
  28. package/esm/models/outputfilesearchservertoolitem.js +19 -2
  29. package/esm/models/outputimagegenerationservertoolitem.d.ts +23 -1
  30. package/esm/models/outputimagegenerationservertoolitem.js +22 -2
  31. package/esm/models/outputitems.d.ts +31 -3
  32. package/esm/models/outputitems.js +19 -14
  33. package/esm/models/outputmcpservertoolitem.d.ts +21 -1
  34. package/esm/models/outputmcpservertoolitem.js +20 -2
  35. package/esm/models/outputmemoryservertoolitem.d.ts +24 -2
  36. package/esm/models/outputmemoryservertoolitem.js +23 -2
  37. package/esm/models/outputmodality.d.ts +1 -0
  38. package/esm/models/outputmodality.js +1 -0
  39. package/esm/models/outputsearchmodelsservertoolitem.d.ts +21 -1
  40. package/esm/models/outputsearchmodelsservertoolitem.js +20 -2
  41. package/esm/models/outputtexteditorservertoolitem.d.ts +23 -2
  42. package/esm/models/outputtexteditorservertoolitem.js +23 -2
  43. package/esm/models/outputtoolsearchservertoolitem.d.ts +20 -1
  44. package/esm/models/outputtoolsearchservertoolitem.js +19 -2
  45. package/esm/models/outputwebfetchservertoolitem.d.ts +22 -1
  46. package/esm/models/outputwebfetchservertoolitem.js +21 -2
  47. package/esm/models/providername.d.ts +1 -0
  48. package/esm/models/providername.js +1 -0
  49. package/esm/models/providerresponse.d.ts +1 -0
  50. package/esm/models/providerresponse.js +1 -0
  51. package/esm/models/speechrequest.d.ts +6 -0
  52. package/esm/models/speechrequest.js +1 -0
  53. package/esm/models/updateworkspacerequest.d.ts +10 -0
  54. package/esm/models/updateworkspacerequest.js +4 -0
  55. package/esm/models/usage.d.ts +4 -4
  56. package/esm/models/usage.js +4 -5
  57. package/esm/models/videogenerationrequest.d.ts +11 -0
  58. package/esm/models/videogenerationrequest.js +3 -0
  59. package/esm/models/websearchplugin.d.ts +35 -0
  60. package/esm/models/websearchplugin.js +21 -0
  61. package/esm/models/websearchuserlocationservertool.d.ts +8 -8
  62. package/esm/models/websearchuserlocationservertool.js +4 -4
  63. package/esm/models/workspace.d.ts +8 -0
  64. package/esm/models/workspace.js +4 -0
  65. package/jsr.json +1 -1
  66. package/package.json +5 -5
@@ -7,7 +7,7 @@ export type InputTokensDetails = {
7
7
  export type OutputTokensDetails = {
8
8
  reasoningTokens: number;
9
9
  };
10
- export type CostDetails = {
10
+ export type UsageCostDetails = {
11
11
  upstreamInferenceCost?: number | null | undefined;
12
12
  upstreamInferenceInputCost: number;
13
13
  upstreamInferenceOutputCost: number;
@@ -25,7 +25,7 @@ export type Usage = {
25
25
  * Cost of the completion
26
26
  */
27
27
  cost?: number | null | undefined;
28
- costDetails?: CostDetails | undefined;
28
+ costDetails?: UsageCostDetails | undefined;
29
29
  /**
30
30
  * Whether a request was made using a Bring Your Own Key configuration
31
31
  */
@@ -38,8 +38,8 @@ export declare function inputTokensDetailsFromJSON(jsonString: string): SafePars
38
38
  export declare const OutputTokensDetails$inboundSchema: z.ZodType<OutputTokensDetails, unknown>;
39
39
  export declare function outputTokensDetailsFromJSON(jsonString: string): SafeParseResult<OutputTokensDetails, SDKValidationError>;
40
40
  /** @internal */
41
- export declare const CostDetails$inboundSchema: z.ZodType<CostDetails, unknown>;
42
- export declare function costDetailsFromJSON(jsonString: string): SafeParseResult<CostDetails, SDKValidationError>;
41
+ export declare const UsageCostDetails$inboundSchema: z.ZodType<UsageCostDetails, unknown>;
42
+ export declare function usageCostDetailsFromJSON(jsonString: string): SafeParseResult<UsageCostDetails, SDKValidationError>;
43
43
  /** @internal */
44
44
  export declare const Usage$inboundSchema: z.ZodType<Usage, unknown>;
45
45
  export declare function usageFromJSON(jsonString: string): SafeParseResult<Usage, SDKValidationError>;
@@ -28,8 +28,7 @@ export function outputTokensDetailsFromJSON(jsonString) {
28
28
  return safeParse(jsonString, (x) => OutputTokensDetails$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'OutputTokensDetails' from JSON`);
29
29
  }
30
30
  /** @internal */
31
- export const CostDetails$inboundSchema = z
32
- .object({
31
+ export const UsageCostDetails$inboundSchema = z.object({
33
32
  upstream_inference_cost: z.nullable(z.number()).optional(),
34
33
  upstream_inference_input_cost: z.number(),
35
34
  upstream_inference_output_cost: z.number(),
@@ -40,8 +39,8 @@ export const CostDetails$inboundSchema = z
40
39
  "upstream_inference_output_cost": "upstreamInferenceOutputCost",
41
40
  });
42
41
  });
43
- export function costDetailsFromJSON(jsonString) {
44
- return safeParse(jsonString, (x) => CostDetails$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CostDetails' from JSON`);
42
+ export function usageCostDetailsFromJSON(jsonString) {
43
+ return safeParse(jsonString, (x) => UsageCostDetails$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'UsageCostDetails' from JSON`);
45
44
  }
46
45
  /** @internal */
47
46
  export const Usage$inboundSchema = z.object({
@@ -51,7 +50,7 @@ export const Usage$inboundSchema = z.object({
51
50
  output_tokens_details: z.lazy(() => OutputTokensDetails$inboundSchema),
52
51
  total_tokens: z.int(),
53
52
  cost: z.nullable(z.number()).optional(),
54
- cost_details: z.lazy(() => CostDetails$inboundSchema).optional(),
53
+ cost_details: z.lazy(() => UsageCostDetails$inboundSchema).optional(),
55
54
  is_byok: z.boolean().optional(),
56
55
  }).transform((v) => {
57
56
  return remap$(v, {
@@ -268,6 +268,9 @@ export type VideoGenerationRequestOptions = {
268
268
  phala?: {
269
269
  [k: string]: any | null;
270
270
  } | undefined;
271
+ poolside?: {
272
+ [k: string]: any | null;
273
+ } | undefined;
271
274
  recraft?: {
272
275
  [k: string]: any | null;
273
276
  } | undefined;
@@ -376,6 +379,10 @@ export type VideoGenerationRequest = {
376
379
  * Aspect ratio of the generated video
377
380
  */
378
381
  aspectRatio?: AspectRatio | undefined;
382
+ /**
383
+ * URL to receive a webhook notification when the video generation job completes. Overrides the workspace-level default callback URL if set. Must be HTTPS.
384
+ */
385
+ callbackUrl?: string | undefined;
379
386
  /**
380
387
  * Duration of the generated video in seconds
381
388
  */
@@ -661,6 +668,9 @@ export type VideoGenerationRequestOptions$Outbound = {
661
668
  phala?: {
662
669
  [k: string]: any | null;
663
670
  } | undefined;
671
+ poolside?: {
672
+ [k: string]: any | null;
673
+ } | undefined;
664
674
  recraft?: {
665
675
  [k: string]: any | null;
666
676
  } | undefined;
@@ -755,6 +765,7 @@ export declare const Resolution$outboundSchema: z.ZodType<string, Resolution>;
755
765
  /** @internal */
756
766
  export type VideoGenerationRequest$Outbound = {
757
767
  aspect_ratio?: string | undefined;
768
+ callback_url?: string | undefined;
758
769
  duration?: number | undefined;
759
770
  frame_images?: Array<FrameImage$Outbound> | undefined;
760
771
  generate_audio?: boolean | undefined;
@@ -116,6 +116,7 @@ export const VideoGenerationRequestOptions$outboundSchema = z.object({
116
116
  parasail: z.record(z.string(), z.nullable(z.any())).optional(),
117
117
  perplexity: z.record(z.string(), z.nullable(z.any())).optional(),
118
118
  phala: z.record(z.string(), z.nullable(z.any())).optional(),
119
+ poolside: z.record(z.string(), z.nullable(z.any())).optional(),
119
120
  recraft: z.record(z.string(), z.nullable(z.any())).optional(),
120
121
  recursal: z.record(z.string(), z.nullable(z.any())).optional(),
121
122
  reflection: z.record(z.string(), z.nullable(z.any())).optional(),
@@ -183,6 +184,7 @@ export const Resolution$outboundSchema = openEnums.outboundSchema(Resolution);
183
184
  /** @internal */
184
185
  export const VideoGenerationRequest$outboundSchema = z.object({
185
186
  aspectRatio: AspectRatio$outboundSchema.optional(),
187
+ callbackUrl: z.string().optional(),
186
188
  duration: z.int().optional(),
187
189
  frameImages: z.array(FrameImage$outboundSchema).optional(),
188
190
  generateAudio: z.boolean().optional(),
@@ -197,6 +199,7 @@ export const VideoGenerationRequest$outboundSchema = z.object({
197
199
  }).transform((v) => {
198
200
  return remap$(v, {
199
201
  aspectRatio: "aspect_ratio",
202
+ callbackUrl: "callback_url",
200
203
  frameImages: "frame_images",
201
204
  generateAudio: "generate_audio",
202
205
  inputReferences: "input_references",
@@ -1,5 +1,20 @@
1
1
  import * as z from "zod/v4";
2
+ import { ClosedEnum } from "../types/enums.js";
2
3
  import { WebSearchEngine } from "./websearchengine.js";
4
+ export declare const WebSearchPluginType: {
5
+ readonly Approximate: "approximate";
6
+ };
7
+ export type WebSearchPluginType = ClosedEnum<typeof WebSearchPluginType>;
8
+ /**
9
+ * Approximate user location for location-biased search results. Passed through to native providers that support it (e.g. Anthropic).
10
+ */
11
+ export type UserLocation = {
12
+ city?: string | null | undefined;
13
+ country?: string | null | undefined;
14
+ region?: string | null | undefined;
15
+ timezone?: string | null | undefined;
16
+ type: WebSearchPluginType;
17
+ };
3
18
  export type WebSearchPlugin = {
4
19
  /**
5
20
  * Set to false to disable the web-search plugin for this request. Defaults to true.
@@ -19,9 +34,27 @@ export type WebSearchPlugin = {
19
34
  */
20
35
  includeDomains?: Array<string> | undefined;
21
36
  maxResults?: number | undefined;
37
+ /**
38
+ * Maximum number of times the model can invoke web search in a single turn. Passed through to native providers that support it (e.g. Anthropic).
39
+ */
40
+ maxUses?: number | undefined;
22
41
  searchPrompt?: string | undefined;
42
+ userLocation?: UserLocation | null | undefined;
23
43
  };
24
44
  /** @internal */
45
+ export declare const WebSearchPluginType$outboundSchema: z.ZodEnum<typeof WebSearchPluginType>;
46
+ /** @internal */
47
+ export type UserLocation$Outbound = {
48
+ city?: string | null | undefined;
49
+ country?: string | null | undefined;
50
+ region?: string | null | undefined;
51
+ timezone?: string | null | undefined;
52
+ type: string;
53
+ };
54
+ /** @internal */
55
+ export declare const UserLocation$outboundSchema: z.ZodType<UserLocation$Outbound, UserLocation>;
56
+ export declare function userLocationToJSON(userLocation: UserLocation): string;
57
+ /** @internal */
25
58
  export type WebSearchPlugin$Outbound = {
26
59
  enabled?: boolean | undefined;
27
60
  engine?: string | undefined;
@@ -29,7 +62,9 @@ export type WebSearchPlugin$Outbound = {
29
62
  id: "web";
30
63
  include_domains?: Array<string> | undefined;
31
64
  max_results?: number | undefined;
65
+ max_uses?: number | undefined;
32
66
  search_prompt?: string | undefined;
67
+ user_location?: UserLocation$Outbound | null | undefined;
33
68
  };
34
69
  /** @internal */
35
70
  export declare const WebSearchPlugin$outboundSchema: z.ZodType<WebSearchPlugin$Outbound, WebSearchPlugin>;
@@ -5,6 +5,22 @@
5
5
  import * as z from "zod/v4";
6
6
  import { remap as remap$ } from "../lib/primitives.js";
7
7
  import { WebSearchEngine$outboundSchema, } from "./websearchengine.js";
8
+ export const WebSearchPluginType = {
9
+ Approximate: "approximate",
10
+ };
11
+ /** @internal */
12
+ export const WebSearchPluginType$outboundSchema = z.enum(WebSearchPluginType);
13
+ /** @internal */
14
+ export const UserLocation$outboundSchema = z.object({
15
+ city: z.nullable(z.string()).optional(),
16
+ country: z.nullable(z.string()).optional(),
17
+ region: z.nullable(z.string()).optional(),
18
+ timezone: z.nullable(z.string()).optional(),
19
+ type: WebSearchPluginType$outboundSchema,
20
+ });
21
+ export function userLocationToJSON(userLocation) {
22
+ return JSON.stringify(UserLocation$outboundSchema.parse(userLocation));
23
+ }
8
24
  /** @internal */
9
25
  export const WebSearchPlugin$outboundSchema = z.object({
10
26
  enabled: z.boolean().optional(),
@@ -13,13 +29,18 @@ export const WebSearchPlugin$outboundSchema = z.object({
13
29
  id: z.literal("web"),
14
30
  includeDomains: z.array(z.string()).optional(),
15
31
  maxResults: z.int().optional(),
32
+ maxUses: z.int().optional(),
16
33
  searchPrompt: z.string().optional(),
34
+ userLocation: z.nullable(z.lazy(() => UserLocation$outboundSchema))
35
+ .optional(),
17
36
  }).transform((v) => {
18
37
  return remap$(v, {
19
38
  excludeDomains: "exclude_domains",
20
39
  includeDomains: "include_domains",
21
40
  maxResults: "max_results",
41
+ maxUses: "max_uses",
22
42
  searchPrompt: "search_prompt",
43
+ userLocation: "user_location",
23
44
  });
24
45
  });
25
46
  export function webSearchPluginToJSON(webSearchPlugin) {
@@ -8,20 +8,20 @@ export type WebSearchUserLocationServerToolType = ClosedEnum<typeof WebSearchUse
8
8
  * Approximate user location for location-biased results.
9
9
  */
10
10
  export type WebSearchUserLocationServerTool = {
11
- city?: string | undefined;
12
- country?: string | undefined;
13
- region?: string | undefined;
14
- timezone?: string | undefined;
11
+ city?: string | null | undefined;
12
+ country?: string | null | undefined;
13
+ region?: string | null | undefined;
14
+ timezone?: string | null | undefined;
15
15
  type?: WebSearchUserLocationServerToolType | undefined;
16
16
  };
17
17
  /** @internal */
18
18
  export declare const WebSearchUserLocationServerToolType$outboundSchema: z.ZodEnum<typeof WebSearchUserLocationServerToolType>;
19
19
  /** @internal */
20
20
  export type WebSearchUserLocationServerTool$Outbound = {
21
- city?: string | undefined;
22
- country?: string | undefined;
23
- region?: string | undefined;
24
- timezone?: string | undefined;
21
+ city?: string | null | undefined;
22
+ country?: string | null | undefined;
23
+ region?: string | null | undefined;
24
+ timezone?: string | null | undefined;
25
25
  type?: string | undefined;
26
26
  };
27
27
  /** @internal */
@@ -10,10 +10,10 @@ export const WebSearchUserLocationServerToolType = {
10
10
  export const WebSearchUserLocationServerToolType$outboundSchema = z.enum(WebSearchUserLocationServerToolType);
11
11
  /** @internal */
12
12
  export const WebSearchUserLocationServerTool$outboundSchema = z.object({
13
- city: z.string().optional(),
14
- country: z.string().optional(),
15
- region: z.string().optional(),
16
- timezone: z.string().optional(),
13
+ city: z.nullable(z.string()).optional(),
14
+ country: z.nullable(z.string()).optional(),
15
+ region: z.nullable(z.string()).optional(),
16
+ timezone: z.nullable(z.string()).optional(),
17
17
  type: WebSearchUserLocationServerToolType$outboundSchema.optional(),
18
18
  });
19
19
  export function webSearchUserLocationServerToolToJSON(webSearchUserLocationServerTool) {
@@ -30,6 +30,14 @@ export type Workspace = {
30
30
  * Unique identifier for the workspace
31
31
  */
32
32
  id: string;
33
+ /**
34
+ * Optional array of API key IDs to filter I/O logging. Null means all keys are logged.
35
+ */
36
+ ioLoggingApiKeyIds: Array<number> | null;
37
+ /**
38
+ * Sampling rate for I/O logging (0.0001-1). 1 means 100% of requests are logged.
39
+ */
40
+ ioLoggingSamplingRate: number;
33
41
  /**
34
42
  * Whether data discount logging is enabled for this workspace
35
43
  */
@@ -14,6 +14,8 @@ export const Workspace$inboundSchema = z.object({
14
14
  default_text_model: z.nullable(z.string()),
15
15
  description: z.nullable(z.string()),
16
16
  id: z.string(),
17
+ io_logging_api_key_ids: z.nullable(z.array(z.int())),
18
+ io_logging_sampling_rate: z.number(),
17
19
  is_data_discount_logging_enabled: z.boolean(),
18
20
  is_observability_broadcast_enabled: z.boolean(),
19
21
  is_observability_io_logging_enabled: z.boolean(),
@@ -27,6 +29,8 @@ export const Workspace$inboundSchema = z.object({
27
29
  "default_image_model": "defaultImageModel",
28
30
  "default_provider_sort": "defaultProviderSort",
29
31
  "default_text_model": "defaultTextModel",
32
+ "io_logging_api_key_ids": "ioLoggingApiKeyIds",
33
+ "io_logging_sampling_rate": "ioLoggingSamplingRate",
30
34
  "is_data_discount_logging_enabled": "isDataDiscountLoggingEnabled",
31
35
  "is_observability_broadcast_enabled": "isObservabilityBroadcastEnabled",
32
36
  "is_observability_io_logging_enabled": "isObservabilityIoLoggingEnabled",
package/jsr.json CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  {
4
4
  "name": "@openrouter/sdk",
5
- "version": "0.12.20",
5
+ "version": "0.12.22",
6
6
  "exports": {
7
7
  ".": "./src/index.ts",
8
8
  "./models/errors": "./src/models/errors/index.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openrouter/sdk",
3
- "version": "0.12.20",
3
+ "version": "0.12.22",
4
4
  "author": "OpenRouter",
5
5
  "description": "The OpenRouter TypeScript SDK is a type-safe toolkit for building AI applications with access to 300+ language models through a unified API.",
6
6
  "keywords": [
@@ -69,14 +69,14 @@
69
69
  "lint": "eslint --cache --max-warnings=0 src",
70
70
  "build": "tsc",
71
71
  "prepublishOnly": "npm run build",
72
- "test:transit": "exit 0",
73
- "compile": "tsc",
72
+ "typecheck": "tsc --noEmit",
74
73
  "postinstall": "node scripts/check-types.js || true",
75
74
  "prepare": "npm run build",
76
- "test": "vitest --run --project unit",
75
+ "test:transit": "exit 0",
77
76
  "test:watch": "vitest --watch --project unit",
78
- "typecheck": "tsc --noEmit",
79
77
  "typecheck:transit": "exit 0",
78
+ "compile": "tsc",
79
+ "test": "vitest --run --project unit",
80
80
  "test:e2e": "vitest --run --project e2e"
81
81
  },
82
82
  "peerDependencies": {},