@openrouter/sdk 0.8.0 → 0.9.11

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 (135) hide show
  1. package/esm/funcs/chatSend.d.ts +3 -3
  2. package/esm/funcs/chatSend.js +18 -2
  3. package/esm/lib/config.d.ts +2 -2
  4. package/esm/lib/config.js +2 -2
  5. package/esm/models/assistantmessage.d.ts +47 -36
  6. package/esm/models/assistantmessage.js +35 -47
  7. package/esm/models/assistantmessageimages.d.ts +33 -0
  8. package/esm/models/assistantmessageimages.js +44 -0
  9. package/esm/models/chatgenerationparams.d.ts +453 -126
  10. package/esm/models/chatgenerationparams.js +238 -97
  11. package/esm/models/chatgenerationtokenusage.d.ts +48 -0
  12. package/esm/models/chatmessagecontentitem.d.ts +15 -10
  13. package/esm/models/chatmessagecontentitem.js +25 -4
  14. package/esm/models/chatmessagecontentitemaudio.d.ts +20 -2
  15. package/esm/models/chatmessagecontentitemaudio.js +9 -2
  16. package/esm/models/chatmessagecontentitemcachecontrol.d.ts +14 -3
  17. package/esm/models/chatmessagecontentitemcachecontrol.js +9 -2
  18. package/esm/models/chatmessagecontentitemimage.d.ts +26 -3
  19. package/esm/models/chatmessagecontentitemimage.js +12 -2
  20. package/esm/models/chatmessagecontentitemtext.d.ts +17 -2
  21. package/esm/models/chatmessagecontentitemtext.js +9 -2
  22. package/esm/models/chatmessagecontentitemvideo.d.ts +12 -55
  23. package/esm/models/chatmessagecontentitemvideo.js +5 -72
  24. package/esm/models/chatmessagecontentitemvideolegacy.d.ts +28 -0
  25. package/esm/models/chatmessagecontentitemvideolegacy.js +33 -0
  26. package/esm/models/chatmessagetokenlogprob.d.ts +15 -0
  27. package/esm/models/chatmessagetokenlogprobs.d.ts +9 -0
  28. package/esm/models/chatmessagetoolcall.d.ts +23 -2
  29. package/esm/models/chatmessagetoolcall.js +9 -2
  30. package/esm/models/chatresponse.d.ts +29 -1
  31. package/esm/models/chatresponse.js +6 -1
  32. package/esm/models/chatresponsechoice.d.ts +13 -2
  33. package/esm/models/chatresponsechoice.js +1 -2
  34. package/esm/models/chatstreamingchoice.d.ts +13 -2
  35. package/esm/models/chatstreamingchoice.js +1 -2
  36. package/esm/models/chatstreamingmessagechunk.d.ts +29 -2
  37. package/esm/models/chatstreamingmessagechunk.js +5 -2
  38. package/esm/models/chatstreamingmessagetoolcall.d.ts +38 -1
  39. package/esm/models/chatstreamingmessagetoolcall.js +9 -1
  40. package/esm/models/chatstreamingresponsechunk.d.ts +45 -11
  41. package/esm/models/chatstreamingresponsechunk.js +11 -25
  42. package/esm/models/chatstreamoptions.d.ts +8 -0
  43. package/esm/models/debugoptions.d.ts +18 -0
  44. package/esm/models/debugoptions.js +18 -0
  45. package/esm/models/developermessage.d.ts +12 -0
  46. package/esm/models/errors/index.d.ts +0 -1
  47. package/esm/models/errors/index.js +0 -1
  48. package/esm/models/index.d.ts +12 -8
  49. package/esm/models/index.js +12 -8
  50. package/esm/models/jsonschemaconfig.d.ts +17 -2
  51. package/esm/models/jsonschemaconfig.js +1 -1
  52. package/esm/models/message.d.ts +9 -2
  53. package/esm/models/message.js +1 -1
  54. package/esm/models/modelscountresponse.d.ts +4 -4
  55. package/esm/models/modelscountresponse.js +4 -4
  56. package/esm/models/namedtoolchoice.d.ts +15 -2
  57. package/esm/models/namedtoolchoice.js +6 -1
  58. package/esm/models/openairesponsesreasoningconfig.d.ts +1 -1
  59. package/esm/models/openairesponsesreasoningconfig.js +1 -1
  60. package/esm/models/openresponsesnonstreamingresponse.d.ts +4 -4
  61. package/esm/models/openresponsesnonstreamingresponse.js +3 -3
  62. package/esm/models/openresponsesreasoning.d.ts +2 -2
  63. package/esm/models/openresponsesreasoning.js +1 -1
  64. package/esm/models/openresponsesreasoningconfig.d.ts +2 -2
  65. package/esm/models/openresponsesreasoningconfig.js +1 -1
  66. package/esm/models/openresponsesrequest.d.ts +62 -32
  67. package/esm/models/openresponsesrequest.js +61 -36
  68. package/esm/models/operations/createauthkeyscode.d.ts +24 -0
  69. package/esm/models/operations/createauthkeyscode.js +14 -0
  70. package/esm/models/operations/getgeneration.d.ts +2 -0
  71. package/esm/models/operations/getgeneration.js +2 -0
  72. package/esm/models/operations/sendchatcompletionrequest.d.ts +12 -3
  73. package/esm/models/operations/sendchatcompletionrequest.js +20 -2
  74. package/esm/models/providername.d.ts +2 -0
  75. package/esm/models/providername.js +2 -0
  76. package/esm/models/providerpreferences.d.ts +45 -14
  77. package/esm/models/providerpreferences.js +29 -15
  78. package/esm/models/providersort.d.ts +6 -0
  79. package/esm/models/providersort.js +3 -0
  80. package/esm/models/providersortconfig.d.ts +30 -2
  81. package/esm/models/providersortconfig.js +15 -2
  82. package/esm/models/reasoningdetailencrypted.d.ts +42 -0
  83. package/esm/models/reasoningdetailencrypted.js +42 -0
  84. package/esm/models/reasoningdetailsummary.d.ts +42 -0
  85. package/esm/models/reasoningdetailsummary.js +42 -0
  86. package/esm/models/reasoningdetailtext.d.ts +44 -0
  87. package/esm/models/reasoningdetailtext.js +44 -0
  88. package/esm/models/reasoningdetailunion.d.ts +19 -0
  89. package/esm/models/reasoningdetailunion.js +28 -0
  90. package/esm/models/responseformatjsonobject.d.ts +20 -0
  91. package/esm/models/responseformatjsonobject.js +21 -0
  92. package/esm/models/responseformatjsonschema.d.ts +6 -0
  93. package/esm/models/responseformattext.d.ts +15 -0
  94. package/esm/models/responseformattext.js +13 -0
  95. package/esm/models/responseformattextconfig.d.ts +3 -3
  96. package/esm/models/responseformattextconfig.js +3 -3
  97. package/esm/models/responseformattextgrammar.d.ts +6 -0
  98. package/esm/models/responseformattextpython.d.ts +15 -0
  99. package/esm/models/responseformattextpython.js +13 -0
  100. package/esm/models/responseserrorfield.d.ts +4 -4
  101. package/esm/models/responseserrorfield.js +4 -4
  102. package/esm/models/responsesoutputitemreasoning.d.ts +2 -2
  103. package/esm/models/responsesoutputitemreasoning.js +2 -2
  104. package/esm/models/systemmessage.d.ts +12 -0
  105. package/esm/models/toolchoiceoption.d.ts +31 -0
  106. package/esm/models/toolchoiceoption.js +32 -0
  107. package/esm/models/tooldefinitionjson.d.ts +38 -4
  108. package/esm/models/tooldefinitionjson.js +14 -2
  109. package/esm/models/toolresponsemessage.d.ts +12 -0
  110. package/esm/models/usermessage.d.ts +12 -0
  111. package/esm/models/videoinput.d.ts +23 -0
  112. package/esm/models/videoinput.js +22 -0
  113. package/esm/sdk/chat.d.ts +1 -1
  114. package/esm/sdk/sdk.d.ts +2 -2
  115. package/esm/sdk/sdk.js +3 -3
  116. package/jsr.json +1 -1
  117. package/package.json +1 -1
  118. package/esm/models/chaterror.d.ts +0 -17
  119. package/esm/models/chaterror.js +0 -25
  120. package/esm/models/errors/chaterror.d.ts +0 -19
  121. package/esm/models/errors/chaterror.js +0 -32
  122. package/esm/models/providersortunion.d.ts +0 -10
  123. package/esm/models/providersortunion.js +0 -13
  124. package/esm/models/responsesformatjsonobject.d.ts +0 -20
  125. package/esm/models/responsesformatjsonobject.js +0 -21
  126. package/esm/models/schema10.d.ts +0 -33
  127. package/esm/models/schema10.js +0 -30
  128. package/esm/models/schema14.d.ts +0 -8
  129. package/esm/models/schema14.js +0 -12
  130. package/esm/models/schema17.d.ts +0 -102
  131. package/esm/models/schema17.js +0 -95
  132. package/esm/models/schema19.d.ts +0 -92
  133. package/esm/models/schema19.js +0 -109
  134. package/esm/models/schema5.d.ts +0 -86
  135. package/esm/models/schema5.js +0 -89
