@openrouter/sdk 1.2.6 → 1.2.7

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.
@@ -15,5 +15,5 @@ import { Result } from "../types/fp.js";
15
15
  * @remarks
16
16
  * Remove the budget for a given interval. [Management key](/docs/guides/overview/auth/management-api-keys) required.
17
17
  */
18
- export declare function workspacesDeleteBudget(client: OpenRouterCore, request: operations.DeleteWorkspaceBudgetRequest, options?: RequestOptions): APIPromise<Result<models.DeleteWorkspaceBudgetResponse, errors.UnauthorizedResponseError | errors.NotFoundResponseError | errors.InternalServerResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
18
+ export declare function workspacesDeleteBudget(client: OpenRouterCore, request: operations.DeleteWorkspaceBudgetRequest, options?: RequestOptions): APIPromise<Result<models.DeleteWorkspaceBudgetResponse, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.NotFoundResponseError | errors.InternalServerResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
19
19
  //# sourceMappingURL=workspacesDeleteBudget.d.ts.map
@@ -98,7 +98,7 @@ async function $do(client, request, options) {
98
98
  const responseFields = {
99
99
  HttpMeta: { Response: response, Request: req },
100
100
  };
101
- const [result] = await M.match(M.json(200, models.DeleteWorkspaceBudgetResponse$inboundSchema), M.jsonErr(401, errors.UnauthorizedResponseError$inboundSchema), M.jsonErr(404, errors.NotFoundResponseError$inboundSchema), M.jsonErr(500, errors.InternalServerResponseError$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
101
+ const [result] = await M.match(M.json(200, models.DeleteWorkspaceBudgetResponse$inboundSchema), M.jsonErr(400, errors.BadRequestResponseError$inboundSchema), M.jsonErr(401, errors.UnauthorizedResponseError$inboundSchema), M.jsonErr(404, errors.NotFoundResponseError$inboundSchema), M.jsonErr(500, errors.InternalServerResponseError$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
102
102
  if (!result.ok) {
103
103
  return [result, { status: "complete", request: req, response }];
104
104
  }
@@ -0,0 +1,19 @@
1
+ import { OpenRouterCore } from "../core.js";
2
+ import { RequestOptions } from "../lib/sdks.js";
3
+ import { ConnectionError, InvalidRequestError, RequestAbortedError, RequestTimeoutError, UnexpectedClientError } from "../models/errors/httpclienterrors.js";
4
+ import * as errors from "../models/errors/index.js";
5
+ import { OpenRouterError } from "../models/errors/openroutererror.js";
6
+ import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
7
+ import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
8
+ import * as models from "../models/index.js";
9
+ import * as operations from "../models/operations/index.js";
10
+ import { APIPromise } from "../types/async.js";
11
+ import { Result } from "../types/fp.js";
12
+ /**
13
+ * Get a workspace budget
14
+ *
15
+ * @remarks
16
+ * Retrieve the budget for a given interval. [Management key](/docs/guides/overview/auth/management-api-keys) required.
17
+ */
18
+ export declare function workspacesGetBudget(client: OpenRouterCore, request: operations.GetWorkspaceBudgetRequest, options?: RequestOptions): APIPromise<Result<models.GetWorkspaceBudgetResponse, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.NotFoundResponseError | errors.InternalServerResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
19
+ //# sourceMappingURL=workspacesGetBudget.d.ts.map
@@ -0,0 +1,107 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: cdb084566ab1
4
+ */
5
+ import { encodeSimple } from "../lib/encodings.js";
6
+ import { matchStatusCode } from "../lib/http.js";
7
+ import * as M from "../lib/matchers.js";
8
+ import { compactMap } from "../lib/primitives.js";
9
+ import { safeParse } from "../lib/schemas.js";
10
+ import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
11
+ import { pathToFunc } from "../lib/url.js";
12
+ import * as errors from "../models/errors/index.js";
13
+ import * as models from "../models/index.js";
14
+ import * as operations from "../models/operations/index.js";
15
+ import { APIPromise } from "../types/async.js";
16
+ /**
17
+ * Get a workspace budget
18
+ *
19
+ * @remarks
20
+ * Retrieve the budget for a given interval. [Management key](/docs/guides/overview/auth/management-api-keys) required.
21
+ */
22
+ export function workspacesGetBudget(client, request, options) {
23
+ return new APIPromise($do(client, request, options));
24
+ }
25
+ async function $do(client, request, options) {
26
+ const parsed = safeParse(request, (value) => operations.GetWorkspaceBudgetRequest$outboundSchema.parse(value), "Input validation failed");
27
+ if (!parsed.ok) {
28
+ return [parsed, { status: "invalid" }];
29
+ }
30
+ const payload = parsed.value;
31
+ const body = null;
32
+ const pathParams = {
33
+ id: encodeSimple("id", payload.id, {
34
+ explode: false,
35
+ charEncoding: "percent",
36
+ }),
37
+ interval: encodeSimple("interval", payload.interval, {
38
+ explode: false,
39
+ charEncoding: "percent",
40
+ }),
41
+ };
42
+ const path = pathToFunc("/workspaces/{id}/budgets/{interval}")(pathParams);
43
+ const headers = new Headers(compactMap({
44
+ Accept: "application/json",
45
+ "HTTP-Referer": encodeSimple("HTTP-Referer", payload["HTTP-Referer"] ?? client._options.httpReferer, { explode: false, charEncoding: "none" }),
46
+ "X-OpenRouter-Categories": encodeSimple("X-OpenRouter-Categories", payload.appCategories ?? client._options.appCategories, { explode: false, charEncoding: "none" }),
47
+ "X-OpenRouter-Title": encodeSimple("X-OpenRouter-Title", payload.appTitle ?? client._options.appTitle, { explode: false, charEncoding: "none" }),
48
+ }));
49
+ const secConfig = await extractSecurity(client._options.apiKey);
50
+ const securityInput = secConfig == null ? {} : { apiKey: secConfig };
51
+ const requestSecurity = resolveGlobalSecurity(securityInput);
52
+ const context = {
53
+ options: client._options,
54
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
55
+ operationID: "getWorkspaceBudget",
56
+ oAuth2Scopes: null,
57
+ resolvedSecurity: requestSecurity,
58
+ securitySource: client._options.apiKey,
59
+ retryConfig: options?.retries
60
+ || client._options.retryConfig
61
+ || {
62
+ strategy: "backoff",
63
+ backoff: {
64
+ initialInterval: 500,
65
+ maxInterval: 60000,
66
+ exponent: 1.5,
67
+ maxElapsedTime: 3600000,
68
+ },
69
+ retryConnectionErrors: true,
70
+ }
71
+ || { strategy: "none" },
72
+ retryCodes: options?.retryCodes || ["5XX"],
73
+ };
74
+ const requestRes = client._createRequest(context, {
75
+ security: requestSecurity,
76
+ method: "GET",
77
+ baseURL: options?.serverURL,
78
+ path: path,
79
+ headers: headers,
80
+ body: body,
81
+ userAgent: client._options.userAgent,
82
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
83
+ }, options);
84
+ if (!requestRes.ok) {
85
+ return [requestRes, { status: "invalid" }];
86
+ }
87
+ const req = requestRes.value;
88
+ const doResult = await client._do(req, {
89
+ context,
90
+ isErrorStatusCode: (statusCode) => matchStatusCode({ status: statusCode }, ["4XX", "5XX"]),
91
+ retryConfig: context.retryConfig,
92
+ retryCodes: context.retryCodes,
93
+ });
94
+ if (!doResult.ok) {
95
+ return [doResult, { status: "request-error", request: req }];
96
+ }
97
+ const response = doResult.value;
98
+ const responseFields = {
99
+ HttpMeta: { Response: response, Request: req },
100
+ };
101
+ const [result] = await M.match(M.json(200, models.GetWorkspaceBudgetResponse$inboundSchema), M.jsonErr(400, errors.BadRequestResponseError$inboundSchema), M.jsonErr(401, errors.UnauthorizedResponseError$inboundSchema), M.jsonErr(404, errors.NotFoundResponseError$inboundSchema), M.jsonErr(500, errors.InternalServerResponseError$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
102
+ if (!result.ok) {
103
+ return [result, { status: "complete", request: req, response }];
104
+ }
105
+ return [result, { status: "complete", request: req, response }];
106
+ }
107
+ //# sourceMappingURL=workspacesGetBudget.js.map
@@ -49,8 +49,8 @@ export declare function serverURLFromOptions(options: SDKOptions): URL | null;
49
49
  export declare const SDK_METADATA: {
50
50
  readonly language: "typescript";
51
51
  readonly openapiDocVersion: "1.0.0";
52
- readonly sdkVersion: "1.2.6";
52
+ readonly sdkVersion: "1.2.7";
53
53
  readonly genVersion: "2.914.0";
54
- readonly userAgent: "speakeasy-sdk/typescript 1.2.6 2.914.0 1.0.0 @openrouter/sdk";
54
+ readonly userAgent: "speakeasy-sdk/typescript 1.2.7 2.914.0 1.0.0 @openrouter/sdk";
55
55
  };
56
56
  //# sourceMappingURL=config.d.ts.map
package/esm/lib/config.js CHANGED
@@ -26,8 +26,8 @@ export function serverURLFromOptions(options) {
26
26
  export const SDK_METADATA = {
27
27
  language: "typescript",
28
28
  openapiDocVersion: "1.0.0",
29
- sdkVersion: "1.2.6",
29
+ sdkVersion: "1.2.7",
30
30
  genVersion: "2.914.0",
31
- userAgent: "speakeasy-sdk/typescript 1.2.6 2.914.0 1.0.0 @openrouter/sdk",
31
+ userAgent: "speakeasy-sdk/typescript 1.2.7 2.914.0 1.0.0 @openrouter/sdk",
32
32
  };
33
33
  //# sourceMappingURL=config.js.map
@@ -0,0 +1,15 @@
1
+ import * as z from "zod/v4";
2
+ import { Result as SafeParseResult } from "../types/fp.js";
3
+ import { SDKValidationError } from "./errors/sdkvalidationerror.js";
4
+ import { WorkspaceBudget } from "./workspacebudget.js";
5
+ export type GetWorkspaceBudgetResponse = {
6
+ data: WorkspaceBudget;
7
+ /**
8
+ * Whether BYOK (bring-your-own-key) spend is included when enforcing the workspace's budgets. This is a workspace-wide setting that applies to all budget intervals (daily, weekly, monthly, and lifetime).
9
+ */
10
+ includeByokInBudgets?: boolean | undefined;
11
+ };
12
+ /** @internal */
13
+ export declare const GetWorkspaceBudgetResponse$inboundSchema: z.ZodType<GetWorkspaceBudgetResponse, unknown>;
14
+ export declare function getWorkspaceBudgetResponseFromJSON(jsonString: string): SafeParseResult<GetWorkspaceBudgetResponse, SDKValidationError>;
15
+ //# sourceMappingURL=getworkspacebudgetresponse.d.ts.map
@@ -0,0 +1,21 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: ccd40e25fb1b
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 { WorkspaceBudget$inboundSchema, } from "./workspacebudget.js";
9
+ /** @internal */
10
+ export const GetWorkspaceBudgetResponse$inboundSchema = z.object({
11
+ data: WorkspaceBudget$inboundSchema,
12
+ include_byok_in_budgets: z.boolean().optional(),
13
+ }).transform((v) => {
14
+ return remap$(v, {
15
+ "include_byok_in_budgets": "includeByokInBudgets",
16
+ });
17
+ });
18
+ export function getWorkspaceBudgetResponseFromJSON(jsonString) {
19
+ return safeParse(jsonString, (x) => GetWorkspaceBudgetResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetWorkspaceBudgetResponse' from JSON`);
20
+ }
21
+ //# sourceMappingURL=getworkspacebudgetresponse.js.map
@@ -237,6 +237,7 @@ export * from "./getobservabilitydestinationresponse.js";
237
237
  export * from "./getpresetresponse.js";
238
238
  export * from "./getpresetversionresponse.js";
239
239
  export * from "./getscimgroupmappingresponse.js";
240
+ export * from "./getworkspacebudgetresponse.js";
240
241
  export * from "./getworkspaceresponse.js";
241
242
  export * from "./guardrail.js";
242
243
  export * from "./guardrailinterval.js";
@@ -241,6 +241,7 @@ export * from "./getobservabilitydestinationresponse.js";
241
241
  export * from "./getpresetresponse.js";
242
242
  export * from "./getpresetversionresponse.js";
243
243
  export * from "./getscimgroupmappingresponse.js";
244
+ export * from "./getworkspacebudgetresponse.js";
244
245
  export * from "./getworkspaceresponse.js";
245
246
  export * from "./guardrail.js";
246
247
  export * from "./guardrailinterval.js";
@@ -0,0 +1,64 @@
1
+ import * as z from "zod/v4";
2
+ import * as models from "../index.js";
3
+ export type GetWorkspaceBudgetGlobals = {
4
+ /**
5
+ * The app identifier should be your app's URL and is used as the primary identifier for rankings.
6
+ *
7
+ * @remarks
8
+ * This is used to track API usage per application.
9
+ */
10
+ httpReferer?: string | undefined;
11
+ /**
12
+ * The app display name allows you to customize how your app appears in OpenRouter's dashboard.
13
+ *
14
+ * @remarks
15
+ */
16
+ appTitle?: string | undefined;
17
+ /**
18
+ * Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
19
+ *
20
+ * @remarks
21
+ */
22
+ appCategories?: string | undefined;
23
+ };
24
+ export type GetWorkspaceBudgetRequest = {
25
+ /**
26
+ * The app identifier should be your app's URL and is used as the primary identifier for rankings.
27
+ *
28
+ * @remarks
29
+ * This is used to track API usage per application.
30
+ */
31
+ httpReferer?: string | undefined;
32
+ /**
33
+ * The app display name allows you to customize how your app appears in OpenRouter's dashboard.
34
+ *
35
+ * @remarks
36
+ */
37
+ appTitle?: string | undefined;
38
+ /**
39
+ * Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
40
+ *
41
+ * @remarks
42
+ */
43
+ appCategories?: string | undefined;
44
+ /**
45
+ * The workspace ID (UUID) or slug
46
+ */
47
+ id: string;
48
+ /**
49
+ * Budget reset interval. Use "lifetime" for a one-time budget that never resets.
50
+ */
51
+ interval: models.WorkspaceBudgetInterval;
52
+ };
53
+ /** @internal */
54
+ export type GetWorkspaceBudgetRequest$Outbound = {
55
+ "HTTP-Referer"?: string | undefined;
56
+ appTitle?: string | undefined;
57
+ appCategories?: string | undefined;
58
+ id: string;
59
+ interval: string;
60
+ };
61
+ /** @internal */
62
+ export declare const GetWorkspaceBudgetRequest$outboundSchema: z.ZodType<GetWorkspaceBudgetRequest$Outbound, GetWorkspaceBudgetRequest>;
63
+ export declare function getWorkspaceBudgetRequestToJSON(getWorkspaceBudgetRequest: GetWorkspaceBudgetRequest): string;
64
+ //# sourceMappingURL=getworkspacebudget.d.ts.map
@@ -0,0 +1,23 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: 0979c0e7d04e
4
+ */
5
+ import * as z from "zod/v4";
6
+ import { remap as remap$ } from "../../lib/primitives.js";
7
+ import * as models from "../index.js";
8
+ /** @internal */
9
+ export const GetWorkspaceBudgetRequest$outboundSchema = z.object({
10
+ httpReferer: z.string().optional(),
11
+ appTitle: z.string().optional(),
12
+ appCategories: z.string().optional(),
13
+ id: z.string(),
14
+ interval: models.WorkspaceBudgetInterval$outboundSchema,
15
+ }).transform((v) => {
16
+ return remap$(v, {
17
+ httpReferer: "HTTP-Referer",
18
+ });
19
+ });
20
+ export function getWorkspaceBudgetRequestToJSON(getWorkspaceBudgetRequest) {
21
+ return JSON.stringify(GetWorkspaceBudgetRequest$outboundSchema.parse(getWorkspaceBudgetRequest));
22
+ }
23
+ //# sourceMappingURL=getworkspacebudget.js.map
@@ -53,6 +53,7 @@ export * from "./gettaskclassifications.js";
53
53
  export * from "./getuseractivity.js";
54
54
  export * from "./getvideos.js";
55
55
  export * from "./getworkspace.js";
56
+ export * from "./getworkspacebudget.js";
56
57
  export * from "./list.js";
57
58
  export * from "./listbyokkeys.js";
58
59
  export * from "./listembeddingsmodels.js";
@@ -57,6 +57,7 @@ export * from "./gettaskclassifications.js";
57
57
  export * from "./getuseractivity.js";
58
58
  export * from "./getvideos.js";
59
59
  export * from "./getworkspace.js";
60
+ export * from "./getworkspacebudget.js";
60
61
  export * from "./list.js";
61
62
  export * from "./listbyokkeys.js";
62
63
  export * from "./listembeddingsmodels.js";
@@ -54,6 +54,13 @@ export declare class Workspaces extends ClientSDK {
54
54
  * Remove the budget for a given interval. [Management key](/docs/guides/overview/auth/management-api-keys) required.
55
55
  */
56
56
  deleteBudget(request: operations.DeleteWorkspaceBudgetRequest, options?: RequestOptions): Promise<models.DeleteWorkspaceBudgetResponse>;
57
+ /**
58
+ * Get a workspace budget
59
+ *
60
+ * @remarks
61
+ * Retrieve the budget for a given interval. [Management key](/docs/guides/overview/auth/management-api-keys) required.
62
+ */
63
+ getBudget(request: operations.GetWorkspaceBudgetRequest, options?: RequestOptions): Promise<models.GetWorkspaceBudgetResponse>;
57
64
  /**
58
65
  * Create or update a workspace budget
59
66
  *
@@ -8,6 +8,7 @@ import { workspacesCreate } from "../funcs/workspacesCreate.js";
8
8
  import { workspacesDelete } from "../funcs/workspacesDelete.js";
9
9
  import { workspacesDeleteBudget } from "../funcs/workspacesDeleteBudget.js";
10
10
  import { workspacesGet } from "../funcs/workspacesGet.js";
11
+ import { workspacesGetBudget } from "../funcs/workspacesGetBudget.js";
11
12
  import { workspacesList } from "../funcs/workspacesList.js";
12
13
  import { workspacesListBudgets } from "../funcs/workspacesListBudgets.js";
13
14
  import { workspacesListMembers } from "../funcs/workspacesListMembers.js";
@@ -80,6 +81,15 @@ export class Workspaces extends ClientSDK {
80
81
  async deleteBudget(request, options) {
81
82
  return unwrapAsync(workspacesDeleteBudget(this, request, options));
82
83
  }
84
+ /**
85
+ * Get a workspace budget
86
+ *
87
+ * @remarks
88
+ * Retrieve the budget for a given interval. [Management key](/docs/guides/overview/auth/management-api-keys) required.
89
+ */
90
+ async getBudget(request, options) {
91
+ return unwrapAsync(workspacesGetBudget(this, request, options));
92
+ }
83
93
  /**
84
94
  * Create or update a workspace budget
85
95
  *
package/jsr.json CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  {
4
4
  "name": "@openrouter/sdk",
5
- "version": "1.2.6",
5
+ "version": "1.2.7",
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.2.6",
3
+ "version": "1.2.7",
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": [
@@ -75,13 +75,13 @@
75
75
  "prepublishOnly": "npm run build",
76
76
  "compile": "tsc",
77
77
  "postinstall": "node scripts/check-types.js || true",
78
- "test:e2e": "vitest --run --project e2e",
78
+ "test": "vitest --run --project unit",
79
79
  "test:watch": "vitest --watch --project unit",
80
- "typecheck": "tsc --noEmit",
80
+ "typecheck:transit": "exit 0",
81
81
  "prepare": "npm run build",
82
- "test": "vitest --run --project unit",
82
+ "test:e2e": "vitest --run --project e2e",
83
83
  "test:transit": "exit 0",
84
- "typecheck:transit": "exit 0"
84
+ "typecheck": "tsc --noEmit"
85
85
  },
86
86
  "peerDependencies": {},
87
87
  "devDependencies": {