@openrouter/sdk 0.1.10 → 0.1.13

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 (98) hide show
  1. package/esm/lib/config.d.ts +3 -3
  2. package/esm/lib/config.js +3 -3
  3. package/esm/models/chatgenerationparams.d.ts +2 -1
  4. package/esm/models/chatgenerationparams.js +4 -4
  5. package/esm/models/chatmessagecontentitem.d.ts +4 -0
  6. package/esm/models/chatmessagecontentitem.js +2 -0
  7. package/esm/models/chatmessagecontentitemaudio.d.ts +1 -1
  8. package/esm/models/chatmessagecontentitemaudio.js +3 -10
  9. package/esm/models/chatmessagecontentitemimage.d.ts +1 -1
  10. package/esm/models/chatmessagecontentitemimage.js +3 -10
  11. package/esm/models/chatmessagecontentitemvideo.d.ts +48 -11
  12. package/esm/models/chatmessagecontentitemvideo.js +64 -11
  13. package/esm/models/chatresponsechoice.d.ts +21 -1
  14. package/esm/models/chatresponsechoice.js +25 -1
  15. package/esm/models/chatstreamingresponsechunk.d.ts +1 -1
  16. package/esm/models/chatstreamingresponsechunk.js +1 -1
  17. package/esm/models/completionchoice.js +2 -6
  18. package/esm/models/createchargerequest.d.ts +1 -1
  19. package/esm/models/createchargerequest.js +3 -4
  20. package/esm/models/datacollection.d.ts +26 -0
  21. package/esm/models/datacollection.js +19 -0
  22. package/esm/models/endpointstatus.js +2 -7
  23. package/esm/models/imagegenerationstatus.d.ts +1 -1
  24. package/esm/models/imagegenerationstatus.js +3 -11
  25. package/esm/models/index.d.ts +2 -2
  26. package/esm/models/index.js +2 -2
  27. package/esm/models/inputmodality.js +2 -7
  28. package/esm/models/instructtype.js +2 -7
  29. package/esm/models/listendpointsresponse.js +3 -6
  30. package/esm/models/modelarchitecture.js +2 -6
  31. package/esm/models/modelgroup.js +2 -7
  32. package/esm/models/openairesponsesincludable.d.ts +1 -1
  33. package/esm/models/openairesponsesincludable.js +2 -5
  34. package/esm/models/openairesponsesincompletedetails.js +3 -6
  35. package/esm/models/openairesponsesreasoningeffort.d.ts +2 -1
  36. package/esm/models/openairesponsesreasoningeffort.js +4 -11
  37. package/esm/models/openairesponsesresponsestatus.js +2 -7
  38. package/esm/models/openairesponsesservicetier.js +2 -7
  39. package/esm/models/openairesponsestruncation.js +2 -7
  40. package/esm/models/openresponsesreasoning.d.ts +2 -1
  41. package/esm/models/openresponsesreasoning.js +3 -4
  42. package/esm/models/openresponsesrequest.d.ts +8 -40
  43. package/esm/models/openresponsesrequest.js +10 -49
  44. package/esm/models/openresponsesresponsetext.d.ts +1 -1
  45. package/esm/models/openresponsesresponsetext.js +2 -4
  46. package/esm/models/operations/createauthkeyscode.d.ts +1 -1
  47. package/esm/models/operations/createauthkeyscode.js +2 -4
  48. package/esm/models/operations/createembeddings.d.ts +82 -61
  49. package/esm/models/operations/createembeddings.js +72 -52
  50. package/esm/models/operations/createkeys.d.ts +2 -2
  51. package/esm/models/operations/createkeys.js +3 -5
  52. package/esm/models/operations/exchangeauthcodeforapikey.d.ts +1 -1
  53. package/esm/models/operations/exchangeauthcodeforapikey.js +3 -4
  54. package/esm/models/operations/getcurrentkey.d.ts +4 -0
  55. package/esm/models/operations/getcurrentkey.js +2 -0
  56. package/esm/models/operations/getgeneration.js +3 -6
  57. package/esm/models/operations/getkey.js +1 -1
  58. package/esm/models/operations/getparameters.d.ts +3 -9
  59. package/esm/models/operations/getparameters.js +5 -18
  60. package/esm/models/operations/list.js +1 -1
  61. package/esm/models/operations/updatekeys.d.ts +1 -1
  62. package/esm/models/operations/updatekeys.js +3 -5
  63. package/esm/models/outputmodality.js +2 -7
  64. package/esm/models/parameter.js +3 -7
  65. package/esm/models/providername.d.ts +3 -27
  66. package/esm/models/providername.js +5 -37
  67. package/esm/models/providersort.d.ts +17 -0
  68. package/esm/models/providersort.js +15 -0
  69. package/esm/models/publicendpoint.d.ts +4 -0
  70. package/esm/models/publicendpoint.js +4 -6
  71. package/esm/models/publicpricing.d.ts +4 -0
  72. package/esm/models/publicpricing.js +2 -0
  73. package/esm/models/quantization.d.ts +1 -1
  74. package/esm/models/quantization.js +2 -5
  75. package/esm/models/reasoningsummaryverbosity.d.ts +1 -1
  76. package/esm/models/reasoningsummaryverbosity.js +3 -11
  77. package/esm/models/responseinputaudio.d.ts +1 -1
  78. package/esm/models/responseinputaudio.js +3 -10
  79. package/esm/models/responseinputimage.d.ts +1 -1
  80. package/esm/models/responseinputimage.js +3 -10
  81. package/esm/models/responseserrorfield.js +3 -6
  82. package/esm/models/responsessearchcontextsize.d.ts +1 -1
  83. package/esm/models/responsessearchcontextsize.js +3 -11
  84. package/esm/models/responsetextconfig.js +2 -6
  85. package/esm/models/toolcallstatus.d.ts +1 -1
  86. package/esm/models/toolcallstatus.js +3 -11
  87. package/esm/models/websearchstatus.d.ts +1 -1
  88. package/esm/models/websearchstatus.js +3 -11
  89. package/esm/types/enums.d.ts +10 -6
  90. package/esm/types/enums.js +38 -1
  91. package/esm/types/index.d.ts +0 -1
  92. package/esm/types/index.js +0 -1
  93. package/jsr.json +1 -1
  94. package/package.json +1 -1
  95. package/esm/models/chatcompletionfinishreason.d.ts +0 -13
  96. package/esm/models/chatcompletionfinishreason.js +0 -19
  97. package/esm/models/chatstreamingchoice.d.ts +0 -16
  98. package/esm/models/chatstreamingchoice.js +0 -24
