@openrouter/sdk 1.4.6 → 1.4.8

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 (47) hide show
  1. package/esm/funcs/toolsGetTool.d.ts +18 -0
  2. package/esm/funcs/toolsGetTool.js +110 -0
  3. package/esm/funcs/toolsListTools.d.ts +19 -0
  4. package/esm/funcs/toolsListTools.js +107 -0
  5. package/esm/lib/config.d.ts +2 -2
  6. package/esm/lib/config.js +2 -2
  7. package/esm/models/generationresponse.d.ts +4 -4
  8. package/esm/models/generationresponse.js +3 -3
  9. package/esm/models/gettoolresponse.d.ts +11 -0
  10. package/esm/models/gettoolresponse.js +15 -0
  11. package/esm/models/index.d.ts +11 -0
  12. package/esm/models/index.js +11 -0
  13. package/esm/models/listtoolsresponse.d.ts +25 -0
  14. package/esm/models/listtoolsresponse.js +29 -0
  15. package/esm/models/modelslistresponse.d.ts +4 -4
  16. package/esm/models/modelslistresponse.js +4 -4
  17. package/esm/models/operations/gettool.d.ts +80 -0
  18. package/esm/models/operations/gettool.js +43 -0
  19. package/esm/models/operations/index.d.ts +2 -0
  20. package/esm/models/operations/index.js +2 -0
  21. package/esm/models/operations/listtools.d.ts +93 -0
  22. package/esm/models/operations/listtools.js +43 -0
  23. package/esm/models/servertool.d.ts +79 -0
  24. package/esm/models/servertool.js +59 -0
  25. package/esm/models/servertooldetails.d.ts +90 -0
  26. package/esm/models/servertooldetails.js +73 -0
  27. package/esm/models/servertoolengine.d.ts +82 -0
  28. package/esm/models/servertoolengine.js +63 -0
  29. package/esm/models/servertoolexecutedby.d.ts +17 -0
  30. package/esm/models/servertoolexecutedby.js +16 -0
  31. package/esm/models/servertoolinputname.d.ts +28 -0
  32. package/esm/models/servertoolinputname.js +31 -0
  33. package/esm/models/servertoolnativemodel.d.ts +11 -0
  34. package/esm/models/servertoolnativemodel.js +15 -0
  35. package/esm/models/servertoolnativesupport.d.ts +14 -0
  36. package/esm/models/servertoolnativesupport.js +21 -0
  37. package/esm/models/servertooloutputname.d.ts +27 -0
  38. package/esm/models/servertooloutputname.js +29 -0
  39. package/esm/models/servertoolprice.d.ts +19 -0
  40. package/esm/models/servertoolprice.js +22 -0
  41. package/esm/models/speechrequest.d.ts +1 -1
  42. package/esm/sdk/sdk.d.ts +3 -0
  43. package/esm/sdk/sdk.js +4 -0
  44. package/esm/sdk/tools.d.ts +20 -0
  45. package/esm/sdk/tools.js +29 -0
  46. package/jsr.json +1 -1
  47. package/package.json +7 -7