@@ -73,7 +73,7 @@ export const ResponsesOutputItemReasoningFormat$outboundSchema = openEnums.outbo
73
73
  export const ResponsesOutputItemReasoning$inboundSchema = z.object({
74
74
  type: ResponsesOutputItemReasoningType$inboundSchema,
75
75
  id: z.string(),
76
- content: z.array(ReasoningTextContent$inboundSchema).optional(),
76
+ content: z.nullable(z.array(ReasoningTextContent$inboundSchema)).optional(),
77
77
  summary: z.array(ReasoningSummaryText$inboundSchema),
78
78
  encrypted_content: z.nullable(z.string()).optional(),
79
79
  status: z.union([
@@ -93,7 +93,7 @@ export const ResponsesOutputItemReasoning$inboundSchema = z.object({
93
93
  export const ResponsesOutputItemReasoning$outboundSchema = z.object({
94
94
  type: ResponsesOutputItemReasoningType$outboundSchema,
95
95
  id: z.string(),
96
- content: z.array(ReasoningTextContent$outboundSchema).optional(),
96
+ content: z.nullable(z.array(ReasoningTextContent$outboundSchema)).optional(),
97
97
  summary: z.array(ReasoningSummaryText$outboundSchema),
98
98
  encryptedContent: z.nullable(z.string()).optional(),
99
99
  status: z.union([
@@ -1,9 +1,21 @@
1
1
  import * as z from "zod/v4";
2
2
  import { ChatMessageContentItemText, ChatMessageContentItemText$Outbound } from "./chatmessagecontentitemtext.js";
3
+ /**
4
+ * System message content
5
+ */
3
6
  export type SystemMessageContent = string | Array<ChatMessageContentItemText>;
7
+ /**
8
+ * System message for setting behavior
9
+ */
4
10
  export type SystemMessage = {
5
11
  role: "system";
12
+ /**
13
+ * System message content
14
+ */
6
15
  content: string | Array<ChatMessageContentItemText>;
16
+ /**
17
+ * Optional name for the system message
18
+ */
7
19
  name?: string | undefined;
8
20
  };
9
21
  /** @internal */
@@ -0,0 +1,31 @@
1
+ import * as z from "zod/v4";
2
+ import { ClosedEnum } from "../types/enums.js";
3
+ import { NamedToolChoice, NamedToolChoice$Outbound } from "./namedtoolchoice.js";
4
+ export declare const ToolChoiceOptionRequired: {
5
+ readonly Required: "required";
6
+ };
7
+ export type ToolChoiceOptionRequired = ClosedEnum<typeof ToolChoiceOptionRequired>;
8
+ export declare const ToolChoiceOptionAuto: {
9
+ readonly Auto: "auto";
10
+ };
11
+ export type ToolChoiceOptionAuto = ClosedEnum<typeof ToolChoiceOptionAuto>;
12
+ export declare const ToolChoiceOptionNone: {
13
+ readonly None: "none";
14
+ };
15
+ export type ToolChoiceOptionNone = ClosedEnum<typeof ToolChoiceOptionNone>;
16
+ /**
17
+ * Tool choice configuration
18
+ */
19
+ export type ToolChoiceOption = NamedToolChoice | ToolChoiceOptionNone | ToolChoiceOptionAuto | ToolChoiceOptionRequired;
20
+ /** @internal */
21
+ export declare const ToolChoiceOptionRequired$outboundSchema: z.ZodEnum<typeof ToolChoiceOptionRequired>;
22
+ /** @internal */
23
+ export declare const ToolChoiceOptionAuto$outboundSchema: z.ZodEnum<typeof ToolChoiceOptionAuto>;
24
+ /** @internal */
25
+ export declare const ToolChoiceOptionNone$outboundSchema: z.ZodEnum<typeof ToolChoiceOptionNone>;
26
+ /** @internal */
27
+ export type ToolChoiceOption$Outbound = NamedToolChoice$Outbound | string | string | string;
28
+ /** @internal */
29
+ export declare const ToolChoiceOption$outboundSchema: z.ZodType<ToolChoiceOption$Outbound, ToolChoiceOption>;
30
+ export declare function toolChoiceOptionToJSON(toolChoiceOption: ToolChoiceOption): string;
31
+ //# sourceMappingURL=toolchoiceoption.d.ts.map
@@ -0,0 +1,32 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: d767ca0ded82
4
+ */
5
+ import * as z from "zod/v4";
6
+ import { NamedToolChoice$outboundSchema, } from "./namedtoolchoice.js";
7
+ export const ToolChoiceOptionRequired = {
8
+ Required: "required",
9
+ };
10
+ export const ToolChoiceOptionAuto = {
11
+ Auto: "auto",
12
+ };
13
+ export const ToolChoiceOptionNone = {
14
+ None: "none",
15
+ };
16
+ /** @internal */
17
+ export const ToolChoiceOptionRequired$outboundSchema = z.enum(ToolChoiceOptionRequired);
18
+ /** @internal */
19
+ export const ToolChoiceOptionAuto$outboundSchema = z.enum(ToolChoiceOptionAuto);
20
+ /** @internal */
21
+ export const ToolChoiceOptionNone$outboundSchema = z.enum(ToolChoiceOptionNone);
22
+ /** @internal */
23
+ export const ToolChoiceOption$outboundSchema = z.union([
24
+ NamedToolChoice$outboundSchema,
25
+ ToolChoiceOptionNone$outboundSchema,
26
+ ToolChoiceOptionAuto$outboundSchema,
27
+ ToolChoiceOptionRequired$outboundSchema,
28
+ ]);
29
+ export function toolChoiceOptionToJSON(toolChoiceOption) {
30
+ return JSON.stringify(ToolChoiceOption$outboundSchema.parse(toolChoiceOption));
31
+ }
32
+ //# sourceMappingURL=toolchoiceoption.js.map
@@ -1,22 +1,55 @@
1
1
  import * as z from "zod/v4";
2
+ import { ClosedEnum } from "../types/enums.js";
3
+ import { ChatMessageContentItemCacheControl, ChatMessageContentItemCacheControl$Outbound } from "./chatmessagecontentitemcachecontrol.js";
4
+ export declare const ToolDefinitionJsonType: {
5
+ readonly Function: "function";
6
+ };
7
+ export type ToolDefinitionJsonType = ClosedEnum<typeof ToolDefinitionJsonType>;
8
+ /**
9
+ * Function definition for tool calling
10
+ */
2
11
  export type ToolDefinitionJsonFunction = {
12
+ /**
13
+ * Function name (a-z, A-Z, 0-9, underscores, dashes, max 64 chars)
14
+ */
3
15
  name: string;
16
+ /**
17
+ * Function description for the model
18
+ */
4
19
  description?: string | undefined;
20
+ /**
21
+ * Function parameters as JSON Schema object
22
+ */
5
23
  parameters?: {
6
- [k: string]: any;
24
+ [k: string]: any | null;
7
25
  } | undefined;
26
+ /**
27
+ * Enable strict schema adherence
28
+ */
8
29
  strict?: boolean | null | undefined;
9
30
  };
31
+ /**
32
+ * Tool definition for function calling
33
+ */
10
34
  export type ToolDefinitionJson = {
11
- type: "function";
35
+ type: ToolDefinitionJsonType;
36
+ /**
37
+ * Function definition for tool calling
38
+ */
12
39
  function: ToolDefinitionJsonFunction;
40
+ /**
41
+ * Cache control for the content part
42
+ */
43
+ cacheControl?: ChatMessageContentItemCacheControl | undefined;
13
44
  };
14
45
  /** @internal */
46
+ export declare const ToolDefinitionJsonType$outboundSchema: z.ZodEnum<typeof ToolDefinitionJsonType>;
47
+ /** @internal */
15
48
  export type ToolDefinitionJsonFunction$Outbound = {
16
49
  name: string;
17
50
  description?: string | undefined;
18
51
  parameters?: {
19
- [k: string]: any;
52
+ [k: string]: any | null;
20
53
  } | undefined;
21
54
  strict?: boolean | null | undefined;
22
55
  };
@@ -25,8 +58,9 @@ export declare const ToolDefinitionJsonFunction$outboundSchema: z.ZodType<ToolDe
25
58
  export declare function toolDefinitionJsonFunctionToJSON(toolDefinitionJsonFunction: ToolDefinitionJsonFunction): string;
26
59
  /** @internal */
27
60
  export type ToolDefinitionJson$Outbound = {
28
- type: "function";
61
+ type: string;
29
62
  function: ToolDefinitionJsonFunction$Outbound;
63
+ cache_control?: ChatMessageContentItemCacheControl$Outbound | undefined;
30
64
  };
31
65
  /** @internal */
32
66
  export declare const ToolDefinitionJson$outboundSchema: z.ZodType<ToolDefinitionJson$Outbound, ToolDefinitionJson>;
@@ -3,11 +3,18 @@
3
3
  * @generated-id: 546c340f3013
4
4
  */
5
5
  import * as z from "zod/v4";
6
+ import { remap as remap$ } from "../lib/primitives.js";
7
+ import { ChatMessageContentItemCacheControl$outboundSchema, } from "./chatmessagecontentitemcachecontrol.js";
8
+ export const ToolDefinitionJsonType = {
9
+ Function: "function",
10
+ };
11
+ /** @internal */
12
+ export const ToolDefinitionJsonType$outboundSchema = z.enum(ToolDefinitionJsonType);
6
13
  /** @internal */
7
14
  export const ToolDefinitionJsonFunction$outboundSchema = z.object({
8
15
  name: z.string(),
9
16
  description: z.string().optional(),
10
- parameters: z.record(z.string(), z.any()).optional(),
17
+ parameters: z.record(z.string(), z.nullable(z.any())).optional(),
11
18
  strict: z.nullable(z.boolean()).optional(),
12
19
  });
13
20
  export function toolDefinitionJsonFunctionToJSON(toolDefinitionJsonFunction) {
@@ -15,8 +22,13 @@ export function toolDefinitionJsonFunctionToJSON(toolDefinitionJsonFunction) {
15
22
  }
16
23
  /** @internal */
17
24
  export const ToolDefinitionJson$outboundSchema = z.object({
18
- type: z.literal("function"),
25
+ type: ToolDefinitionJsonType$outboundSchema,
19
26
  function: z.lazy(() => ToolDefinitionJsonFunction$outboundSchema),
27
+ cacheControl: ChatMessageContentItemCacheControl$outboundSchema.optional(),
28
+ }).transform((v) => {
29
+ return remap$(v, {
30
+ cacheControl: "cache_control",
31
+ });
20
32
  });
21
33
  export function toolDefinitionJsonToJSON(toolDefinitionJson) {
22
34
  return JSON.stringify(ToolDefinitionJson$outboundSchema.parse(toolDefinitionJson));
@@ -1,9 +1,21 @@
1
1
  import * as z from "zod/v4";
2
2
  import { ChatMessageContentItem, ChatMessageContentItem$Outbound } from "./chatmessagecontentitem.js";
3
+ /**
4
+ * Tool response content
5
+ */
3
6
  export type ToolResponseMessageContent = string | Array<ChatMessageContentItem>;
7
+ /**
8
+ * Tool response message
9
+ */
4
10
  export type ToolResponseMessage = {
5
11
  role: "tool";
12
+ /**
13
+ * Tool response content
14
+ */
6
15
  content: string | Array<ChatMessageContentItem>;
16
+ /**
17
+ * ID of the assistant message tool call this message responds to
18
+ */
7
19
  toolCallId: string;
8
20
  };
9
21
  /** @internal */
@@ -1,9 +1,21 @@
1
1
  import * as z from "zod/v4";
2
2
  import { ChatMessageContentItem, ChatMessageContentItem$Outbound } from "./chatmessagecontentitem.js";
3
+ /**
4
+ * User message content
5
+ */
3
6
  export type UserMessageContent = string | Array<ChatMessageContentItem>;
7
+ /**
8
+ * User message
9
+ */
4
10
  export type UserMessage = {
5
11
  role: "user";
12
+ /**
13
+ * User message content
14
+ */
6
15
  content: string | Array<ChatMessageContentItem>;
16
+ /**
17
+ * Optional name for the user
18
+ */
7
19
  name?: string | undefined;
8
20
  };
9
21
  /** @internal */
@@ -0,0 +1,23 @@
1
+ import * as z from "zod/v4";
2
+ import { Result as SafeParseResult } from "../types/fp.js";
3
+ import { SDKValidationError } from "./errors/sdkvalidationerror.js";
4
+ /**
5
+ * Video input object
6
+ */
7
+ export type VideoInput = {
8
+ /**
9
+ * URL of the video (data: URLs supported)
10
+ */
11
+ url: string;
12
+ };
13
+ /** @internal */
14
+ export declare const VideoInput$inboundSchema: z.ZodType<VideoInput, unknown>;
15
+ /** @internal */
16
+ export type VideoInput$Outbound = {
17
+ url: string;
18
+ };
19
+ /** @internal */
20
+ export declare const VideoInput$outboundSchema: z.ZodType<VideoInput$Outbound, VideoInput>;
21
+ export declare function videoInputToJSON(videoInput: VideoInput): string;
22
+ export declare function videoInputFromJSON(jsonString: string): SafeParseResult<VideoInput, SDKValidationError>;
23
+ //# sourceMappingURL=videoinput.d.ts.map
@@ -0,0 +1,22 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: c9307d9d04a6
4
+ */
5
+ import * as z from "zod/v4";
6
+ import { safeParse } from "../lib/schemas.js";
7
+ /** @internal */
8
+ export const VideoInput$inboundSchema = z
9
+ .object({
10
+ url: z.string(),
11
+ });
12
+ /** @internal */
13
+ export const VideoInput$outboundSchema = z.object({
14
+ url: z.string(),
15
+ });
16
+ export function videoInputToJSON(videoInput) {
17
+ return JSON.stringify(VideoInput$outboundSchema.parse(videoInput));
18
+ }
19
+ export function videoInputFromJSON(jsonString) {
20
+ return safeParse(jsonString, (x) => VideoInput$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'VideoInput' from JSON`);
21
+ }
22
+ //# sourceMappingURL=videoinput.js.map
package/esm/sdk/chat.d.ts CHANGED
@@ -18,7 +18,7 @@ export declare class Chat extends ClientSDK {
18
18
  chatGenerationParams: {
19
19
  stream: true;
20
20
  };
21
- }, options?: RequestOptions): Promise<EventStream<models.ChatStreamingResponseChunkData>>;
21
+ }, options?: RequestOptions): Promise<EventStream<models.ChatStreamingResponseChunk>>;
22
22
  send(request: operations.SendChatCompletionRequestRequest, options?: RequestOptions): Promise<operations.SendChatCompletionRequestResponse>;
23
23
  }
24
24
  //# sourceMappingURL=chat.d.ts.map
package/esm/sdk/sdk.d.ts CHANGED
@@ -21,6 +21,8 @@ export declare class OpenRouter extends ClientSDK {
21
21
  get beta(): Beta;
22
22
  private _analytics?;
23
23
  get analytics(): Analytics;
24
+ private _chat?;
25
+ get chat(): Chat;
24
26
  private _credits?;
25
27
  get credits(): Credits;
26
28
  private _embeddings?;
@@ -39,8 +41,6 @@ export declare class OpenRouter extends ClientSDK {
39
41
  get guardrails(): Guardrails;
40
42
  private _oAuth?;
41
43
  get oAuth(): OAuth;
42
- private _chat?;
43
- get chat(): Chat;
44
44
  callModel<TTools extends readonly Tool[]>(request: CallModelInput<TTools>, options?: RequestOptions): ModelResult<TTools>;
45
45
  }
46
46
  //# sourceMappingURL=sdk.d.ts.map
package/esm/sdk/sdk.js CHANGED
@@ -27,6 +27,9 @@ export class OpenRouter extends ClientSDK {
27
27
  get analytics() {
28
28
  return (this._analytics ?? (this._analytics = new Analytics(this._options)));
29
29
  }
30
+ get chat() {
31
+ return (this._chat ?? (this._chat = new Chat(this._options)));
32
+ }
30
33
  get credits() {
31
34
  return (this._credits ?? (this._credits = new Credits(this._options)));
32
35
  }
@@ -54,9 +57,6 @@ export class OpenRouter extends ClientSDK {
54
57
  get oAuth() {
55
58
  return (this._oAuth ?? (this._oAuth = new OAuth(this._options)));
56
59
  }
57
- get chat() {
58
- return (this._chat ?? (this._chat = new Chat(this._options)));
59
- }
60
60
  // #region sdk-class-body
61
61
  callModel(request, options) {
62
62
  return callModelFunc(this, request, options);
package/jsr.json CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  {
4
4
  "name": "@openrouter/sdk",
5
- "version": "0.8.0",
5
+ "version": "0.9.11",
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.8.0",
3
+ "version": "0.9.11",
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": [
@@ -1,17 +0,0 @@
1
- import * as z from "zod/v4";
2
- import { Result as SafeParseResult } from "../types/fp.js";
3
- import { SDKValidationError } from "./errors/sdkvalidationerror.js";
4
- export type Code = string | number;
5
- export type ChatErrorError = {
6
- code: string | number | null;
7
- message: string;
8
- param?: string | null | undefined;
9
- type?: string | null | undefined;
10
- };
11
- /** @internal */
12
- export declare const Code$inboundSchema: z.ZodType<Code, unknown>;
13
- export declare function codeFromJSON(jsonString: string): SafeParseResult<Code, SDKValidationError>;
14
- /** @internal */
15
- export declare const ChatErrorError$inboundSchema: z.ZodType<ChatErrorError, unknown>;
16
- export declare function chatErrorErrorFromJSON(jsonString: string): SafeParseResult<ChatErrorError, SDKValidationError>;
17
- //# sourceMappingURL=chaterror.d.ts.map
@@ -1,25 +0,0 @@
1
- /*
2
- * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
- * @generated-id: b107ec938dc1
4
- */
5
- import * as z from "zod/v4";
6
- import { safeParse } from "../lib/schemas.js";
7
- /** @internal */
8
- export const Code$inboundSchema = z.union([
9
- z.string(),
10
- z.number(),
11
- ]);
12
- export function codeFromJSON(jsonString) {
13
- return safeParse(jsonString, (x) => Code$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Code' from JSON`);
14
- }
15
- /** @internal */
16
- export const ChatErrorError$inboundSchema = z.object({
17
- code: z.nullable(z.union([z.string(), z.number()])),
18
- message: z.string(),
19
- param: z.nullable(z.string()).optional(),
20
- type: z.nullable(z.string()).optional(),
21
- });
22
- export function chatErrorErrorFromJSON(jsonString) {
23
- return safeParse(jsonString, (x) => ChatErrorError$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ChatErrorError' from JSON`);
24
- }
25
- //# sourceMappingURL=chaterror.js.map
@@ -1,19 +0,0 @@
1
- import * as z from "zod/v4";
2
- import * as models from "../index.js";
3
- import { OpenRouterError } from "./openroutererror.js";
4
- export type ChatErrorData = {
5
- error: models.ChatErrorError;
6
- };
7
- export declare class ChatError extends OpenRouterError {
8
- error: models.ChatErrorError;
9
- /** The original data that was passed to this error instance. */
10
- data$: ChatErrorData;
11
- constructor(err: ChatErrorData, httpMeta: {
12
- response: Response;
13
- request: Request;
14
- body: string;
15
- });
16
- }
17
- /** @internal */
18
- export declare const ChatError$inboundSchema: z.ZodType<ChatError, unknown>;
19
- //# sourceMappingURL=chaterror.d.ts.map
@@ -1,32 +0,0 @@
1
- /*
2
- * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
- * @generated-id: a3b18e48f494
4
- */
5
- import * as z from "zod/v4";
6
- import * as models from "../index.js";
7
- import { OpenRouterError } from "./openroutererror.js";
8
- export class ChatError extends OpenRouterError {
9
- constructor(err, httpMeta) {
10
- const message = err.error?.message
11
- || `API error occurred: ${JSON.stringify(err)}`;
12
- super(message, httpMeta);
13
- this.data$ = err;
14
- this.error = err.error;
15
- this.name = "ChatError";
16
- }
17
- }
18
- /** @internal */
19
- export const ChatError$inboundSchema = z.object({
20
- error: z.lazy(() => models.ChatErrorError$inboundSchema),
21
- request$: z.custom(x => x instanceof Request),
22
- response$: z.custom(x => x instanceof Response),
23
- body$: z.string(),
24
- })
25
- .transform((v) => {
26
- return new ChatError(v, {
27
- request: v.request$,
28
- response: v.response$,
29
- body: v.body$,
30
- });
31
- });
32
- //# sourceMappingURL=chaterror.js.map
@@ -1,10 +0,0 @@
1
- import * as z from "zod/v4";
2
- import { ProviderSort } from "./providersort.js";
3
- import { ProviderSortConfig, ProviderSortConfig$Outbound } from "./providersortconfig.js";
4
- export type ProviderSortUnion = ProviderSort | ProviderSortConfig;
5
- /** @internal */
6
- export type ProviderSortUnion$Outbound = string | ProviderSortConfig$Outbound;
7
- /** @internal */
8
- export declare const ProviderSortUnion$outboundSchema: z.ZodType<ProviderSortUnion$Outbound, ProviderSortUnion>;
9
- export declare function providerSortUnionToJSON(providerSortUnion: ProviderSortUnion): string;
10
- //# sourceMappingURL=providersortunion.d.ts.map
@@ -1,13 +0,0 @@
1
- /*
2
- * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
- * @generated-id: 7a2d23baab80
4
- */
5
- import * as z from "zod/v4";
6
- import { ProviderSort$outboundSchema } from "./providersort.js";
7
- import { ProviderSortConfig$outboundSchema, } from "./providersortconfig.js";
8
- /** @internal */
9
- export const ProviderSortUnion$outboundSchema = z.union([ProviderSort$outboundSchema, ProviderSortConfig$outboundSchema]);
10
- export function providerSortUnionToJSON(providerSortUnion) {
11
- return JSON.stringify(ProviderSortUnion$outboundSchema.parse(providerSortUnion));
12
- }
13
- //# sourceMappingURL=providersortunion.js.map
@@ -1,20 +0,0 @@
1
- import * as z from "zod/v4";
2
- import { Result as SafeParseResult } from "../types/fp.js";
3
- import { SDKValidationError } from "./errors/sdkvalidationerror.js";
4
- /**
5
- * JSON object response format
6
- */
7
- export type ResponsesFormatJSONObject = {
8
- type: "json_object";
9
- };
10
- /** @internal */
11
- export declare const ResponsesFormatJSONObject$inboundSchema: z.ZodType<ResponsesFormatJSONObject, unknown>;
12
- /** @internal */
13
- export type ResponsesFormatJSONObject$Outbound = {
14
- type: "json_object";
15
- };
16
- /** @internal */
17
- export declare const ResponsesFormatJSONObject$outboundSchema: z.ZodType<ResponsesFormatJSONObject$Outbound, ResponsesFormatJSONObject>;
18
- export declare function responsesFormatJSONObjectToJSON(responsesFormatJSONObject: ResponsesFormatJSONObject): string;
19
- export declare function responsesFormatJSONObjectFromJSON(jsonString: string): SafeParseResult<ResponsesFormatJSONObject, SDKValidationError>;
20
- //# sourceMappingURL=responsesformatjsonobject.d.ts.map
@@ -1,21 +0,0 @@
1
- /*
2
- * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
- * @generated-id: cd67052e598c
4
- */
5
- import * as z from "zod/v4";
6
- import { safeParse } from "../lib/schemas.js";
7
- /** @internal */
8
- export const ResponsesFormatJSONObject$inboundSchema = z.object({
9
- type: z.literal("json_object"),
10
- });
11
- /** @internal */
12
- export const ResponsesFormatJSONObject$outboundSchema = z.object({
13
- type: z.literal("json_object"),
14
- });
15
- export function responsesFormatJSONObjectToJSON(responsesFormatJSONObject) {
16
- return JSON.stringify(ResponsesFormatJSONObject$outboundSchema.parse(responsesFormatJSONObject));
17
- }
18
- export function responsesFormatJSONObjectFromJSON(jsonString) {
19
- return safeParse(jsonString, (x) => ResponsesFormatJSONObject$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ResponsesFormatJSONObject' from JSON`);
20
- }
21
- //# sourceMappingURL=responsesformatjsonobject.js.map
@@ -1,33 +0,0 @@
1
- import * as z from "zod/v4";
2
- import { Schema14, Schema14$Outbound } from "./schema14.js";
3
- export type Prompt = number | string | any;
4
- export type Completion = number | string | any;
5
- export type Schema10 = {
6
- prompt?: number | string | any | undefined;
7
- completion?: number | string | any | undefined;
8
- image?: Schema14 | undefined;
9
- audio?: Schema14 | undefined;
10
- request?: Schema14 | undefined;
11
- };
12
- /** @internal */
13
- export type Prompt$Outbound = number | string | any;
14
- /** @internal */
15
- export declare const Prompt$outboundSchema: z.ZodType<Prompt$Outbound, Prompt>;
16
- export declare function promptToJSON(prompt: Prompt): string;
17
- /** @internal */
18
- export type Completion$Outbound = number | string | any;
19
- /** @internal */
20
- export declare const Completion$outboundSchema: z.ZodType<Completion$Outbound, Completion>;
21
- export declare function completionToJSON(completion: Completion): string;
22
- /** @internal */
23
- export type Schema10$Outbound = {
24
- prompt?: number | string | any | undefined;
25
- completion?: number | string | any | undefined;
26
- image?: Schema14$Outbound | undefined;
27
- audio?: Schema14$Outbound | undefined;
28
- request?: Schema14$Outbound | undefined;
29
- };
30
- /** @internal */
31
- export declare const Schema10$outboundSchema: z.ZodType<Schema10$Outbound, Schema10>;
32
- export declare function schema10ToJSON(schema10: Schema10): string;
33
- //# sourceMappingURL=schema10.d.ts.map
@@ -1,30 +0,0 @@
1
- /*
2
- * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
- * @generated-id: 3a361cbac0f8
4
- */
5
- import * as z from "zod/v4";
6
- import { Schema14$outboundSchema, } from "./schema14.js";
7
- /** @internal */
8
- export const Prompt$outboundSchema = z
9
- .union([z.number(), z.string(), z.any()]);
10
- export function promptToJSON(prompt) {
11
- return JSON.stringify(Prompt$outboundSchema.parse(prompt));
12
- }
13
- /** @internal */
14
- export const Completion$outboundSchema = z.union([z.number(), z.string(), z.any()]);
15
- export function completionToJSON(completion) {
16
- return JSON.stringify(Completion$outboundSchema.parse(completion));
17
- }
18
- /** @internal */
19
- export const Schema10$outboundSchema = z
20
- .object({
21
- prompt: z.union([z.number(), z.string(), z.any()]).optional(),
22
- completion: z.union([z.number(), z.string(), z.any()]).optional(),
23
- image: Schema14$outboundSchema.optional(),
24
- audio: Schema14$outboundSchema.optional(),
25
- request: Schema14$outboundSchema.optional(),
26
- });
27
- export function schema10ToJSON(schema10) {
28
- return JSON.stringify(Schema10$outboundSchema.parse(schema10));
29
- }
30
- //# sourceMappingURL=schema10.js.map
@@ -1,8 +0,0 @@
1
- import * as z from "zod/v4";
2
- export type Schema14 = number | string | any;
3
- /** @internal */
4
- export type Schema14$Outbound = number | string | any;
5
- /** @internal */
6
- export declare const Schema14$outboundSchema: z.ZodType<Schema14$Outbound, Schema14>;
7
- export declare function schema14ToJSON(schema14: Schema14): string;
8
- //# sourceMappingURL=schema14.d.ts.map
@@ -1,12 +0,0 @@
1
- /*
2
- * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
- * @generated-id: 197e0ddbcace
4
- */
5
- import * as z from "zod/v4";
6
- /** @internal */
7
- export const Schema14$outboundSchema = z
8
- .union([z.number(), z.string(), z.any()]);
9
- export function schema14ToJSON(schema14) {
10
- return JSON.stringify(Schema14$outboundSchema.parse(schema14));
11
- }
12
- //# sourceMappingURL=schema14.js.map