@openrouter/sdk 0.12.15 → 0.12.17

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/funcs/apiKeysCreate.d.ts +1 -1
  2. package/esm/funcs/apiKeysCreate.js +2 -2
  3. package/esm/funcs/generationsGetGeneration.d.ts +2 -1
  4. package/esm/funcs/generationsGetGeneration.js +2 -1
  5. package/esm/funcs/generationsListGenerationContent.d.ts +16 -0
  6. package/esm/funcs/generationsListGenerationContent.js +108 -0
  7. package/esm/funcs/guardrailsCreate.d.ts +1 -1
  8. package/esm/funcs/guardrailsCreate.js +2 -2
  9. package/esm/funcs/guardrailsList.js +1 -0
  10. package/esm/funcs/ttsCreateSpeech.d.ts +18 -0
  11. package/esm/funcs/ttsCreateSpeech.js +110 -0
  12. package/esm/funcs/workspacesBulkAddMembers.d.ts +19 -0
  13. package/esm/funcs/workspacesBulkAddMembers.js +105 -0
  14. package/esm/funcs/workspacesBulkRemoveMembers.d.ts +19 -0
  15. package/esm/funcs/workspacesBulkRemoveMembers.js +105 -0
  16. package/esm/funcs/workspacesCreate.d.ts +19 -0
  17. package/esm/funcs/workspacesCreate.js +99 -0
  18. package/esm/funcs/workspacesDelete.d.ts +19 -0
  19. package/esm/funcs/workspacesDelete.js +102 -0
  20. package/esm/funcs/workspacesGet.d.ts +19 -0
  21. package/esm/funcs/workspacesGet.js +102 -0
  22. package/esm/funcs/workspacesList.d.ts +21 -0
  23. package/esm/funcs/workspacesList.js +133 -0
  24. package/esm/funcs/workspacesUpdate.d.ts +19 -0
  25. package/esm/funcs/workspacesUpdate.js +105 -0
  26. package/esm/lib/config.d.ts +2 -2
  27. package/esm/lib/config.js +2 -2
  28. package/esm/models/bulkaddworkspacemembersrequest.d.ts +15 -0
  29. package/esm/models/bulkaddworkspacemembersrequest.js +18 -0
  30. package/esm/models/bulkaddworkspacemembersresponse.d.ts +18 -0
  31. package/esm/models/bulkaddworkspacemembersresponse.js +21 -0
  32. package/esm/models/bulkremoveworkspacemembersrequest.d.ts +15 -0
  33. package/esm/models/bulkremoveworkspacemembersrequest.js +18 -0
  34. package/esm/models/bulkremoveworkspacemembersresponse.d.ts +13 -0
  35. package/esm/models/bulkremoveworkspacemembersresponse.js +19 -0
  36. package/esm/models/createguardrailrequest.d.ts +5 -0
  37. package/esm/models/createguardrailrequest.js +2 -0
  38. package/esm/models/createworkspacerequest.d.ts +55 -0
  39. package/esm/models/createworkspacerequest.js +31 -0
  40. package/esm/models/createworkspaceresponse.d.ts +11 -0
  41. package/esm/models/createworkspaceresponse.js +15 -0
  42. package/esm/models/deleteworkspaceresponse.d.ts +13 -0
  43. package/esm/models/deleteworkspaceresponse.js +14 -0
  44. package/esm/models/generationcontentdata.d.ts +55 -0
  45. package/esm/models/generationcontentdata.js +45 -0
  46. package/esm/models/generationcontentresponse.d.ts +17 -0
  47. package/esm/models/generationcontentresponse.js +15 -0
  48. package/esm/models/generationresponse.d.ts +198 -0
  49. package/esm/models/generationresponse.js +109 -0
  50. package/esm/models/getworkspaceresponse.d.ts +11 -0
  51. package/esm/models/getworkspaceresponse.js +15 -0
  52. package/esm/models/guardrail.d.ts +4 -0
  53. package/esm/models/guardrail.js +2 -0
  54. package/esm/models/index.d.ts +16 -0
  55. package/esm/models/index.js +16 -0
  56. package/esm/models/listworkspacesresponse.d.ts +18 -0
  57. package/esm/models/listworkspacesresponse.js +21 -0
  58. package/esm/models/modelscountresponse.d.ts +4 -4
  59. package/esm/models/modelscountresponse.js +4 -4
  60. package/esm/models/operations/bulkaddworkspacemembers.d.ts +61 -0
  61. package/esm/models/operations/bulkaddworkspacemembers.js +24 -0
  62. package/esm/models/operations/bulkremoveworkspacemembers.d.ts +61 -0
  63. package/esm/models/operations/bulkremoveworkspacemembers.js +24 -0
  64. package/esm/models/operations/createkeys.d.ts +5 -0
  65. package/esm/models/operations/createkeys.js +2 -0
  66. package/esm/models/operations/createtts.d.ts +779 -0
  67. package/esm/models/operations/createtts.js +193 -0
  68. package/esm/models/operations/createworkspace.d.ts +56 -0
  69. package/esm/models/operations/createworkspace.js +23 -0
  70. package/esm/models/operations/deleteworkspace.d.ts +58 -0
  71. package/esm/models/operations/deleteworkspace.js +21 -0
  72. package/esm/models/operations/getgeneration.d.ts +0 -196
  73. package/esm/models/operations/getgeneration.js +0 -102
  74. package/esm/models/operations/getworkspace.d.ts +58 -0
  75. package/esm/models/operations/getworkspace.js +21 -0
  76. package/esm/models/operations/index.d.ts +9 -0
  77. package/esm/models/operations/index.js +9 -0
  78. package/esm/models/operations/listgenerationcontent.d.ts +58 -0
  79. package/esm/models/operations/listgenerationcontent.js +21 -0
  80. package/esm/models/operations/listguardrails.d.ts +5 -0
  81. package/esm/models/operations/listguardrails.js +2 -0
  82. package/esm/models/operations/listworkspaces.d.ts +72 -0
  83. package/esm/models/operations/listworkspaces.js +35 -0
  84. package/esm/models/operations/updateworkspace.d.ts +61 -0
  85. package/esm/models/operations/updateworkspace.js +24 -0
  86. package/esm/models/updateworkspacerequest.d.ts +55 -0
  87. package/esm/models/updateworkspacerequest.js +31 -0
  88. package/esm/models/updateworkspaceresponse.d.ts +11 -0
  89. package/esm/models/updateworkspaceresponse.js +15 -0
  90. package/esm/models/workspace.d.ts +61 -0
  91. package/esm/models/workspace.js +39 -0
  92. package/esm/models/workspacemember.d.ts +43 -0
  93. package/esm/models/workspacemember.js +35 -0
  94. package/esm/sdk/generations.d.ts +6 -1
  95. package/esm/sdk/generations.js +7 -0
  96. package/esm/sdk/sdk.d.ts +6 -0
  97. package/esm/sdk/sdk.js +8 -0
  98. package/esm/sdk/tts.d.ts +12 -0
  99. package/esm/sdk/tts.js +19 -0
  100. package/esm/sdk/workspaces.d.ts +58 -0
  101. package/esm/sdk/workspaces.js +80 -0
  102. package/jsr.json +1 -1
  103. package/package.json +6 -6