@@ -1,8 +1,7 @@
1
1
  /*
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
3
  */
4
- import * as z from "zod/v4";
5
- import { catchUnrecognizedEnum, } from "../types/enums.js";
4
+ import * as openEnums from "../types/enums.js";
6
5
  /**
7
6
  * Size of the search context for web search tools
8
7
  */
@@ -12,14 +11,7 @@ export const ResponsesSearchContextSize = {
12
11
  High: "high",
13
12
  };
14
13
  /** @internal */
15
- export const ResponsesSearchContextSize$inboundSchema = z
16
- .union([
17
- z.enum(ResponsesSearchContextSize),
18
- z.string().transform(catchUnrecognizedEnum),
19
- ]);
14
+ export const ResponsesSearchContextSize$inboundSchema = openEnums.inboundSchema(ResponsesSearchContextSize);
20
15
  /** @internal */
21
- export const ResponsesSearchContextSize$outboundSchema = z.union([
22
- z.enum(ResponsesSearchContextSize),
23
- z.string().and(z.custom()),
24
- ]);
16
+ export const ResponsesSearchContextSize$outboundSchema = openEnums.outboundSchema(ResponsesSearchContextSize);
25
17
  //# sourceMappingURL=responsessearchcontextsize.js.map
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import * as z from "zod/v4";
5
5
  import { safeParse } from "../lib/schemas.js";
6
- import { catchUnrecognizedEnum } from "../types/enums.js";
6
+ import * as openEnums from "../types/enums.js";
7
7
  import { ResponseFormatTextConfig$inboundSchema, } from "./responseformattextconfig.js";
