@openrouter/sdk 1.5.56 → 1.5.57

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 (103) hide show
  1. package/esm/lib/config.d.ts +2 -2
  2. package/esm/lib/config.js +2 -2
  3. package/esm/models/additionaltoolsitem.d.ts +5 -4
  4. package/esm/models/additionaltoolsitem.js +3 -0
  5. package/esm/models/alignmentresponsesrejected.d.ts +4 -1
  6. package/esm/models/alignmentresponsesrejected.js +6 -0
  7. package/esm/models/byokproviderslug.d.ts +1 -0
  8. package/esm/models/byokproviderslug.js +1 -0
  9. package/esm/models/createworkspacerequest.d.ts +1 -0
  10. package/esm/models/createworkspacerequest.js +1 -0
  11. package/esm/models/decisionschoicequestion.d.ts +4 -4
  12. package/esm/models/decisionschoicequestion.js +1 -5
  13. package/esm/models/decisionsnoulquestion.d.ts +12 -12
  14. package/esm/models/decisionsnoulquestion.js +3 -7
  15. package/esm/models/decisionsscorequestion.d.ts +4 -4
  16. package/esm/models/decisionsscorequestion.js +1 -5
  17. package/esm/models/imagegenerationproviderpreferences.d.ts +6 -0
  18. package/esm/models/imagegenerationproviderpreferences.js +1 -0
  19. package/esm/models/imagegenerationrequest.d.ts +1 -1
  20. package/esm/models/index.d.ts +6 -0
  21. package/esm/models/index.js +6 -0
  22. package/esm/models/mcpapprovalrequestitem.d.ts +7 -0
  23. package/esm/models/mcpapprovalrequestitem.js +19 -1
  24. package/esm/models/mcpcallitem.d.ts +17 -1
  25. package/esm/models/mcpcallitem.js +18 -0
  26. package/esm/models/mcpservertool.d.ts +78 -69
  27. package/esm/models/mcpservertool.js +135 -105
  28. package/esm/models/mcpservertoolopenrouter.d.ts +28 -0
  29. package/esm/models/mcpservertoolopenrouter.js +20 -0
  30. package/esm/models/mcpservertoolparameters.d.ts +152 -0
  31. package/esm/models/mcpservertoolparameters.js +134 -0
  32. package/esm/models/openairesponsestoolchoiceunion.d.ts +3 -2
  33. package/esm/models/openairesponsestoolchoiceunion.js +3 -0
  34. package/esm/models/operations/listbyokkeys.d.ts +1 -0
  35. package/esm/models/operations/listbyokkeys.js +1 -0
  36. package/esm/models/outputitemmcpapprovalrequest.d.ts +14 -0
  37. package/esm/models/outputitemmcpapprovalrequest.js +23 -0
  38. package/esm/models/outputitemmcpcall.d.ts +74 -0
  39. package/esm/models/outputitemmcpcall.js +94 -0
  40. package/esm/models/outputitemmcplisttools.d.ts +25 -0
  41. package/esm/models/outputitemmcplisttools.js +37 -0
  42. package/esm/models/outputitems.d.ts +3 -0
  43. package/esm/models/outputitems.js +2 -0
  44. package/esm/models/providername.d.ts +1 -0
  45. package/esm/models/providername.js +1 -0
  46. package/esm/models/provideroptions.d.ts +6 -0
  47. package/esm/models/provideroptions.js +1 -0
  48. package/esm/models/providerresponse.d.ts +1 -0
  49. package/esm/models/providerresponse.js +1 -0
  50. package/esm/models/responsesrequest.d.ts +9 -0
  51. package/esm/models/responsesrequest.js +3 -0
  52. package/esm/models/toolchoicemcp.d.ts +33 -0
  53. package/esm/models/toolchoicemcp.js +42 -0
  54. package/esm/models/toolsearchoutputitem.d.ts +5 -4
  55. package/esm/models/toolsearchoutputitem.js +3 -0
  56. package/esm/models/updateworkspacerequest.d.ts +1 -0
  57. package/esm/models/updateworkspacerequest.js +1 -0
  58. package/esm/models/videogenerationrequest.d.ts +6 -0
  59. package/esm/models/videogenerationrequest.js +1 -0
  60. package/esm/sdk/sdk.d.ts +0 -9
  61. package/esm/sdk/sdk.js +1 -7
  62. package/jsr.json +1 -1
  63. package/package.json +7 -7
  64. package/esm/funcs/call-model.d.ts +0 -67
  65. package/esm/funcs/call-model.js +0 -98
  66. package/esm/lib/anthropic-compat.d.ts +0 -51
  67. package/esm/lib/anthropic-compat.js +0 -222
  68. package/esm/lib/async-params.d.ts +0 -107
  69. package/esm/lib/async-params.js +0 -88
  70. package/esm/lib/chat-compat.d.ts +0 -47
  71. package/esm/lib/chat-compat.js +0 -111
  72. package/esm/lib/claude-constants.d.ts +0 -22
  73. package/esm/lib/claude-constants.js +0 -20
  74. package/esm/lib/claude-type-guards.d.ts +0 -10
  75. package/esm/lib/claude-type-guards.js +0 -70
  76. package/esm/lib/conversation-state.d.ts +0 -63
  77. package/esm/lib/conversation-state.js +0 -210
  78. package/esm/lib/model-result.d.ts +0 -373
  79. package/esm/lib/model-result.js +0 -1414
  80. package/esm/lib/next-turn-params.d.ts +0 -30
  81. package/esm/lib/next-turn-params.js +0 -135
  82. package/esm/lib/reusable-stream.d.ts +0 -39
  83. package/esm/lib/reusable-stream.js +0 -192
  84. package/esm/lib/stop-conditions.d.ts +0 -80
  85. package/esm/lib/stop-conditions.js +0 -104
  86. package/esm/lib/stream-transformers.d.ts +0 -118
  87. package/esm/lib/stream-transformers.js +0 -852
  88. package/esm/lib/stream-type-guards.d.ts +0 -49
  89. package/esm/lib/stream-type-guards.js +0 -85
  90. package/esm/lib/tool-context.d.ts +0 -68
  91. package/esm/lib/tool-context.js +0 -175
  92. package/esm/lib/tool-event-broadcaster.d.ts +0 -44
  93. package/esm/lib/tool-event-broadcaster.js +0 -146
  94. package/esm/lib/tool-executor.d.ts +0 -74
  95. package/esm/lib/tool-executor.js +0 -267
  96. package/esm/lib/tool-orchestrator.d.ts +0 -52
  97. package/esm/lib/tool-orchestrator.js +0 -180
  98. package/esm/lib/tool-types.d.ts +0 -573
  99. package/esm/lib/tool-types.js +0 -80
  100. package/esm/lib/tool.d.ts +0 -108
  101. package/esm/lib/tool.js +0 -74
  102. package/esm/lib/turn-context.d.ts +0 -52
  103. package/esm/lib/turn-context.js +0 -59