@@ -0,0 +1,99 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: 151342b46246
4
+ */
5
+ import { encodeJSON, encodeSimple } from "../lib/encodings.js";
6
+ import * as M from "../lib/matchers.js";
7
+ import { compactMap } from "../lib/primitives.js";
8
+ import { safeParse } from "../lib/schemas.js";
9
+ import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
10
+ import { pathToFunc } from "../lib/url.js";
11
+ import * as errors from "../models/errors/index.js";
12
+ import * as models from "../models/index.js";
13
+ import * as operations from "../models/operations/index.js";
14
+ import { APIPromise } from "../types/async.js";
15
+ /**
16
+ * Create a workspace
17
+ *
18
+ * @remarks
19
+ * Create a new workspace for the authenticated user. [Management key](/docs/guides/overview/auth/management-api-keys) required.
20
+ */
21
+ export function workspacesCreate(client, request, options) {
22
+ return new APIPromise($do(client, request, options));
23
+ }
24
+ async function $do(client, request, options) {
25
+ const parsed = safeParse(request, (value) => operations.CreateWorkspaceRequest$outboundSchema.parse(value), "Input validation failed");
26
+ if (!parsed.ok) {
27
+ return [parsed, { status: "invalid" }];
28
+ }
29
+ const payload = parsed.value;
30
+ const body = encodeJSON("body", payload.CreateWorkspaceRequest, {
31
+ explode: true,
32
+ });
33
+ const path = pathToFunc("/workspaces")();
34
+ const headers = new Headers(compactMap({
35
+ "Content-Type": "application/json",
36
+ Accept: "application/json",
37
+ "HTTP-Referer": encodeSimple("HTTP-Referer", payload["HTTP-Referer"] ?? client._options.httpReferer, { explode: false, charEncoding: "none" }),
38
+ "X-OpenRouter-Categories": encodeSimple("X-OpenRouter-Categories", payload.appCategories ?? client._options.appCategories, { explode: false, charEncoding: "none" }),
39
+ "X-OpenRouter-Title": encodeSimple("X-OpenRouter-Title", payload.appTitle ?? client._options.appTitle, { explode: false, charEncoding: "none" }),
40
+ }));
41
+ const secConfig = await extractSecurity(client._options.apiKey);
42
+ const securityInput = secConfig == null ? {} : { apiKey: secConfig };
43
+ const requestSecurity = resolveGlobalSecurity(securityInput);
44
+ const context = {
45
+ options: client._options,
46
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
47
+ operationID: "createWorkspace",
48
+ oAuth2Scopes: null,
49
+ resolvedSecurity: requestSecurity,
50
+ securitySource: client._options.apiKey,
51
+ retryConfig: options?.retries
52
+ || client._options.retryConfig
53
+ || {
54
+ strategy: "backoff",
55
+ backoff: {
56
+ initialInterval: 500,
57
+ maxInterval: 60000,
58
+ exponent: 1.5,
59
+ maxElapsedTime: 3600000,
60
+ },
61
+ retryConnectionErrors: true,
62
+ }
63
+ || { strategy: "none" },
64
+ retryCodes: options?.retryCodes || ["5XX"],
65
+ };
66
+ const requestRes = client._createRequest(context, {
67
+ security: requestSecurity,
68
+ method: "POST",
69
+ baseURL: options?.serverURL,
70
+ path: path,
71
+ headers: headers,
72
+ body: body,
73
+ userAgent: client._options.userAgent,
74
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
75
+ }, options);
76
+ if (!requestRes.ok) {
77
+ return [requestRes, { status: "invalid" }];
78
+ }
79
+ const req = requestRes.value;
80
+ const doResult = await client._do(req, {
81
+ context,
82
+ errorCodes: ["400", "401", "403", "4XX", "500", "5XX"],
83
+ retryConfig: context.retryConfig,
84
+ retryCodes: context.retryCodes,
85
+ });
86
+ if (!doResult.ok) {
87
+ return [doResult, { status: "request-error", request: req }];
88
+ }
89
+ const response = doResult.value;
90
+ const responseFields = {
91
+ HttpMeta: { Response: response, Request: req },
92
+ };
93
+ const [result] = await M.match(M.json(201, models.CreateWorkspaceResponse$inboundSchema), M.jsonErr(400, errors.BadRequestResponseError$inboundSchema), M.jsonErr(401, errors.UnauthorizedResponseError$inboundSchema), M.jsonErr(403, errors.ForbiddenResponseError$inboundSchema), M.jsonErr(500, errors.InternalServerResponseError$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
94
+ if (!result.ok) {
95
+ return [result, { status: "complete", request: req, response }];
96
+ }
97
+ return [result, { status: "complete", request: req, response }];
98
+ }
99
+ //# sourceMappingURL=workspacesCreate.js.map
@@ -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
+ * Delete a workspace
14
+ *
15
+ * @remarks
16
+ * Delete an existing workspace. The default workspace cannot be deleted. Workspaces with active API keys cannot be deleted. [Management key](/docs/guides/overview/auth/management-api-keys) required.
17
+ */
18
+ export declare function workspacesDelete(client: OpenRouterCore, request: operations.DeleteWorkspaceRequest, options?: RequestOptions): APIPromise<Result<models.DeleteWorkspaceResponse, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.ForbiddenResponseError | errors.NotFoundResponseError | errors.InternalServerResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
19
+ //# sourceMappingURL=workspacesDelete.d.ts.map
@@ -0,0 +1,102 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: 548699dffed1
4
+ */
5
+ import { encodeSimple } from "../lib/encodings.js";
6
+ import * as M from "../lib/matchers.js";
7
+ import { compactMap } from "../lib/primitives.js";
8
+ import { safeParse } from "../lib/schemas.js";
9
+ import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
10
+ import { pathToFunc } from "../lib/url.js";
11
+ import * as errors from "../models/errors/index.js";
12
+ import * as models from "../models/index.js";
13
+ import * as operations from "../models/operations/index.js";
14
+ import { APIPromise } from "../types/async.js";
15
+ /**
16
+ * Delete a workspace
17
+ *
18
+ * @remarks
19
+ * Delete an existing workspace. The default workspace cannot be deleted. Workspaces with active API keys cannot be deleted. [Management key](/docs/guides/overview/auth/management-api-keys) required.
20
+ */
21
+ export function workspacesDelete(client, request, options) {
22
+ return new APIPromise($do(client, request, options));
23
+ }
24
+ async function $do(client, request, options) {
25
+ const parsed = safeParse(request, (value) => operations.DeleteWorkspaceRequest$outboundSchema.parse(value), "Input validation failed");
26
+ if (!parsed.ok) {
27
+ return [parsed, { status: "invalid" }];
28
+ }
29
+ const payload = parsed.value;
30
+ const body = null;
31
+ const pathParams = {
32
+ id: encodeSimple("id", payload.id, {
33
+ explode: false,
34
+ charEncoding: "percent",
35
+ }),
36
+ };
37
+ const path = pathToFunc("/workspaces/{id}")(pathParams);
38
+ const headers = new Headers(compactMap({
39
+ Accept: "application/json",
40
+ "HTTP-Referer": encodeSimple("HTTP-Referer", payload["HTTP-Referer"] ?? client._options.httpReferer, { explode: false, charEncoding: "none" }),
41
+ "X-OpenRouter-Categories": encodeSimple("X-OpenRouter-Categories", payload.appCategories ?? client._options.appCategories, { explode: false, charEncoding: "none" }),
42
+ "X-OpenRouter-Title": encodeSimple("X-OpenRouter-Title", payload.appTitle ?? client._options.appTitle, { explode: false, charEncoding: "none" }),
43
+ }));
44
+ const secConfig = await extractSecurity(client._options.apiKey);
45
+ const securityInput = secConfig == null ? {} : { apiKey: secConfig };
46
+ const requestSecurity = resolveGlobalSecurity(securityInput);
47
+ const context = {
48
+ options: client._options,
49
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
50
+ operationID: "deleteWorkspace",
51
+ oAuth2Scopes: null,
52
+ resolvedSecurity: requestSecurity,
53
+ securitySource: client._options.apiKey,
54
+ retryConfig: options?.retries
55
+ || client._options.retryConfig
56
+ || {
57
+ strategy: "backoff",
58
+ backoff: {
59
+ initialInterval: 500,
60
+ maxInterval: 60000,
61
+ exponent: 1.5,
62
+ maxElapsedTime: 3600000,
63
+ },
64
+ retryConnectionErrors: true,
65
+ }
66
+ || { strategy: "none" },
67
+ retryCodes: options?.retryCodes || ["5XX"],
68
+ };
69
+ const requestRes = client._createRequest(context, {
70
+ security: requestSecurity,
71
+ method: "DELETE",
72
+ baseURL: options?.serverURL,
73
+ path: path,
74
+ headers: headers,
75
+ body: body,
76
+ userAgent: client._options.userAgent,
77
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
78
+ }, options);
79
+ if (!requestRes.ok) {
80
+ return [requestRes, { status: "invalid" }];
81
+ }
82
+ const req = requestRes.value;
83
+ const doResult = await client._do(req, {
84
+ context,
85
+ errorCodes: ["400", "401", "403", "404", "4XX", "500", "5XX"],
86
+ retryConfig: context.retryConfig,
87
+ retryCodes: context.retryCodes,
88
+ });
89
+ if (!doResult.ok) {
90
+ return [doResult, { status: "request-error", request: req }];
91
+ }
92
+ const response = doResult.value;
93
+ const responseFields = {
94
+ HttpMeta: { Response: response, Request: req },
95
+ };
96
+ const [result] = await M.match(M.json(200, models.DeleteWorkspaceResponse$inboundSchema), M.jsonErr(400, errors.BadRequestResponseError$inboundSchema), M.jsonErr(401, errors.UnauthorizedResponseError$inboundSchema), M.jsonErr(403, errors.ForbiddenResponseError$inboundSchema), M.jsonErr(404, errors.NotFoundResponseError$inboundSchema), M.jsonErr(500, errors.InternalServerResponseError$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
97
+ if (!result.ok) {
98
+ return [result, { status: "complete", request: req, response }];
99
+ }
100
+ return [result, { status: "complete", request: req, response }];
101
+ }
102
+ //# sourceMappingURL=workspacesDelete.js.map
@@ -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
14
+ *
15
+ * @remarks
16
+ * Get a single workspace by ID or slug. [Management key](/docs/guides/overview/auth/management-api-keys) required.
17
+ */
18
+ export declare function workspacesGet(client: OpenRouterCore, request: operations.GetWorkspaceRequest, options?: RequestOptions): APIPromise<Result<models.GetWorkspaceResponse, errors.UnauthorizedResponseError | errors.NotFoundResponseError | errors.InternalServerResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
19
+ //# sourceMappingURL=workspacesGet.d.ts.map
@@ -0,0 +1,102 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: f361d34e5bff
4
+ */
5
+ import { encodeSimple } from "../lib/encodings.js";
6
+ import * as M from "../lib/matchers.js";
7
+ import { compactMap } from "../lib/primitives.js";
8
+ import { safeParse } from "../lib/schemas.js";
9
+ import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
10
+ import { pathToFunc } from "../lib/url.js";
11
+ import * as errors from "../models/errors/index.js";
12
+ import * as models from "../models/index.js";
13
+ import * as operations from "../models/operations/index.js";
14
+ import { APIPromise } from "../types/async.js";
15
+ /**
16
+ * Get a workspace
17
+ *
18
+ * @remarks
19
+ * Get a single workspace by ID or slug. [Management key](/docs/guides/overview/auth/management-api-keys) required.
20
+ */
21
+ export function workspacesGet(client, request, options) {
22
+ return new APIPromise($do(client, request, options));
23
+ }
24
+ async function $do(client, request, options) {
25
+ const parsed = safeParse(request, (value) => operations.GetWorkspaceRequest$outboundSchema.parse(value), "Input validation failed");
26
+ if (!parsed.ok) {
27
+ return [parsed, { status: "invalid" }];
28
+ }
29
+ const payload = parsed.value;
30
+ const body = null;
31
+ const pathParams = {
32
+ id: encodeSimple("id", payload.id, {
33
+ explode: false,
34
+ charEncoding: "percent",
35
+ }),
36
+ };
37
+ const path = pathToFunc("/workspaces/{id}")(pathParams);
38
+ const headers = new Headers(compactMap({
39
+ Accept: "application/json",
40
+ "HTTP-Referer": encodeSimple("HTTP-Referer", payload["HTTP-Referer"] ?? client._options.httpReferer, { explode: false, charEncoding: "none" }),
41
+ "X-OpenRouter-Categories": encodeSimple("X-OpenRouter-Categories", payload.appCategories ?? client._options.appCategories, { explode: false, charEncoding: "none" }),
42
+ "X-OpenRouter-Title": encodeSimple("X-OpenRouter-Title", payload.appTitle ?? client._options.appTitle, { explode: false, charEncoding: "none" }),
43
+ }));
44
+ const secConfig = await extractSecurity(client._options.apiKey);
45
+ const securityInput = secConfig == null ? {} : { apiKey: secConfig };
46
+ const requestSecurity = resolveGlobalSecurity(securityInput);
47
+ const context = {
48
+ options: client._options,
49
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
50
+ operationID: "getWorkspace",
51
+ oAuth2Scopes: null,
52
+ resolvedSecurity: requestSecurity,
53
+ securitySource: client._options.apiKey,
54
+ retryConfig: options?.retries
55
+ || client._options.retryConfig
56
+ || {
57
+ strategy: "backoff",
58
+ backoff: {
59
+ initialInterval: 500,
60
+ maxInterval: 60000,
61
+ exponent: 1.5,
62
+ maxElapsedTime: 3600000,
63
+ },
64
+ retryConnectionErrors: true,
65
+ }
66
+ || { strategy: "none" },
67
+ retryCodes: options?.retryCodes || ["5XX"],
68
+ };
69
+ const requestRes = client._createRequest(context, {
70
+ security: requestSecurity,
71
+ method: "GET",
72
+ baseURL: options?.serverURL,
73
+ path: path,
74
+ headers: headers,
75
+ body: body,
76
+ userAgent: client._options.userAgent,
77
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
78
+ }, options);
79
+ if (!requestRes.ok) {
80
+ return [requestRes, { status: "invalid" }];
81
+ }
82
+ const req = requestRes.value;
83
+ const doResult = await client._do(req, {
84
+ context,
85
+ errorCodes: ["401", "404", "4XX", "500", "5XX"],
86
+ retryConfig: context.retryConfig,
87
+ retryCodes: context.retryCodes,
88
+ });
89
+ if (!doResult.ok) {
90
+ return [doResult, { status: "request-error", request: req }];
91
+ }
92
+ const response = doResult.value;
93
+ const responseFields = {
94
+ HttpMeta: { Response: response, Request: req },
95
+ };
96
+ const [result] = await M.match(M.json(200, models.GetWorkspaceResponse$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 });
97
+ if (!result.ok) {
98
+ return [result, { status: "complete", request: req, response }];
99
+ }
100
+ return [result, { status: "complete", request: req, response }];
101
+ }
102
+ //# sourceMappingURL=workspacesGet.js.map
@@ -0,0 +1,21 @@
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 operations from "../models/operations/index.js";
9
+ import { APIPromise } from "../types/async.js";
10
+ import { Result } from "../types/fp.js";
11
+ import { PageIterator } from "../types/operations.js";
12
+ /**
13
+ * List workspaces
14
+ *
15
+ * @remarks
16
+ * List all workspaces for the authenticated user. [Management key](/docs/guides/overview/auth/management-api-keys) required.
17
+ */
18
+ export declare function workspacesList(client: OpenRouterCore, request?: operations.ListWorkspacesRequest | undefined, options?: RequestOptions): APIPromise<PageIterator<Result<operations.ListWorkspacesResponse, errors.UnauthorizedResponseError | errors.InternalServerResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>, {
19
+ offset: number;
20
+ }>>;
21
+ //# sourceMappingURL=workspacesList.d.ts.map
@@ -0,0 +1,133 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: 6ff9df556ff5
4
+ */
5
+ import { dlv } from "../lib/dlv.js";
6
+ import { encodeFormQuery, encodeSimple } from "../lib/encodings.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 operations from "../models/operations/index.js";
14
+ import { APIPromise } from "../types/async.js";
15
+ import { createPageIterator, haltIterator, } from "../types/operations.js";
16
+ /**
17
+ * List workspaces
18
+ *
19
+ * @remarks
20
+ * List all workspaces for the authenticated user. [Management key](/docs/guides/overview/auth/management-api-keys) required.
21
+ */
22
+ export function workspacesList(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.ListWorkspacesRequest$outboundSchema.optional().parse(value), "Input validation failed");
27
+ if (!parsed.ok) {
28
+ return [haltIterator(parsed), { status: "invalid" }];
29
+ }
30
+ const payload = parsed.value;
31
+ const body = null;
32
+ const path = pathToFunc("/workspaces")();
33
+ const query = encodeFormQuery({
34
+ "limit": payload?.limit,
35
+ "offset": payload?.offset,
36
+ });
37
+ const headers = new Headers(compactMap({
38
+ Accept: "application/json",
39
+ "HTTP-Referer": encodeSimple("HTTP-Referer", payload?.["HTTP-Referer"] ?? client._options.httpReferer, { explode: false, charEncoding: "none" }),
40
+ "X-OpenRouter-Categories": encodeSimple("X-OpenRouter-Categories", payload?.appCategories ?? client._options.appCategories, { explode: false, charEncoding: "none" }),
41
+ "X-OpenRouter-Title": encodeSimple("X-OpenRouter-Title", payload?.appTitle ?? client._options.appTitle, { explode: false, charEncoding: "none" }),
42
+ }));
43
+ const secConfig = await extractSecurity(client._options.apiKey);
44
+ const securityInput = secConfig == null ? {} : { apiKey: secConfig };
45
+ const requestSecurity = resolveGlobalSecurity(securityInput);
46
+ const context = {
47
+ options: client._options,
48
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
49
+ operationID: "listWorkspaces",
50
+ oAuth2Scopes: null,
51
+ resolvedSecurity: requestSecurity,
52
+ securitySource: client._options.apiKey,
53
+ retryConfig: options?.retries
54
+ || client._options.retryConfig
55
+ || {
56
+ strategy: "backoff",
57
+ backoff: {
58
+ initialInterval: 500,
59
+ maxInterval: 60000,
60
+ exponent: 1.5,
61
+ maxElapsedTime: 3600000,
62
+ },
63
+ retryConnectionErrors: true,
64
+ }
65
+ || { strategy: "none" },
66
+ retryCodes: options?.retryCodes || ["5XX"],
67
+ };
68
+ const requestRes = client._createRequest(context, {
69
+ security: requestSecurity,
70
+ method: "GET",
71
+ baseURL: options?.serverURL,
72
+ path: path,
73
+ headers: headers,
74
+ query: query,
75
+ body: body,
76
+ userAgent: client._options.userAgent,
77
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
78
+ }, options);
79
+ if (!requestRes.ok) {
80
+ return [haltIterator(requestRes), { status: "invalid" }];
81
+ }
82
+ const req = requestRes.value;
83
+ const doResult = await client._do(req, {
84
+ context,
85
+ errorCodes: ["401", "4XX", "500", "5XX"],
86
+ retryConfig: context.retryConfig,
87
+ retryCodes: context.retryCodes,
88
+ });
89
+ if (!doResult.ok) {
90
+ return [haltIterator(doResult), { status: "request-error", request: req }];
91
+ }
92
+ const response = doResult.value;
93
+ const responseFields = {
94
+ HttpMeta: { Response: response, Request: req },
95
+ };
96
+ const [result, raw] = await M.match(M.json(200, operations.ListWorkspacesResponse$inboundSchema, {
97
+ key: "Result",
98
+ }), M.jsonErr(401, errors.UnauthorizedResponseError$inboundSchema), M.jsonErr(500, errors.InternalServerResponseError$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
99
+ if (!result.ok) {
100
+ return [haltIterator(result), {
101
+ status: "complete",
102
+ request: req,
103
+ response,
104
+ }];
105
+ }
106
+ const nextFunc = (responseData) => {
107
+ const offset = request?.offset ?? 0;
108
+ if (!responseData) {
109
+ return { next: () => null };
110
+ }
111
+ const results = dlv(responseData, "data");
112
+ if (!Array.isArray(results) || !results.length) {
113
+ return { next: () => null };
114
+ }
115
+ const limit = request?.limit ?? 0;
116
+ if (results.length < limit) {
117
+ return { next: () => null };
118
+ }
119
+ const nextOffset = offset + results.length;
120
+ const nextVal = () => workspacesList(client, {
121
+ ...request,
122
+ offset: nextOffset,
123
+ }, options);
124
+ return { next: nextVal, "~next": { offset: nextOffset } };
125
+ };
126
+ const page = { ...result, ...nextFunc(raw) };
127
+ return [{ ...page, ...createPageIterator(page, (v) => !v.ok) }, {
128
+ status: "complete",
129
+ request: req,
130
+ response,
131
+ }];
132
+ }
133
+ //# sourceMappingURL=workspacesList.js.map
@@ -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
+ * Update a workspace
14
+ *
15
+ * @remarks
16
+ * Update an existing workspace by ID or slug. [Management key](/docs/guides/overview/auth/management-api-keys) required.
17
+ */
18
+ export declare function workspacesUpdate(client: OpenRouterCore, request: operations.UpdateWorkspaceRequest, options?: RequestOptions): APIPromise<Result<models.UpdateWorkspaceResponse, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.ForbiddenResponseError | errors.NotFoundResponseError | errors.InternalServerResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
19
+ //# sourceMappingURL=workspacesUpdate.d.ts.map
@@ -0,0 +1,105 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: f0404418dd03
4
+ */
5
+ import { encodeJSON, encodeSimple } from "../lib/encodings.js";
6
+ import * as M from "../lib/matchers.js";
7
+ import { compactMap } from "../lib/primitives.js";
8
+ import { safeParse } from "../lib/schemas.js";
9
+ import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
10
+ import { pathToFunc } from "../lib/url.js";
11
+ import * as errors from "../models/errors/index.js";
12
+ import * as models from "../models/index.js";
13
+ import * as operations from "../models/operations/index.js";
14
+ import { APIPromise } from "../types/async.js";
15
+ /**
16
+ * Update a workspace
17
+ *
18
+ * @remarks
19
+ * Update an existing workspace by ID or slug. [Management key](/docs/guides/overview/auth/management-api-keys) required.
20
+ */
21
+ export function workspacesUpdate(client, request, options) {
22
+ return new APIPromise($do(client, request, options));
23
+ }
24
+ async function $do(client, request, options) {
25
+ const parsed = safeParse(request, (value) => operations.UpdateWorkspaceRequest$outboundSchema.parse(value), "Input validation failed");
26
+ if (!parsed.ok) {
27
+ return [parsed, { status: "invalid" }];
28
+ }
29
+ const payload = parsed.value;
30
+ const body = encodeJSON("body", payload.UpdateWorkspaceRequest, {
31
+ explode: true,
32
+ });
33
+ const pathParams = {
34
+ id: encodeSimple("id", payload.id, {
35
+ explode: false,
36
+ charEncoding: "percent",
37
+ }),
38
+ };
39
+ const path = pathToFunc("/workspaces/{id}")(pathParams);
40
+ const headers = new Headers(compactMap({
41
+ "Content-Type": "application/json",
42
+ Accept: "application/json",
43
+ "HTTP-Referer": encodeSimple("HTTP-Referer", payload["HTTP-Referer"] ?? client._options.httpReferer, { explode: false, charEncoding: "none" }),
44
+ "X-OpenRouter-Categories": encodeSimple("X-OpenRouter-Categories", payload.appCategories ?? client._options.appCategories, { explode: false, charEncoding: "none" }),
45
+ "X-OpenRouter-Title": encodeSimple("X-OpenRouter-Title", payload.appTitle ?? client._options.appTitle, { explode: false, charEncoding: "none" }),
46
+ }));
47
+ const secConfig = await extractSecurity(client._options.apiKey);
48
+ const securityInput = secConfig == null ? {} : { apiKey: secConfig };
49
+ const requestSecurity = resolveGlobalSecurity(securityInput);
50
+ const context = {
51
+ options: client._options,
52
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
53
+ operationID: "updateWorkspace",
54
+ oAuth2Scopes: null,
55
+ resolvedSecurity: requestSecurity,
56
+ securitySource: client._options.apiKey,
57
+ retryConfig: options?.retries
58
+ || client._options.retryConfig
59
+ || {
60
+ strategy: "backoff",
61
+ backoff: {
62
+ initialInterval: 500,
63
+ maxInterval: 60000,
64
+ exponent: 1.5,
65
+ maxElapsedTime: 3600000,
66
+ },
67
+ retryConnectionErrors: true,
68
+ }
69
+ || { strategy: "none" },
70
+ retryCodes: options?.retryCodes || ["5XX"],
71
+ };
72
+ const requestRes = client._createRequest(context, {
73
+ security: requestSecurity,
74
+ method: "PATCH",
75
+ baseURL: options?.serverURL,
76
+ path: path,
77
+ headers: headers,
78
+ body: body,
79
+ userAgent: client._options.userAgent,
80
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
81
+ }, options);
82
+ if (!requestRes.ok) {
83
+ return [requestRes, { status: "invalid" }];
84
+ }
85
+ const req = requestRes.value;
86
+ const doResult = await client._do(req, {
87
+ context,
88
+ errorCodes: ["400", "401", "403", "404", "4XX", "500", "5XX"],
89
+ retryConfig: context.retryConfig,
90
+ retryCodes: context.retryCodes,
91
+ });
92
+ if (!doResult.ok) {
93
+ return [doResult, { status: "request-error", request: req }];
94
+ }
95
+ const response = doResult.value;
96
+ const responseFields = {
97
+ HttpMeta: { Response: response, Request: req },
98
+ };
99
+ const [result] = await M.match(M.json(200, models.UpdateWorkspaceResponse$inboundSchema), M.jsonErr(400, errors.BadRequestResponseError$inboundSchema), M.jsonErr(401, errors.UnauthorizedResponseError$inboundSchema), M.jsonErr(403, errors.ForbiddenResponseError$inboundSchema), M.jsonErr(404, errors.NotFoundResponseError$inboundSchema), M.jsonErr(500, errors.InternalServerResponseError$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
100
+ if (!result.ok) {
101
+ return [result, { status: "complete", request: req, response }];
102
+ }
103
+ return [result, { status: "complete", request: req, response }];
104
+ }
105
+ //# sourceMappingURL=workspacesUpdate.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: "0.12.15";
52
+ readonly sdkVersion: "0.12.17";
53
53
  readonly genVersion: "2.879.1";
54
- readonly userAgent: "speakeasy-sdk/typescript 0.12.15 2.879.1 1.0.0 @openrouter/sdk";
54
+ readonly userAgent: "speakeasy-sdk/typescript 0.12.17 2.879.1 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: "0.12.15",
29
+ sdkVersion: "0.12.17",
30
30
  genVersion: "2.879.1",
31
- userAgent: "speakeasy-sdk/typescript 0.12.15 2.879.1 1.0.0 @openrouter/sdk",
31
+ userAgent: "speakeasy-sdk/typescript 0.12.17 2.879.1 1.0.0 @openrouter/sdk",
32
32
  };
33
33
  //# sourceMappingURL=config.js.map