8
8
  export const ResponseTextConfigVerbosity = {
9
9
  High: "high",
@@ -11,11 +11,7 @@ export const ResponseTextConfigVerbosity = {
11
11
  Medium: "medium",
12
12
  };
13
13
  /** @internal */
14
- export const ResponseTextConfigVerbosity$inboundSchema = z
15
- .union([
16
- z.enum(ResponseTextConfigVerbosity),
17
- z.string().transform(catchUnrecognizedEnum),
18
- ]);
14
+ export const ResponseTextConfigVerbosity$inboundSchema = openEnums.inboundSchema(ResponseTextConfigVerbosity);
19
15
  /** @internal */
20
16
  export const ResponseTextConfig$inboundSchema = z.object({
21
17
  format: ResponseFormatTextConfig$inboundSchema.optional(),
@@ -9,5 +9,5 @@ export type ToolCallStatus = OpenEnum<typeof ToolCallStatus>;
9
9
  /** @internal */
10
10
  export declare const ToolCallStatus$inboundSchema: z.ZodType<ToolCallStatus, unknown>;
11
11
  /** @internal */
12
- export declare const ToolCallStatus$outboundSchema: z.ZodType<ToolCallStatus, ToolCallStatus>;
12
+ export declare const ToolCallStatus$outboundSchema: z.ZodType<string, ToolCallStatus>;
13
13
  //# sourceMappingURL=toolcallstatus.d.ts.map
@@ -1,22 +1,14 @@
1
1
  /*
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
3
  */
4
- import * as z from "zod/v4";
5
- import { catchUnrecognizedEnum, } from "../types/enums.js";
4
+ import * as openEnums from "../types/enums.js";
6
5
  export const ToolCallStatus = {
7
6
  InProgress: "in_progress",
8
7
  Completed: "completed",
9
8
  Incomplete: "incomplete",
10
9
  };
11
10
  /** @internal */
12
- export const ToolCallStatus$inboundSchema = z
13
- .union([
14
- z.enum(ToolCallStatus),
15
- z.string().transform(catchUnrecognizedEnum),
16
- ]);
11
+ export const ToolCallStatus$inboundSchema = openEnums.inboundSchema(ToolCallStatus);
17
12
  /** @internal */
18
- export const ToolCallStatus$outboundSchema = z.union([
19
- z.enum(ToolCallStatus),
20
- z.string().and(z.custom()),
21
- ]);
13
+ export const ToolCallStatus$outboundSchema = openEnums.outboundSchema(ToolCallStatus);
22
14
  //# sourceMappingURL=toolcallstatus.js.map
@@ -10,5 +10,5 @@ export type WebSearchStatus = OpenEnum<typeof WebSearchStatus>;
10
10
  /** @internal */
11
11
  export declare const WebSearchStatus$inboundSchema: z.ZodType<WebSearchStatus, unknown>;
12
12
  /** @internal */
13
- export declare const WebSearchStatus$outboundSchema: z.ZodType<WebSearchStatus, WebSearchStatus>;
13
+ export declare const WebSearchStatus$outboundSchema: z.ZodType<string, WebSearchStatus>;
14
14
  //# sourceMappingURL=websearchstatus.d.ts.map
@@ -1,8 +1,7 @@
1
1
  /*
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
3
  */
4
- import * as z from "zod/v4";
5
- import { catchUnrecognizedEnum, } from "../types/enums.js";
4
+ import * as openEnums from "../types/enums.js";
6
5
  export const WebSearchStatus = {
7
6
  Completed: "completed",
8
7
  Searching: "searching",
@@ -10,14 +9,7 @@ export const WebSearchStatus = {
10
9
  Failed: "failed",
11
10
  };
12
11
  /** @internal */
13
- export const WebSearchStatus$inboundSchema = z
14
- .union([
15
- z.enum(WebSearchStatus),
16
- z.string().transform(catchUnrecognizedEnum),
17
- ]);
12
+ export const WebSearchStatus$inboundSchema = openEnums.inboundSchema(WebSearchStatus);
18
13
  /** @internal */
19
- export const WebSearchStatus$outboundSchema = z.union([
20
- z.enum(WebSearchStatus),
21
- z.string().and(z.custom()),
22
- ]);
14
+ export const WebSearchStatus$outboundSchema = openEnums.outboundSchema(WebSearchStatus);
23
15
  //# sourceMappingURL=websearchstatus.js.map
@@ -1,12 +1,16 @@
1
+ import * as z from "zod/v4";
1
2
  declare const __brand: unique symbol;
2
3
  export type Unrecognized<T> = T & {
3
4
  [__brand]: "unrecognized";
4
5
  };
5
- export declare function catchUnrecognizedEnum<T>(value: T): Unrecognized<T>;
6
- type Prettify<T> = {
7
- [K in keyof T]: T[K];
8
- } & {};
9
- export type ClosedEnum<T> = T[keyof T];
10
- export type OpenEnum<T> = Prettify<T[keyof T]> | Unrecognized<T[keyof T] extends number ? number : string>;
6
+ export type ClosedEnum<T extends Readonly<Record<string, string | number>>> = T[keyof T];
7
+ export type OpenEnum<T extends Readonly<Record<string, string | number>>> = T[keyof T] | Unrecognized<T[keyof T] extends number ? number : string>;
8
+ export declare function unrecognizedCounter(): {
9
+ count: () => number;
10
+ };
11
+ export declare function inboundSchema<T extends Record<string, string>>(enumObj: T): z.ZodType<OpenEnum<T>, unknown>;
12
+ export declare function inboundSchemaInt<T extends Record<string, number | string>>(enumObj: T): z.ZodType<OpenEnum<T>, unknown>;
13
+ export declare function outboundSchema<T extends Record<string, string>>(_: T): z.ZodType<string, OpenEnum<T>>;
14
+ export declare function outboundSchemaInt<T extends Record<string, number | string>>(_: T): z.ZodType<number, OpenEnum<T>>;
11
15
  export {};
12
16
  //# sourceMappingURL=enums.d.ts.map
@@ -1,7 +1,44 @@
1
1
  /*
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
3
  */
4
- export function catchUnrecognizedEnum(value) {
4
+ import * as z from "zod/v4";
5
+ function unrecognized(value) {
6
+ unrecognizedCount++;
5
7
  return value;
6
8
  }
9
+ let unrecognizedCount = 0;
10
+ let refCount = 0;
11
+ export function unrecognizedCounter() {
12
+ refCount++;
13
+ const start = unrecognizedCount;
14
+ return {
15
+ count: () => {
16
+ const count = unrecognizedCount - start;
17
+ if (--refCount === 0)
18
+ unrecognizedCount = 0;
19
+ return count;
20
+ },
21
+ };
22
+ }
23
+ export function inboundSchema(enumObj) {
24
+ const options = Object.values(enumObj);
25
+ return z.union([
26
+ ...options.map(x => z.literal(x)),
27
+ z.string().transform(x => unrecognized(x)),
28
+ ]);
29
+ }
30
+ export function inboundSchemaInt(enumObj) {
31
+ // For numeric enums, Object.values returns both numbers and string keys
32
+ const options = Object.values(enumObj).filter(v => typeof v === "number");
33
+ return z.union([
34
+ ...options.map(x => z.literal(x)),
35
+ z.int().transform(x => unrecognized(x)),
36
+ ]);
37
+ }
38
+ export function outboundSchema(_) {
39
+ return z.string();
40
+ }
41
+ export function outboundSchemaInt(_) {
42
+ return z.int();
43
+ }
7
44
  //# sourceMappingURL=enums.js.map
@@ -1,5 +1,4 @@
1
1
  export { blobLikeSchema, isBlobLike } from "./blobs.js";
2
- export { catchUnrecognizedEnum } from "./enums.js";
3
2
  export type { ClosedEnum, OpenEnum, Unrecognized } from "./enums.js";
4
3
  export type { Result } from "./fp.js";
5
4
  export type { PageIterator, Paginator } from "./operations.js";
@@ -2,7 +2,6 @@
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
3
  */
4
4
  export { blobLikeSchema, isBlobLike } from "./blobs.js";
5
- export { catchUnrecognizedEnum } from "./enums.js";
6
5
  export { createPageIterator } from "./operations.js";
7
6
  export { RFCDate } from "./rfcdate.js";
8
7
  //# sourceMappingURL=index.js.map
package/jsr.json CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  {
4
4
  "name": "@openrouter/sdk",
5
- "version": "0.1.10",
5
+ "version": "0.1.13",
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.1.10",
3
+ "version": "0.1.13",
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,13 +0,0 @@
1
- import * as z from "zod/v4";
2
- import { OpenEnum } from "../types/enums.js";
3
- export declare const ChatCompletionFinishReason: {
4
- readonly ToolCalls: "tool_calls";
5
- readonly Stop: "stop";
6
- readonly Length: "length";
7
- readonly ContentFilter: "content_filter";
8
- readonly Error: "error";
9
- };
10
- export type ChatCompletionFinishReason = OpenEnum<typeof ChatCompletionFinishReason>;
11
- /** @internal */
12
- export declare const ChatCompletionFinishReason$inboundSchema: z.ZodType<ChatCompletionFinishReason, unknown>;
13
- //# sourceMappingURL=chatcompletionfinishreason.d.ts.map
@@ -1,19 +0,0 @@
1
- /*
2
- * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
- */
4
- import * as z from "zod/v4";
5
- import { catchUnrecognizedEnum } from "../types/enums.js";
6
- export const ChatCompletionFinishReason = {
7
- ToolCalls: "tool_calls",
8
- Stop: "stop",
9
- Length: "length",
10
- ContentFilter: "content_filter",
11
- Error: "error",
12
- };
13
- /** @internal */
14
- export const ChatCompletionFinishReason$inboundSchema = z
15
- .union([
16
- z.enum(ChatCompletionFinishReason),
17
- z.string().transform(catchUnrecognizedEnum),
18
- ]);
19
- //# sourceMappingURL=chatcompletionfinishreason.js.map
@@ -1,16 +0,0 @@
1
- import * as z from "zod/v4";
2
- import { Result as SafeParseResult } from "../types/fp.js";
3
- import { ChatCompletionFinishReason } from "./chatcompletionfinishreason.js";
4
- import { ChatMessageTokenLogprobs } from "./chatmessagetokenlogprobs.js";
5
- import { ChatStreamingMessageChunk } from "./chatstreamingmessagechunk.js";
6
- import { SDKValidationError } from "./errors/sdkvalidationerror.js";
7
- export type ChatStreamingChoice = {
8
- delta: ChatStreamingMessageChunk;
9
- finishReason: ChatCompletionFinishReason | null;
10
- index: number;
11
- logprobs?: ChatMessageTokenLogprobs | null | undefined;
12
- };
13
- /** @internal */
14
- export declare const ChatStreamingChoice$inboundSchema: z.ZodType<ChatStreamingChoice, unknown>;
15
- export declare function chatStreamingChoiceFromJSON(jsonString: string): SafeParseResult<ChatStreamingChoice, SDKValidationError>;
16
- //# sourceMappingURL=chatstreamingchoice.d.ts.map
@@ -1,24 +0,0 @@
1
- /*
2
- * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
- */
4
- import * as z from "zod/v4";
5
- import { remap as remap$ } from "../lib/primitives.js";
6
- import { safeParse } from "../lib/schemas.js";
7
- import { ChatCompletionFinishReason$inboundSchema, } from "./chatcompletionfinishreason.js";
8
- import { ChatMessageTokenLogprobs$inboundSchema, } from "./chatmessagetokenlogprobs.js";
9
- import { ChatStreamingMessageChunk$inboundSchema, } from "./chatstreamingmessagechunk.js";
10
- /** @internal */
11
- export const ChatStreamingChoice$inboundSchema = z.object({
12
- delta: ChatStreamingMessageChunk$inboundSchema,
13
- finish_reason: z.nullable(ChatCompletionFinishReason$inboundSchema),
14
- index: z.number(),
15
- logprobs: z.nullable(ChatMessageTokenLogprobs$inboundSchema).optional(),
16
- }).transform((v) => {
17
- return remap$(v, {
18
- "finish_reason": "finishReason",
19
- });
20
- });
21
- export function chatStreamingChoiceFromJSON(jsonString) {
22
- return safeParse(jsonString, (x) => ChatStreamingChoice$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ChatStreamingChoice' from JSON`);
23
- }
24
- //# sourceMappingURL=chatstreamingchoice.js.map