@@ -96,6 +96,7 @@ export declare const ProviderName: {
96
96
  readonly Reka: "Reka";
97
97
  readonly Relace: "Relace";
98
98
  readonly Respan: "Respan";
99
+ readonly River: "River";
99
100
  readonly SailResearch: "Sail Research";
100
101
  readonly SakanaAI: "Sakana AI";
101
102
  readonly SambaNova: "SambaNova";
@@ -99,6 +99,7 @@ export const ProviderName = {
99
99
  Reka: "Reka",
100
100
  Relace: "Relace",
101
101
  Respan: "Respan",
102
+ River: "River",
102
103
  SailResearch: "Sail Research",
103
104
  SakanaAI: "Sakana AI",
104
105
  SambaNova: "SambaNova",
@@ -366,6 +366,9 @@ export type ProviderOptions = {
366
366
  respan?: {
367
367
  [k: string]: any;
368
368
  } | undefined;
369
+ river?: {
370
+ [k: string]: any;
371
+ } | undefined;
369
372
  runway?: {
370
373
  [k: string]: any;
371
374
  } | undefined;
@@ -831,6 +834,9 @@ export type ProviderOptions$Outbound = {
831
834
  respan?: {
832
835
  [k: string]: any;
833
836
  } | undefined;
837
+ river?: {
838
+ [k: string]: any;
839
+ } | undefined;
834
840
  runway?: {
835
841
  [k: string]: any;
836
842
  } | undefined;
@@ -127,6 +127,7 @@ export const ProviderOptions$outboundSchema = z.object({
127
127
  relace: z.record(z.string(), z.any()).optional(),
128
128
  replicate: z.record(z.string(), z.any()).optional(),
129
129
  respan: z.record(z.string(), z.any()).optional(),
130
+ river: z.record(z.string(), z.any()).optional(),
130
131
  runway: z.record(z.string(), z.any()).optional(),
131
132
  sailResearch: z.record(z.string(), z.any()).optional(),
132
133
  sakana: z.record(z.string(), z.any()).optional(),
@@ -129,6 +129,7 @@ export declare const ProviderResponseProviderName: {
129
129
  readonly Reka: "Reka";
130
130
  readonly Relace: "Relace";
131
131
  readonly Respan: "Respan";
132
+ readonly River: "River";
132
133
  readonly SailResearch: "Sail Research";
133
134
  readonly SakanaAI: "Sakana AI";
134
135
  readonly SambaNova: "SambaNova";
@@ -133,6 +133,7 @@ export const ProviderResponseProviderName = {
133
133
  Reka: "Reka",
134
134
  Relace: "Relace",
135
135
  Respan: "Respan",
136
+ River: "River",
136
137
  SailResearch: "Sail Research",
137
138
  SakanaAI: "Sakana AI",
138
139
  SambaNova: "SambaNova",
@@ -29,6 +29,7 @@ import { InputsUnion, InputsUnion$Outbound } from "./inputsunion.js";
29
29
  import { JevRouterPlugin, JevRouterPlugin$Outbound } from "./jevrouterplugin.js";
30
30
  import { LegacyWebSearchServerTool, LegacyWebSearchServerTool$Outbound } from "./legacywebsearchservertool.js";
31
31
  import { McpServerTool, McpServerTool$Outbound } from "./mcpservertool.js";
32
+ import { McpServerToolOpenRouter, McpServerToolOpenRouter$Outbound } from "./mcpservertoolopenrouter.js";
32
33
  import { ModerationPlugin, ModerationPlugin$Outbound } from "./moderationplugin.js";
33
34
  import { NamespaceTool, NamespaceTool$Outbound } from "./namespacetool.js";
34
35
  import { OpenAIResponsesToolChoiceUnion, OpenAIResponsesToolChoiceUnion$Outbound } from "./openairesponsestoolchoiceunion.js";
@@ -190,6 +191,8 @@ export type ResponsesRequestToolUnion = ResponsesRequestToolFunction | (PreviewW
190
191
  type: "openrouter:shell";
191
192
  }) | (ToolSearchServerTool & {
192
193
  type: "openrouter:tool_search";
194
+ }) | (McpServerToolOpenRouter & {
195
+ type: "openrouter:mcp";
193
196
  });
194
197
  /**
195
198
  * Request schema for Responses endpoint
@@ -348,6 +351,8 @@ export type ResponsesRequest = {
348
351
  type: "openrouter:shell";
349
352
  }) | (ToolSearchServerTool & {
350
353
  type: "openrouter:tool_search";
354
+ }) | (McpServerToolOpenRouter & {
355
+ type: "openrouter:mcp";
351
356
  })> | undefined;
352
357
  topK?: number | undefined;
353
358
  topLogprobs?: number | null | undefined;
@@ -471,6 +476,8 @@ export type ResponsesRequestToolUnion$Outbound = ResponsesRequestToolFunction$Ou
471
476
  type: "openrouter:shell";
472
477
  }) | (ToolSearchServerTool$Outbound & {
473
478
  type: "openrouter:tool_search";
479
+ }) | (McpServerToolOpenRouter$Outbound & {
480
+ type: "openrouter:mcp";
474
481
  });
475
482
  /** @internal */
476
483
  export declare const ResponsesRequestToolUnion$outboundSchema: z.ZodType<ResponsesRequestToolUnion$Outbound, ResponsesRequestToolUnion>;
@@ -570,6 +577,8 @@ export type ResponsesRequest$Outbound = {
570
577
  type: "openrouter:shell";
571
578
  }) | (ToolSearchServerTool$Outbound & {
572
579
  type: "openrouter:tool_search";
580
+ }) | (McpServerToolOpenRouter$Outbound & {
581
+ type: "openrouter:mcp";
573
582
  })> | undefined;
574
583
  top_k?: number | undefined;
575
584
  top_logprobs?: number | null | undefined;
@@ -34,6 +34,7 @@ import { InputsUnion$outboundSchema, } from "./inputsunion.js";
34
34
  import { JevRouterPlugin$outboundSchema, } from "./jevrouterplugin.js";
35
35
  import { LegacyWebSearchServerTool$outboundSchema, } from "./legacywebsearchservertool.js";
36
36
  import { McpServerTool$outboundSchema, } from "./mcpservertool.js";
37
+ import { McpServerToolOpenRouter$outboundSchema, } from "./mcpservertoolopenrouter.js";
37
38
  import { ModerationPlugin$outboundSchema, } from "./moderationplugin.js";
38
39
  import { NamespaceTool$outboundSchema, } from "./namespacetool.js";
39
40
  import { OpenAIResponsesToolChoiceUnion$outboundSchema, } from "./openairesponsestoolchoiceunion.js";
@@ -191,6 +192,7 @@ export const ResponsesRequestToolUnion$outboundSchema = z.union([
191
192
  BashServerTool$outboundSchema.and(z.object({ type: z.literal("openrouter:bash") })),
192
193
  ShellServerToolOpenRouter$outboundSchema.and(z.object({ type: z.literal("openrouter:shell") })),
193
194
  ToolSearchServerTool$outboundSchema.and(z.object({ type: z.literal("openrouter:tool_search") })),
195
+ McpServerToolOpenRouter$outboundSchema.and(z.object({ type: z.literal("openrouter:mcp") })),
194
196
  ]);
195
197
  export function responsesRequestToolUnionToJSON(responsesRequestToolUnion) {
196
198
  return JSON.stringify(ResponsesRequestToolUnion$outboundSchema.parse(responsesRequestToolUnion));
@@ -279,6 +281,7 @@ export const ResponsesRequest$outboundSchema = z.object({
279
281
  BashServerTool$outboundSchema.and(z.object({ type: z.literal("openrouter:bash") })),
280
282
  ShellServerToolOpenRouter$outboundSchema.and(z.object({ type: z.literal("openrouter:shell") })),
281
283
  ToolSearchServerTool$outboundSchema.and(z.object({ type: z.literal("openrouter:tool_search") })),
284
+ McpServerToolOpenRouter$outboundSchema.and(z.object({ type: z.literal("openrouter:mcp") })),
282
285
  ])).optional(),
283
286
  topK: z.int().optional(),
284
287
  topLogprobs: z.nullable(z.int()).optional(),
@@ -0,0 +1,33 @@
1
+ import * as z from "zod/v4";
2
+ import { ClosedEnum } from "../types/enums.js";
3
+ import { Result as SafeParseResult } from "../types/fp.js";
4
+ import { SDKValidationError } from "./errors/sdkvalidationerror.js";
5
+ export declare const ToolChoiceMcpType: {
6
+ readonly Mcp: "mcp";
7
+ };
8
+ export type ToolChoiceMcpType = ClosedEnum<typeof ToolChoiceMcpType>;
9
+ /**
10
+ * Forces a call to the named MCP server; `name` narrows it to one of its tools
11
+ */
12
+ export type ToolChoiceMcp = {
13
+ name?: string | null | undefined;
14
+ serverLabel: string;
15
+ type: ToolChoiceMcpType;
16
+ };
17
+ /** @internal */
18
+ export declare const ToolChoiceMcpType$inboundSchema: z.ZodEnum<typeof ToolChoiceMcpType>;
19
+ /** @internal */
20
+ export declare const ToolChoiceMcpType$outboundSchema: z.ZodEnum<typeof ToolChoiceMcpType>;
21
+ /** @internal */
22
+ export declare const ToolChoiceMcp$inboundSchema: z.ZodType<ToolChoiceMcp, unknown>;
23
+ /** @internal */
24
+ export type ToolChoiceMcp$Outbound = {
25
+ name?: string | null | undefined;
26
+ server_label: string;
27
+ type: string;
28
+ };
29
+ /** @internal */
30
+ export declare const ToolChoiceMcp$outboundSchema: z.ZodType<ToolChoiceMcp$Outbound, ToolChoiceMcp>;
31
+ export declare function toolChoiceMcpToJSON(toolChoiceMcp: ToolChoiceMcp): string;
32
+ export declare function toolChoiceMcpFromJSON(jsonString: string): SafeParseResult<ToolChoiceMcp, SDKValidationError>;
33
+ //# sourceMappingURL=toolchoicemcp.d.ts.map
@@ -0,0 +1,42 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: 83450e561cd5
4
+ */
5
+ import * as z from "zod/v4";
6
+ import { remap as remap$ } from "../lib/primitives.js";
7
+ import { safeParse } from "../lib/schemas.js";
8
+ export const ToolChoiceMcpType = {
9
+ Mcp: "mcp",
10
+ };
11
+ /** @internal */
12
+ export const ToolChoiceMcpType$inboundSchema = z.enum(ToolChoiceMcpType);
13
+ /** @internal */
14
+ export const ToolChoiceMcpType$outboundSchema = ToolChoiceMcpType$inboundSchema;
15
+ /** @internal */
16
+ export const ToolChoiceMcp$inboundSchema = z
17
+ .object({
18
+ name: z.nullable(z.string()).optional(),
19
+ server_label: z.string(),
20
+ type: ToolChoiceMcpType$inboundSchema,
21
+ }).transform((v) => {
22
+ return remap$(v, {
23
+ "server_label": "serverLabel",
24
+ });
25
+ });
26
+ /** @internal */
27
+ export const ToolChoiceMcp$outboundSchema = z.object({
28
+ name: z.nullable(z.string()).optional(),
29
+ serverLabel: z.string(),
30
+ type: ToolChoiceMcpType$outboundSchema,
31
+ }).transform((v) => {
32
+ return remap$(v, {
33
+ serverLabel: "server_label",
34
+ });
35
+ });
36
+ export function toolChoiceMcpToJSON(toolChoiceMcp) {
37
+ return JSON.stringify(ToolChoiceMcp$outboundSchema.parse(toolChoiceMcp));
38
+ }
39
+ export function toolChoiceMcpFromJSON(jsonString) {
40
+ return safeParse(jsonString, (x) => ToolChoiceMcp$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ToolChoiceMcp' from JSON`);
41
+ }
42
+ //# sourceMappingURL=toolchoicemcp.js.map
@@ -16,6 +16,7 @@ import { ImageGenerationServerTool, ImageGenerationServerTool$Outbound } from ".
16
16
  import { ImageGenerationServerToolOpenRouter, ImageGenerationServerToolOpenRouter$Outbound } from "./imagegenerationservertoolopenrouter.js";
17
17
  import { LegacyWebSearchServerTool, LegacyWebSearchServerTool$Outbound } from "./legacywebsearchservertool.js";
18
18
  import { McpServerTool, McpServerTool$Outbound } from "./mcpservertool.js";
19
+ import { McpServerToolOpenRouter, McpServerToolOpenRouter$Outbound } from "./mcpservertoolopenrouter.js";
19
20
  import { NamespaceTool, NamespaceTool$Outbound } from "./namespacetool.js";
20
21
  import { Preview20250311WebSearchServerTool, Preview20250311WebSearchServerTool$Outbound } from "./preview20250311websearchservertool.js";
21
22
  import { PreviewWebSearchServerTool, PreviewWebSearchServerTool$Outbound } from "./previewwebsearchservertool.js";
@@ -77,7 +78,7 @@ export type ToolSearchOutputItemToolFunction = {
77
78
  [k: string]: any;
78
79
  } | null | undefined;
79
80
  };
80
- export type ToolSearchOutputItemToolUnion = ComputerUseServerTool | NamespaceTool | ToolSearchOutputItemToolFunction | FileSearchServerTool | CodeInterpreterServerTool | McpServerTool | CustomTool | PreviewWebSearchServerTool | Preview20250311WebSearchServerTool | LegacyWebSearchServerTool | WebSearchServerTool | ImageGenerationServerTool | CodexLocalShellTool | ShellServerTool | ApplyPatchServerTool | AdvisorServerToolOpenRouter | SubagentServerToolOpenRouter | DatetimeServerTool | FilesServerTool | FusionServerToolOpenRouter | ImageGenerationServerToolOpenRouter | SearchModelsServerToolOpenRouter | WebFetchServerTool | WebSearchServerToolOpenRouter | ApplyPatchServerToolOpenRouter | BashServerTool | ShellServerToolOpenRouter | ToolSearchServerTool | ToolSearchOutputItemTool;
81
+ export type ToolSearchOutputItemToolUnion = ComputerUseServerTool | NamespaceTool | ToolSearchOutputItemToolFunction | FileSearchServerTool | CodeInterpreterServerTool | McpServerTool | CustomTool | McpServerToolOpenRouter | PreviewWebSearchServerTool | Preview20250311WebSearchServerTool | LegacyWebSearchServerTool | WebSearchServerTool | ImageGenerationServerTool | CodexLocalShellTool | ShellServerTool | ApplyPatchServerTool | AdvisorServerToolOpenRouter | SubagentServerToolOpenRouter | DatetimeServerTool | FilesServerTool | FusionServerToolOpenRouter | ImageGenerationServerToolOpenRouter | SearchModelsServerToolOpenRouter | WebFetchServerTool | WebSearchServerToolOpenRouter | ApplyPatchServerToolOpenRouter | BashServerTool | ShellServerToolOpenRouter | ToolSearchServerTool | ToolSearchOutputItemTool;
81
82
  export declare const TypeToolSearchOutput: {
82
83
  readonly ToolSearchOutput: "tool_search_output";
83
84
  };
@@ -90,7 +91,7 @@ export type ToolSearchOutputItem = {
90
91
  execution: ToolSearchOutputItemExecution;
91
92
  id?: string | null | undefined;
92
93
  status?: ToolSearchOutputItemStatus | null | undefined;
93
- tools: Array<ComputerUseServerTool | NamespaceTool | ToolSearchOutputItemToolFunction | FileSearchServerTool | CodeInterpreterServerTool | McpServerTool | CustomTool | PreviewWebSearchServerTool | Preview20250311WebSearchServerTool | LegacyWebSearchServerTool | WebSearchServerTool | ImageGenerationServerTool | CodexLocalShellTool | ShellServerTool | ApplyPatchServerTool | AdvisorServerToolOpenRouter | SubagentServerToolOpenRouter | DatetimeServerTool | FilesServerTool | FusionServerToolOpenRouter | ImageGenerationServerToolOpenRouter | SearchModelsServerToolOpenRouter | WebFetchServerTool | WebSearchServerToolOpenRouter | ApplyPatchServerToolOpenRouter | BashServerTool | ShellServerToolOpenRouter | ToolSearchServerTool | ToolSearchOutputItemTool>;
94
+ tools: Array<ComputerUseServerTool | NamespaceTool | ToolSearchOutputItemToolFunction | FileSearchServerTool | CodeInterpreterServerTool | McpServerTool | CustomTool | McpServerToolOpenRouter | PreviewWebSearchServerTool | Preview20250311WebSearchServerTool | LegacyWebSearchServerTool | WebSearchServerTool | ImageGenerationServerTool | CodexLocalShellTool | ShellServerTool | ApplyPatchServerTool | AdvisorServerToolOpenRouter | SubagentServerToolOpenRouter | DatetimeServerTool | FilesServerTool | FusionServerToolOpenRouter | ImageGenerationServerToolOpenRouter | SearchModelsServerToolOpenRouter | WebFetchServerTool | WebSearchServerToolOpenRouter | ApplyPatchServerToolOpenRouter | BashServerTool | ShellServerToolOpenRouter | ToolSearchServerTool | ToolSearchOutputItemTool>;
94
95
  type: TypeToolSearchOutput;
95
96
  };
96
97
  /** @internal */
@@ -129,7 +130,7 @@ export type ToolSearchOutputItemToolFunction$Outbound = {
129
130
  export declare const ToolSearchOutputItemToolFunction$outboundSchema: z.ZodType<ToolSearchOutputItemToolFunction$Outbound, ToolSearchOutputItemToolFunction>;
130
131
  export declare function toolSearchOutputItemToolFunctionToJSON(toolSearchOutputItemToolFunction: ToolSearchOutputItemToolFunction): string;
131
132
  /** @internal */
132
- export type ToolSearchOutputItemToolUnion$Outbound = ComputerUseServerTool$Outbound | NamespaceTool$Outbound | ToolSearchOutputItemToolFunction$Outbound | FileSearchServerTool$Outbound | CodeInterpreterServerTool$Outbound | McpServerTool$Outbound | CustomTool$Outbound | PreviewWebSearchServerTool$Outbound | Preview20250311WebSearchServerTool$Outbound | LegacyWebSearchServerTool$Outbound | WebSearchServerTool$Outbound | ImageGenerationServerTool$Outbound | CodexLocalShellTool$Outbound | ShellServerTool$Outbound | ApplyPatchServerTool$Outbound | AdvisorServerToolOpenRouter$Outbound | SubagentServerToolOpenRouter$Outbound | DatetimeServerTool$Outbound | FilesServerTool$Outbound | FusionServerToolOpenRouter$Outbound | ImageGenerationServerToolOpenRouter$Outbound | SearchModelsServerToolOpenRouter$Outbound | WebFetchServerTool$Outbound | WebSearchServerToolOpenRouter$Outbound | ApplyPatchServerToolOpenRouter$Outbound | BashServerTool$Outbound | ShellServerToolOpenRouter$Outbound | ToolSearchServerTool$Outbound | ToolSearchOutputItemTool$Outbound;
133
+ export type ToolSearchOutputItemToolUnion$Outbound = ComputerUseServerTool$Outbound | NamespaceTool$Outbound | ToolSearchOutputItemToolFunction$Outbound | FileSearchServerTool$Outbound | CodeInterpreterServerTool$Outbound | McpServerTool$Outbound | CustomTool$Outbound | McpServerToolOpenRouter$Outbound | PreviewWebSearchServerTool$Outbound | Preview20250311WebSearchServerTool$Outbound | LegacyWebSearchServerTool$Outbound | WebSearchServerTool$Outbound | ImageGenerationServerTool$Outbound | CodexLocalShellTool$Outbound | ShellServerTool$Outbound | ApplyPatchServerTool$Outbound | AdvisorServerToolOpenRouter$Outbound | SubagentServerToolOpenRouter$Outbound | DatetimeServerTool$Outbound | FilesServerTool$Outbound | FusionServerToolOpenRouter$Outbound | ImageGenerationServerToolOpenRouter$Outbound | SearchModelsServerToolOpenRouter$Outbound | WebFetchServerTool$Outbound | WebSearchServerToolOpenRouter$Outbound | ApplyPatchServerToolOpenRouter$Outbound | BashServerTool$Outbound | ShellServerToolOpenRouter$Outbound | ToolSearchServerTool$Outbound | ToolSearchOutputItemTool$Outbound;
133
134
  /** @internal */
134
135
  export declare const ToolSearchOutputItemToolUnion$outboundSchema: z.ZodType<ToolSearchOutputItemToolUnion$Outbound, ToolSearchOutputItemToolUnion>;
135
136
  export declare function toolSearchOutputItemToolUnionToJSON(toolSearchOutputItemToolUnion: ToolSearchOutputItemToolUnion): string;
@@ -141,7 +142,7 @@ export type ToolSearchOutputItem$Outbound = {
141
142
  execution: string;
142
143
  id?: string | null | undefined;
143
144
  status?: string | null | undefined;
144
- tools: Array<ComputerUseServerTool$Outbound | NamespaceTool$Outbound | ToolSearchOutputItemToolFunction$Outbound | FileSearchServerTool$Outbound | CodeInterpreterServerTool$Outbound | McpServerTool$Outbound | CustomTool$Outbound | PreviewWebSearchServerTool$Outbound | Preview20250311WebSearchServerTool$Outbound | LegacyWebSearchServerTool$Outbound | WebSearchServerTool$Outbound | ImageGenerationServerTool$Outbound | CodexLocalShellTool$Outbound | ShellServerTool$Outbound | ApplyPatchServerTool$Outbound | AdvisorServerToolOpenRouter$Outbound | SubagentServerToolOpenRouter$Outbound | DatetimeServerTool$Outbound | FilesServerTool$Outbound | FusionServerToolOpenRouter$Outbound | ImageGenerationServerToolOpenRouter$Outbound | SearchModelsServerToolOpenRouter$Outbound | WebFetchServerTool$Outbound | WebSearchServerToolOpenRouter$Outbound | ApplyPatchServerToolOpenRouter$Outbound | BashServerTool$Outbound | ShellServerToolOpenRouter$Outbound | ToolSearchServerTool$Outbound | ToolSearchOutputItemTool$Outbound>;
145
+ tools: Array<ComputerUseServerTool$Outbound | NamespaceTool$Outbound | ToolSearchOutputItemToolFunction$Outbound | FileSearchServerTool$Outbound | CodeInterpreterServerTool$Outbound | McpServerTool$Outbound | CustomTool$Outbound | McpServerToolOpenRouter$Outbound | PreviewWebSearchServerTool$Outbound | Preview20250311WebSearchServerTool$Outbound | LegacyWebSearchServerTool$Outbound | WebSearchServerTool$Outbound | ImageGenerationServerTool$Outbound | CodexLocalShellTool$Outbound | ShellServerTool$Outbound | ApplyPatchServerTool$Outbound | AdvisorServerToolOpenRouter$Outbound | SubagentServerToolOpenRouter$Outbound | DatetimeServerTool$Outbound | FilesServerTool$Outbound | FusionServerToolOpenRouter$Outbound | ImageGenerationServerToolOpenRouter$Outbound | SearchModelsServerToolOpenRouter$Outbound | WebFetchServerTool$Outbound | WebSearchServerToolOpenRouter$Outbound | ApplyPatchServerToolOpenRouter$Outbound | BashServerTool$Outbound | ShellServerToolOpenRouter$Outbound | ToolSearchServerTool$Outbound | ToolSearchOutputItemTool$Outbound>;
145
146
  type: string;
146
147
  };
147
148
  /** @internal */
@@ -21,6 +21,7 @@ import { ImageGenerationServerTool$outboundSchema, } from "./imagegenerationserv
21
21
  import { ImageGenerationServerToolOpenRouter$outboundSchema, } from "./imagegenerationservertoolopenrouter.js";
22
22
  import { LegacyWebSearchServerTool$outboundSchema, } from "./legacywebsearchservertool.js";
23
23
  import { McpServerTool$outboundSchema, } from "./mcpservertool.js";
24
+ import { McpServerToolOpenRouter$outboundSchema, } from "./mcpservertoolopenrouter.js";
24
25
  import { NamespaceTool$outboundSchema, } from "./namespacetool.js";
25
26
  import { Preview20250311WebSearchServerTool$outboundSchema, } from "./preview20250311websearchservertool.js";
26
27
  import { PreviewWebSearchServerTool$outboundSchema, } from "./previewwebsearchservertool.js";
@@ -104,6 +105,7 @@ export const ToolSearchOutputItemToolUnion$outboundSchema = z.union([
104
105
  CodeInterpreterServerTool$outboundSchema,
105
106
  McpServerTool$outboundSchema,
106
107
  CustomTool$outboundSchema,
108
+ McpServerToolOpenRouter$outboundSchema,
107
109
  PreviewWebSearchServerTool$outboundSchema,
108
110
  Preview20250311WebSearchServerTool$outboundSchema,
109
111
  LegacyWebSearchServerTool$outboundSchema,
@@ -146,6 +148,7 @@ export const ToolSearchOutputItem$outboundSchema = z.object({
146
148
  CodeInterpreterServerTool$outboundSchema,
147
149
  McpServerTool$outboundSchema,
148
150
  CustomTool$outboundSchema,
151
+ McpServerToolOpenRouter$outboundSchema,
149
152
  PreviewWebSearchServerTool$outboundSchema,
150
153
  Preview20250311WebSearchServerTool$outboundSchema,
151
154
  LegacyWebSearchServerTool$outboundSchema,
@@ -7,6 +7,7 @@ export declare const UpdateWorkspaceRequestDisabledServerTool: {
7
7
  readonly OpenrouterDatetime: "openrouter:datetime";
8
8
  readonly OpenrouterFusion: "openrouter:fusion";
9
9
  readonly OpenrouterImageGeneration: "openrouter:image_generation";
10
+ readonly OpenrouterMcp: "openrouter:mcp";
10
11
  readonly OpenrouterExperimentalSearchModels: "openrouter:experimental__search_models";
11
12
  readonly OpenrouterShell: "openrouter:shell";
12
13
  readonly OpenrouterSubagent: "openrouter:subagent";
@@ -12,6 +12,7 @@ export const UpdateWorkspaceRequestDisabledServerTool = {
12
12
  OpenrouterDatetime: "openrouter:datetime",
13
13
  OpenrouterFusion: "openrouter:fusion",
14
14
  OpenrouterImageGeneration: "openrouter:image_generation",
15
+ OpenrouterMcp: "openrouter:mcp",
15
16
  OpenrouterExperimentalSearchModels: "openrouter:experimental__search_models",
16
17
  OpenrouterShell: "openrouter:shell",
17
18
  OpenrouterSubagent: "openrouter:subagent",
@@ -391,6 +391,9 @@ export type VideoGenerationRequestOptions = {
391
391
  respan?: {
392
392
  [k: string]: any;
393
393
  } | undefined;
394
+ river?: {
395
+ [k: string]: any;
396
+ } | undefined;
394
397
  runway?: {
395
398
  [k: string]: any;
396
399
  } | undefined;
@@ -975,6 +978,9 @@ export type VideoGenerationRequestOptions$Outbound = {
975
978
  respan?: {
976
979
  [k: string]: any;
977
980
  } | undefined;
981
+ river?: {
982
+ [k: string]: any;
983
+ } | undefined;
978
984
  runway?: {
979
985
  [k: string]: any;
980
986
  } | undefined;
@@ -171,6 +171,7 @@ export const VideoGenerationRequestOptions$outboundSchema = z.object({
171
171
  relace: z.record(z.string(), z.any()).optional(),
172
172
  replicate: z.record(z.string(), z.any()).optional(),
173
173
  respan: z.record(z.string(), z.any()).optional(),
174
+ river: z.record(z.string(), z.any()).optional(),
174
175
  runway: z.record(z.string(), z.any()).optional(),
175
176
  sailResearch: z.record(z.string(), z.any()).optional(),
176
177
  sakana: z.record(z.string(), z.any()).optional(),
package/esm/sdk/sdk.d.ts CHANGED
@@ -37,12 +37,6 @@ import { TTS } from "./tts.js";
37
37
  import { Vault } from "./vault.js";
38
38
  import { VideoGeneration } from "./videogeneration.js";
39
39
  import { Workspaces } from "./workspaces.js";
40
- import type { $ZodObject, $ZodShape, infer as zodInfer } from "zod/v4/core";
41
- import { type CallModelInput } from "../funcs/call-model.js";
42
- import type { ModelResult } from "../lib/model-result.js";
43
- import type { RequestOptions } from "../lib/sdks.js";
44
- import { type Tool, ToolType } from "../lib/tool-types.js";
45
- export { ToolType };
46
40
  export declare class OpenRouter extends ClientSDK {
47
41
  private _analytics?;
48
42
  get analytics(): Analytics;
@@ -120,8 +114,5 @@ export declare class OpenRouter extends ClientSDK {
120
114
  get videoGeneration(): VideoGeneration;
121
115
  private _workspaces?;
122
116
  get workspaces(): Workspaces;
123
- callModel<TTools extends readonly Tool[], TSharedSchema extends $ZodObject<$ZodShape> | undefined = undefined, TShared extends Record<string, unknown> = TSharedSchema extends $ZodObject<$ZodShape> ? zodInfer<TSharedSchema> : Record<string, never>>(request: CallModelInput<TTools, TShared> & {
124
- sharedContextSchema?: TSharedSchema;
125
- }, options?: RequestOptions): ModelResult<TTools, TShared>;
126
117
  }
127
118
  //# sourceMappingURL=sdk.d.ts.map
package/esm/sdk/sdk.js CHANGED
@@ -41,9 +41,7 @@ import { TTS } from "./tts.js";
41
41
  import { Vault } from "./vault.js";
42
42
  import { VideoGeneration } from "./videogeneration.js";
43
43
  import { Workspaces } from "./workspaces.js";
44
- import { callModel as callModelFunc, } from "../funcs/call-model.js";
45
- import { ToolType } from "../lib/tool-types.js";
46
- export { ToolType };
44
+ // #region imports
47
45
  // #endregion imports
48
46
  export class OpenRouter extends ClientSDK {
49
47
  get analytics() {
@@ -160,9 +158,5 @@ export class OpenRouter extends ClientSDK {
160
158
  get workspaces() {
161
159
  return (this._workspaces ?? (this._workspaces = new Workspaces(this._options)));
162
160
  }
163
- // #region sdk-class-body
164
- callModel(request, options) {
165
- return callModelFunc(this, request, options);
166
- }
167
161
  }
168
162
  //# sourceMappingURL=sdk.js.map
package/jsr.json CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  {
4
4
  "name": "@openrouter/sdk",
5
- "version": "1.5.56",
5
+ "version": "1.5.57",
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": "1.5.56",
3
+ "version": "1.5.57",
4
4
  "author": "OpenRouter",
5
5
  "description": "The OpenRouter TypeScript SDK is a type-safe toolkit for building AI applications with access to 400+ language models through a unified API.",
6
6
  "keywords": [
@@ -73,15 +73,15 @@
73
73
  "lint": "eslint --cache --max-warnings=0 src",
74
74
  "build": "tsc && node scripts/unbarrel-imports.js",
75
75
  "prepublishOnly": "npm run build",
76
+ "prepare": "npm run build",
76
77
  "test:transit": "exit 0",
77
- "typecheck": "tsc --noEmit",
78
- "typecheck:transit": "exit 0",
79
- "test:e2e": "vitest --run --project e2e",
80
78
  "test:watch": "vitest --watch --project unit",
79
+ "typecheck:transit": "exit 0",
81
80
  "compile": "tsc && node scripts/unbarrel-imports.js",
82
- "postinstall": "node scripts/check-types.js || true",
83
- "prepare": "npm run build",
84
- "test": "vitest --run --project unit"
81
+ "test": "vitest --run --project unit",
82
+ "test:e2e": "vitest --run --project e2e",
83
+ "typecheck": "tsc --noEmit",
84
+ "postinstall": "node scripts/check-types.js || true"
85
85
  },
86
86
  "peerDependencies": {
87
87
 
@@ -1,67 +0,0 @@
1
- import type { $ZodObject, $ZodShape, infer as zodInfer } from 'zod/v4/core';
2
- import type { OpenRouterCore } from '../core.js';
3
- import type { CallModelInput } from '../lib/async-params.js';
4
- import type { RequestOptions } from '../lib/sdks.js';
5
- import type { Tool } from '../lib/tool-types.js';
6
- import { ModelResult } from '../lib/model-result.js';
7
- export type { CallModelInput } from '../lib/async-params.js';
8
- /**
9
- * Get a response with multiple consumption patterns
10
- *
11
- * @remarks
12
- * Creates a response using the OpenResponses API and returns
13
- * a wrapper that allows consuming the response in multiple ways:
14
- *
15
- * - `await response.getText()` - Get just the text content (tools auto-executed)
16
- * - `await response.getResponse()` - Get full response with usage data (inputTokens, cachedTokens, etc.)
17
- * - `for await (const delta of response.getTextStream())` - Stream text deltas
18
- * - `for await (const delta of response.getReasoningStream())` - Stream reasoning deltas
19
- * - `for await (const event of response.getToolStream())` - Stream tool events (incl. preliminary results)
20
- * - `for await (const toolCall of response.getToolCallsStream())` - Stream structured tool calls
21
- * - `await response.getToolCalls()` - Get all tool calls from completed response
22
- * - `for await (const msg of response.getNewMessagesStream())` - Stream cumulative message snapshots
23
- * - `for await (const event of response.getFullResponsesStream())` - Stream all events (incl. tool preliminary)
24
- *
25
- * All consumption patterns can be used concurrently on the same response.
26
- *
27
- * **Context:**
28
- *
29
- * Tools can declare a `contextSchema` to receive typed context data.
30
- * The `context` parameter on callModel is typed as the intersection of all tool schemas:
31
- *
32
- * @example
33
- * ```typescript
34
- * const result = callModel(client, {
35
- * model: 'gpt-4',
36
- * input: 'Hello',
37
- * tools: [weatherTool, dbTool] as const,
38
- * context: {
39
- * get_weather: { apiKey: 'sk-...' },
40
- * db_query: { dbUrl: 'postgres://...' },
41
- * },
42
- * });
43
- * ```
44
- *
45
- * Context can also be a function or async function:
46
- * ```typescript
47
- * context: (turn) => ({
48
- * get_weather: { apiKey: turn.numberOfTurns > 1 ? refreshedKey : initialKey },
49
- * })
50
- * ```
51
- *
52
- * **Stop Conditions:**
53
- *
54
- * Control when tool execution stops using the `stopWhen` parameter:
55
- *
56
- * @example
57
- * ```typescript
58
- * stopWhen: stepCountIs(3)
59
- * stopWhen: [stepCountIs(10), maxCost(0.50), hasToolCall('finalize')]
60
- * ```
61
- *
62
- * Default: `stepCountIs(5)` if not specified
63
- */
64
- export declare function callModel<TTools extends readonly Tool[], TSharedSchema extends $ZodObject<$ZodShape> | undefined = undefined, TShared extends Record<string, unknown> = TSharedSchema extends $ZodObject<$ZodShape> ? zodInfer<TSharedSchema> : Record<string, never>>(client: OpenRouterCore, request: CallModelInput<TTools, TShared> & {
65
- sharedContextSchema?: TSharedSchema;
66
- }, options?: RequestOptions): ModelResult<TTools, TShared>;
67
- //# sourceMappingURL=call-model.d.ts.map
@@ -1,98 +0,0 @@
1
- import { ModelResult } from '../lib/model-result.js';
2
- import { convertToolsToAPIFormat } from '../lib/tool-executor.js';
3
- /**
4
- * Get a response with multiple consumption patterns
5
- *
6
- * @remarks
7
- * Creates a response using the OpenResponses API and returns
8
- * a wrapper that allows consuming the response in multiple ways:
9
- *
10
- * - `await response.getText()` - Get just the text content (tools auto-executed)
11
- * - `await response.getResponse()` - Get full response with usage data (inputTokens, cachedTokens, etc.)
12
- * - `for await (const delta of response.getTextStream())` - Stream text deltas
13
- * - `for await (const delta of response.getReasoningStream())` - Stream reasoning deltas
14
- * - `for await (const event of response.getToolStream())` - Stream tool events (incl. preliminary results)
15
- * - `for await (const toolCall of response.getToolCallsStream())` - Stream structured tool calls
16
- * - `await response.getToolCalls()` - Get all tool calls from completed response
17
- * - `for await (const msg of response.getNewMessagesStream())` - Stream cumulative message snapshots
18
- * - `for await (const event of response.getFullResponsesStream())` - Stream all events (incl. tool preliminary)
19
- *
20
- * All consumption patterns can be used concurrently on the same response.
21
- *
22
- * **Context:**
23
- *
24
- * Tools can declare a `contextSchema` to receive typed context data.
25
- * The `context` parameter on callModel is typed as the intersection of all tool schemas:
26
- *
27
- * @example
28
- * ```typescript
29
- * const result = callModel(client, {
30
- * model: 'gpt-4',
31
- * input: 'Hello',
32
- * tools: [weatherTool, dbTool] as const,
33
- * context: {
34
- * get_weather: { apiKey: 'sk-...' },
35
- * db_query: { dbUrl: 'postgres://...' },
36
- * },
37
- * });
38
- * ```
39
- *
40
- * Context can also be a function or async function:
41
- * ```typescript
42
- * context: (turn) => ({
43
- * get_weather: { apiKey: turn.numberOfTurns > 1 ? refreshedKey : initialKey },
44
- * })
45
- * ```
46
- *
47
- * **Stop Conditions:**
48
- *
49
- * Control when tool execution stops using the `stopWhen` parameter:
50
- *
51
- * @example
52
- * ```typescript
53
- * stopWhen: stepCountIs(3)
54
- * stopWhen: [stepCountIs(10), maxCost(0.50), hasToolCall('finalize')]
55
- * ```
56
- *
57
- * Default: `stepCountIs(5)` if not specified
58
- */
59
- export function callModel(client, request, options) {
60
- // Destructure state management options along with tools and stopWhen
61
- const { tools, stopWhen, state, requireApproval, approveToolCalls, rejectToolCalls, context, sharedContextSchema, onTurnStart, onTurnEnd, ...apiRequest } = request;
62
- // Convert tools to API format - no cast needed now that convertToolsToAPIFormat accepts readonly
63
- const apiTools = tools ? convertToolsToAPIFormat(tools) : undefined;
64
- // Build the request with converted tools
65
- // Note: async functions are resolved later in ModelResult.executeToolsIfNeeded()
66
- // The request can have async fields (functions) or sync fields, and the tools are converted to API format
67
- const finalRequest = {
68
- ...apiRequest,
69
- };
70
- if (apiTools !== undefined) {
71
- finalRequest['tools'] = apiTools;
72
- }
73
- // Inject x-openrouter-callmodel header into every callModel request
74
- const callModelOptions = {
75
- ...options,
76
- headers: {
77
- ...Object.fromEntries(new Headers(options?.headers ?? options?.fetchOptions?.headers ?? undefined)),
78
- 'x-openrouter-callmodel': 'true',
79
- },
80
- };
81
- return new ModelResult({
82
- client,
83
- request: finalRequest,
84
- options: callModelOptions,
85
- tools,
86
- ...(stopWhen !== undefined && { stopWhen }),
87
- // Pass state management options
88
- ...(state !== undefined && { state }),
89
- ...(requireApproval !== undefined && { requireApproval }),
90
- ...(approveToolCalls !== undefined && { approveToolCalls }),
91
- ...(rejectToolCalls !== undefined && { rejectToolCalls }),
92
- ...(context !== undefined && { context }),
93
- ...(sharedContextSchema !== undefined && { sharedContextSchema }),
94
- ...(onTurnStart !== undefined && { onTurnStart }),
95
- ...(onTurnEnd !== undefined && { onTurnEnd }),
96
- });
97
- }
98
- //# sourceMappingURL=call-model.js.map
@@ -1,51 +0,0 @@
1
- import type { InputsUnion } from '../models/inputsunion.js';
2
- import type { ClaudeMessageParam } from '../models/claude-message.js';
3
- import { convertToClaudeMessage } from './stream-transformers.js';
4
- /**
5
- * Convert Anthropic Claude-style messages to OpenResponses input format.
6
- *
7
- * This function transforms ClaudeMessageParam[] (Anthropic SDK format) to
8
- * OpenResponsesInput format that can be passed directly to callModel().
9
- *
10
- * Note: Some Claude features are lost in conversion as OpenRouter doesn't support them:
11
- * - cache_control on content blocks
12
- * - is_error flag on tool_result blocks
13
- *
14
- * @example
15
- * ```typescript
16
- * import { fromClaudeMessages } from '@openrouter/sdk';
17
- *
18
- * const claudeMessages = [
19
- * { role: "user", content: "Hello!" },
20
- * { role: "assistant", content: "Hi there!" },
21
- * ];
22
- *
23
- * const response = openrouter.callModel({
24
- * model: "anthropic/claude-3-sonnet",
25
- * input: fromClaudeMessages(claudeMessages),
26
- * });
27
- * ```
28
- */
29
- export declare function fromClaudeMessages(messages: ClaudeMessageParam[]): InputsUnion;
30
- /**
31
- * Convert an OpenResponses response to Anthropic Claude message format.
32
- *
33
- * This function transforms OpenResponsesResult to ClaudeMessage
34
- * (Anthropic SDK format) for compatibility with code expecting Claude responses.
35
- *
36
- * @example
37
- * ```typescript
38
- * import { toClaudeMessage } from '@openrouter/sdk';
39
- *
40
- * const response = await openrouter.callModel({
41
- * model: "anthropic/claude-3-sonnet",
42
- * input: "Hello!",
43
- * });
44
- *
45
- * const openResponsesResult = await response.getResponse();
46
- * const claudeMessage = toClaudeMessage(openResponsesResult);
47
- * // claudeMessage is now compatible with Anthropic SDK types
48
- * ```
49
- */
50
- export declare const toClaudeMessage: typeof convertToClaudeMessage;
51
- //# sourceMappingURL=anthropic-compat.d.ts.map