@@ -0,0 +1,17 @@
1
+ import * as z from "zod/v4";
2
+ import { OpenEnum } from "../types/enums.js";
3
+ /**
4
+ * Who runs the tool call: the model provider during inference (`provider`), OpenRouter (`openrouter`), or the caller's application after the call is returned (`client`).
5
+ */
6
+ export declare const ServerToolExecutedBy: {
7
+ readonly Provider: "provider";
8
+ readonly Openrouter: "openrouter";
9
+ readonly Client: "client";
10
+ };
11
+ /**
12
+ * Who runs the tool call: the model provider during inference (`provider`), OpenRouter (`openrouter`), or the caller's application after the call is returned (`client`).
13
+ */
14
+ export type ServerToolExecutedBy = OpenEnum<typeof ServerToolExecutedBy>;
15
+ /** @internal */
16
+ export declare const ServerToolExecutedBy$inboundSchema: z.ZodType<ServerToolExecutedBy, unknown>;
17
+ //# sourceMappingURL=servertoolexecutedby.d.ts.map
@@ -0,0 +1,16 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: cfa354bfe40d
4
+ */
5
+ import * as openEnums from "../types/enums.js";
6
+ /**
7
+ * Who runs the tool call: the model provider during inference (`provider`), OpenRouter (`openrouter`), or the caller's application after the call is returned (`client`).
8
+ */
9
+ export const ServerToolExecutedBy = {
10
+ Provider: "provider",
11
+ Openrouter: "openrouter",
12
+ Client: "client",
13
+ };
14
+ /** @internal */
15
+ export const ServerToolExecutedBy$inboundSchema = openEnums.inboundSchema(ServerToolExecutedBy);
16
+ //# sourceMappingURL=servertoolexecutedby.js.map
@@ -0,0 +1,28 @@
1
+ import * as z from "zod/v4";
2
+ import { OpenEnum } from "../types/enums.js";
3
+ import { Result as SafeParseResult } from "../types/fp.js";
4
+ import { SDKValidationError } from "./errors/sdkvalidationerror.js";
5
+ import { ServerToolOutputName } from "./servertooloutputname.js";
6
+ export declare const ServerToolInputNameApiFormat: {
7
+ readonly Responses: "responses";
8
+ readonly ChatCompletions: "chat-completions";
9
+ readonly AnthropicMessages: "anthropic-messages";
10
+ };
11
+ export type ServerToolInputNameApiFormat = OpenEnum<typeof ServerToolInputNameApiFormat>;
12
+ export type ServerToolInputName = {
13
+ /**
14
+ * API formats that accept this spelling in `tools[].type`
15
+ */
16
+ apiFormats: Array<ServerToolInputNameApiFormat>;
17
+ /**
18
+ * What the call surfaces as on each accepting API format when requested under this spelling; a format is absent when the call is not visible to the caller
19
+ */
20
+ outputNames: Array<ServerToolOutputName>;
21
+ type: string;
22
+ };
23
+ /** @internal */
24
+ export declare const ServerToolInputNameApiFormat$inboundSchema: z.ZodType<ServerToolInputNameApiFormat, unknown>;
25
+ /** @internal */
26
+ export declare const ServerToolInputName$inboundSchema: z.ZodType<ServerToolInputName, unknown>;
27
+ export declare function serverToolInputNameFromJSON(jsonString: string): SafeParseResult<ServerToolInputName, SDKValidationError>;
28
+ //# sourceMappingURL=servertoolinputname.d.ts.map
@@ -0,0 +1,31 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: deeca5c74395
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
+ import * as openEnums from "../types/enums.js";
9
+ import { ServerToolOutputName$inboundSchema, } from "./servertooloutputname.js";
10
+ export const ServerToolInputNameApiFormat = {
11
+ Responses: "responses",
12
+ ChatCompletions: "chat-completions",
13
+ AnthropicMessages: "anthropic-messages",
14
+ };
15
+ /** @internal */
16
+ export const ServerToolInputNameApiFormat$inboundSchema = openEnums.inboundSchema(ServerToolInputNameApiFormat);
17
+ /** @internal */
18
+ export const ServerToolInputName$inboundSchema = z.object({
19
+ api_formats: z.array(ServerToolInputNameApiFormat$inboundSchema),
20
+ output_names: z.array(ServerToolOutputName$inboundSchema),
21
+ type: z.string(),
22
+ }).transform((v) => {
23
+ return remap$(v, {
24
+ "api_formats": "apiFormats",
25
+ "output_names": "outputNames",
26
+ });
27
+ });
28
+ export function serverToolInputNameFromJSON(jsonString) {
29
+ return safeParse(jsonString, (x) => ServerToolInputName$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ServerToolInputName' from JSON`);
30
+ }
31
+ //# sourceMappingURL=servertoolinputname.js.map
@@ -0,0 +1,11 @@
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 ServerToolNativeModel = {
5
+ providers: Array<string>;
6
+ slug: string;
7
+ };
8
+ /** @internal */
9
+ export declare const ServerToolNativeModel$inboundSchema: z.ZodType<ServerToolNativeModel, unknown>;
10
+ export declare function serverToolNativeModelFromJSON(jsonString: string): SafeParseResult<ServerToolNativeModel, SDKValidationError>;
11
+ //# sourceMappingURL=servertoolnativemodel.d.ts.map
@@ -0,0 +1,15 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: 80f9cb866c58
4
+ */
5
+ import * as z from "zod/v4";
6
+ import { safeParse } from "../lib/schemas.js";
7
+ /** @internal */
8
+ export const ServerToolNativeModel$inboundSchema = z.object({
9
+ providers: z.array(z.string()),
10
+ slug: z.string(),
11
+ });
12
+ export function serverToolNativeModelFromJSON(jsonString) {
13
+ return safeParse(jsonString, (x) => ServerToolNativeModel$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ServerToolNativeModel' from JSON`);
14
+ }
15
+ //# sourceMappingURL=servertoolnativemodel.js.map
@@ -0,0 +1,14 @@
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
+ * Endpoints whose provider runs this tool itself during inference. Zero for tools no provider runs natively.
6
+ */
7
+ export type ServerToolNativeSupport = {
8
+ endpointCount: number;
9
+ modelCount: number;
10
+ };
11
+ /** @internal */
12
+ export declare const ServerToolNativeSupport$inboundSchema: z.ZodType<ServerToolNativeSupport, unknown>;
13
+ export declare function serverToolNativeSupportFromJSON(jsonString: string): SafeParseResult<ServerToolNativeSupport, SDKValidationError>;
14
+ //# sourceMappingURL=servertoolnativesupport.d.ts.map
@@ -0,0 +1,21 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: 3a84d88babcc
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
+ /** @internal */
9
+ export const ServerToolNativeSupport$inboundSchema = z.object({
10
+ endpoint_count: z.int(),
11
+ model_count: z.int(),
12
+ }).transform((v) => {
13
+ return remap$(v, {
14
+ "endpoint_count": "endpointCount",
15
+ "model_count": "modelCount",
16
+ });
17
+ });
18
+ export function serverToolNativeSupportFromJSON(jsonString) {
19
+ return safeParse(jsonString, (x) => ServerToolNativeSupport$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ServerToolNativeSupport' from JSON`);
20
+ }
21
+ //# sourceMappingURL=servertoolnativesupport.js.map
@@ -0,0 +1,27 @@
1
+ import * as z from "zod/v4";
2
+ import { OpenEnum } from "../types/enums.js";
3
+ import { Result as SafeParseResult } from "../types/fp.js";
4
+ import { SDKValidationError } from "./errors/sdkvalidationerror.js";
5
+ export declare const ServerToolOutputNameApiFormat: {
6
+ readonly Responses: "responses";
7
+ readonly ChatCompletions: "chat-completions";
8
+ readonly AnthropicMessages: "anthropic-messages";
9
+ };
10
+ export type ServerToolOutputNameApiFormat = OpenEnum<typeof ServerToolOutputNameApiFormat>;
11
+ export type ServerToolOutputName = {
12
+ apiFormat: ServerToolOutputNameApiFormat;
13
+ /**
14
+ * Anthropic Messages `server_tool_use` block `name`, when the call surfaces as one
15
+ */
16
+ name?: string | undefined;
17
+ /**
18
+ * Output item `type` on Responses, content block `type` on Anthropic Messages, `reasoning_details[].type` on Chat Completions
19
+ */
20
+ type: string;
21
+ };
22
+ /** @internal */
23
+ export declare const ServerToolOutputNameApiFormat$inboundSchema: z.ZodType<ServerToolOutputNameApiFormat, unknown>;
24
+ /** @internal */
25
+ export declare const ServerToolOutputName$inboundSchema: z.ZodType<ServerToolOutputName, unknown>;
26
+ export declare function serverToolOutputNameFromJSON(jsonString: string): SafeParseResult<ServerToolOutputName, SDKValidationError>;
27
+ //# sourceMappingURL=servertooloutputname.d.ts.map
@@ -0,0 +1,29 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: 1dd915c55b83
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
+ import * as openEnums from "../types/enums.js";
9
+ export const ServerToolOutputNameApiFormat = {
10
+ Responses: "responses",
11
+ ChatCompletions: "chat-completions",
12
+ AnthropicMessages: "anthropic-messages",
13
+ };
14
+ /** @internal */
15
+ export const ServerToolOutputNameApiFormat$inboundSchema = openEnums.inboundSchema(ServerToolOutputNameApiFormat);
16
+ /** @internal */
17
+ export const ServerToolOutputName$inboundSchema = z.object({
18
+ api_format: ServerToolOutputNameApiFormat$inboundSchema,
19
+ name: z.string().optional(),
20
+ type: z.string(),
21
+ }).transform((v) => {
22
+ return remap$(v, {
23
+ "api_format": "apiFormat",
24
+ });
25
+ });
26
+ export function serverToolOutputNameFromJSON(jsonString) {
27
+ return safeParse(jsonString, (x) => ServerToolOutputName$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ServerToolOutputName' from JSON`);
28
+ }
29
+ //# sourceMappingURL=servertooloutputname.js.map
@@ -0,0 +1,19 @@
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 ServerToolPrice = {
5
+ maxUnitsPerCall: number;
6
+ /**
7
+ * The `parameters.mode` this price applies to; null for prices that do not depend on the mode. A request bills exactly one `request` row
8
+ */
9
+ mode: string | null;
10
+ /**
11
+ * USD per unit, as a decimal string
12
+ */
13
+ price: string;
14
+ unit: string;
15
+ };
16
+ /** @internal */
17
+ export declare const ServerToolPrice$inboundSchema: z.ZodType<ServerToolPrice, unknown>;
18
+ export declare function serverToolPriceFromJSON(jsonString: string): SafeParseResult<ServerToolPrice, SDKValidationError>;
19
+ //# sourceMappingURL=servertoolprice.d.ts.map
@@ -0,0 +1,22 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: d12fcc3fb6f8
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
+ /** @internal */
9
+ export const ServerToolPrice$inboundSchema = z.object({
10
+ max_units_per_call: z.int(),
11
+ mode: z.nullable(z.string()),
12
+ price: z.string(),
13
+ unit: z.string(),
14
+ }).transform((v) => {
15
+ return remap$(v, {
16
+ "max_units_per_call": "maxUnitsPerCall",
17
+ });
18
+ });
19
+ export function serverToolPriceFromJSON(jsonString) {
20
+ return safeParse(jsonString, (x) => ServerToolPrice$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ServerToolPrice' from JSON`);
21
+ }
22
+ //# sourceMappingURL=servertoolprice.js.map
@@ -52,7 +52,7 @@ export type SpeechRequest = {
52
52
  */
53
53
  sessionId?: string | undefined;
54
54
  /**
55
- * Playback speed multiplier. Only used by models that support it (e.g. OpenAI TTS). Ignored by other providers.
55
+ * Playback speed multiplier. Honored by models that support it (e.g. OpenAI TTS). Other providers either ignore it or return a 400 for a non-default value when the model has no speed control.
56
56
  */
57
57
  speed?: number | undefined;
58
58
  /**
package/esm/sdk/sdk.d.ts CHANGED
@@ -30,6 +30,7 @@ import { Responses } from "./responses.js";
30
30
  import { Scim } from "./scim.js";
31
31
  import { STT } from "./stt.js";
32
32
  import { SystemOne } from "./systemone.js";
33
+ import { Tools } from "./tools.js";
33
34
  import { TTS } from "./tts.js";
34
35
  import { Vault } from "./vault.js";
35
36
  import { VideoGeneration } from "./videogeneration.js";
@@ -105,6 +106,8 @@ export declare class OpenRouter extends ClientSDK {
105
106
  get scim(): Scim;
106
107
  private _systemOne?;
107
108
  get systemOne(): SystemOne;
109
+ private _tools?;
110
+ get tools(): Tools;
108
111
  private _vault?;
109
112
  get vault(): Vault;
110
113
  private _videoGeneration?;
package/esm/sdk/sdk.js CHANGED
@@ -34,6 +34,7 @@ import { Responses } from "./responses.js";
34
34
  import { Scim } from "./scim.js";
35
35
  import { STT } from "./stt.js";
36
36
  import { SystemOne } from "./systemone.js";
37
+ import { Tools } from "./tools.js";
37
38
  import { TTS } from "./tts.js";
38
39
  import { Vault } from "./vault.js";
39
40
  import { VideoGeneration } from "./videogeneration.js";
@@ -139,6 +140,9 @@ export class OpenRouter extends ClientSDK {
139
140
  get systemOne() {
140
141
  return (this._systemOne ?? (this._systemOne = new SystemOne(this._options)));
141
142
  }
143
+ get tools() {
144
+ return (this._tools ?? (this._tools = new Tools(this._options)));
145
+ }
142
146
  get vault() {
143
147
  return (this._vault ?? (this._vault = new Vault(this._options)));
144
148
  }
@@ -0,0 +1,20 @@
1
+ import { ClientSDK, RequestOptions } from "../lib/sdks.js";
2
+ import * as models from "../models/index.js";
3
+ import * as operations from "../models/operations/index.js";
4
+ export declare class Tools extends ClientSDK {
5
+ /**
6
+ * List server tools
7
+ *
8
+ * @remarks
9
+ * Lists every server tool OpenRouter can run on behalf of a model: accepted `tools[].type` spellings per API format, the engines behind it with their pricing, and how many endpoints run it natively.
10
+ */
11
+ listTools(security: operations.ListToolsSecurity, request?: operations.ListToolsRequest | undefined, options?: RequestOptions): Promise<models.ListToolsResponse>;
12
+ /**
13
+ * Get a server tool
14
+ *
15
+ * @remarks
16
+ * One server tool by canonical name or any accepted alias, with the models that run it natively.
17
+ */
18
+ getTool(security: operations.GetToolSecurity, request: operations.GetToolRequest, options?: RequestOptions): Promise<operations.GetToolResponse | undefined>;
19
+ }
20
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1,29 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: f997ccdd9dd9
4
+ */
5
+ import { toolsGetTool } from "../funcs/toolsGetTool.js";
6
+ import { toolsListTools } from "../funcs/toolsListTools.js";
7
+ import { ClientSDK } from "../lib/sdks.js";
8
+ import { unwrapAsync } from "../types/fp.js";
9
+ export class Tools extends ClientSDK {
10
+ /**
11
+ * List server tools
12
+ *
13
+ * @remarks
14
+ * Lists every server tool OpenRouter can run on behalf of a model: accepted `tools[].type` spellings per API format, the engines behind it with their pricing, and how many endpoints run it natively.
15
+ */
16
+ async listTools(security, request, options) {
17
+ return unwrapAsync(toolsListTools(this, security, request, options));
18
+ }
19
+ /**
20
+ * Get a server tool
21
+ *
22
+ * @remarks
23
+ * One server tool by canonical name or any accepted alias, with the models that run it natively.
24
+ */
25
+ async getTool(security, request, options) {
26
+ return unwrapAsync(toolsGetTool(this, security, request, options));
27
+ }
28
+ }
29
+ //# sourceMappingURL=tools.js.map
package/jsr.json CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  {
4
4
  "name": "@openrouter/sdk",
5
- "version": "1.4.6",
5
+ "version": "1.4.8",
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.4.6",
3
+ "version": "1.4.8",
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
- "typecheck": "tsc --noEmit",
77
- "compile": "tsc && node scripts/unbarrel-imports.js",
78
- "postinstall": "node scripts/check-types.js || true",
79
- "prepare": "npm run build",
80
76
  "test": "vitest --run --project unit",
77
+ "test:e2e": "vitest --run --project e2e",
81
78
  "test:watch": "vitest --watch --project unit",
82
79
  "typecheck:transit": "exit 0",
83
- "test:e2e": "vitest --run --project e2e",
84
- "test:transit": "exit 0"
80
+ "postinstall": "node scripts/check-types.js || true",
81
+ "test:transit": "exit 0",
82
+ "typecheck": "tsc --noEmit",
83
+ "compile": "tsc && node scripts/unbarrel-imports.js",
84
+ "prepare": "npm run build"
85
85
  },
86
86
  "peerDependencies": {
87
87