@openrouter/sdk 1.2.98 → 1.2.100

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 (40) hide show
  1. package/esm/funcs/apiKeysCreate.d.ts +1 -1
  2. package/esm/funcs/apiKeysCreate.js +1 -1
  3. package/esm/funcs/apiKeysDelete.d.ts +1 -1
  4. package/esm/funcs/apiKeysDelete.js +1 -1
  5. package/esm/funcs/apiKeysUpdate.d.ts +1 -1
  6. package/esm/funcs/apiKeysUpdate.js +1 -1
  7. package/esm/funcs/oAuthCreateOauthToken.d.ts +19 -0
  8. package/esm/funcs/oAuthCreateOauthToken.js +100 -0
  9. package/esm/funcs/oAuthListOauthJwks.d.ts +19 -0
  10. package/esm/funcs/oAuthListOauthJwks.js +97 -0
  11. package/esm/lib/config.d.ts +2 -2
  12. package/esm/lib/config.js +2 -2
  13. package/esm/models/errors/index.d.ts +1 -0
  14. package/esm/models/errors/index.js +1 -0
  15. package/esm/models/errors/oautherrorresponse.d.ts +27 -0
  16. package/esm/models/errors/oautherrorresponse.js +42 -0
  17. package/esm/models/index.d.ts +4 -0
  18. package/esm/models/index.js +4 -0
  19. package/esm/models/oautherrorresponse.d.ts +14 -0
  20. package/esm/models/oautherrorresponse.js +17 -0
  21. package/esm/models/oauthjwks.d.ts +50 -0
  22. package/esm/models/oauthjwks.js +47 -0
  23. package/esm/models/operations/createkeys.d.ts +26 -0
  24. package/esm/models/operations/createkeys.js +14 -0
  25. package/esm/models/operations/createoauthtoken.d.ts +56 -0
  26. package/esm/models/operations/createoauthtoken.js +23 -0
  27. package/esm/models/operations/index.d.ts +2 -0
  28. package/esm/models/operations/index.js +2 -0
  29. package/esm/models/operations/listoauthjwks.d.ts +53 -0
  30. package/esm/models/operations/listoauthjwks.js +20 -0
  31. package/esm/models/tokenexchangerequest.d.ts +92 -0
  32. package/esm/models/tokenexchangerequest.js +59 -0
  33. package/esm/models/tokenexchangeresponse.d.ts +36 -0
  34. package/esm/models/tokenexchangeresponse.js +36 -0
  35. package/esm/sdk/apikeys.d.ts +3 -3
  36. package/esm/sdk/apikeys.js +3 -3
  37. package/esm/sdk/oauth.d.ts +15 -0
  38. package/esm/sdk/oauth.js +20 -0
  39. package/jsr.json +1 -1
  40. package/package.json +6 -6
@@ -12,7 +12,7 @@ import { Result } from "../types/fp.js";
12
12
  * Create a new API key
13
13
  *
14
14
  * @remarks
15
- * Create a new API key for the authenticated user. The plaintext `key` is returned only in this response. Treat it as a write-only, sensitive value; it cannot be retrieved later. Authenticate with a [management key](/docs/guides/overview/auth/management-api-keys), or with a Connect client secret.
15
+ * Create a new API key for the authenticated user. The plaintext `key` is returned only in this response. Treat it as a write-only, sensitive value; it cannot be retrieved later. Authenticate with a [management key](/docs/guides/overview/auth/management-api-keys). The optional `external` object associates the key with a partner-defined user and lookup key.
16
16
  */
17
17
  export declare function apiKeysCreate(client: OpenRouterCore, request: operations.CreateKeysRequest, options?: RequestOptions): APIPromise<Result<operations.CreateKeysResponse, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.ForbiddenResponseError | errors.TooManyRequestsResponseError | errors.InternalServerResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
18
18
  //# sourceMappingURL=apiKeysCreate.d.ts.map
@@ -16,7 +16,7 @@ import { APIPromise } from "../types/async.js";
16
16
  * Create a new API key
17
17
  *
18
18
  * @remarks
19
- * Create a new API key for the authenticated user. The plaintext `key` is returned only in this response. Treat it as a write-only, sensitive value; it cannot be retrieved later. Authenticate with a [management key](/docs/guides/overview/auth/management-api-keys), or with a Connect client secret.
19
+ * Create a new API key for the authenticated user. The plaintext `key` is returned only in this response. Treat it as a write-only, sensitive value; it cannot be retrieved later. Authenticate with a [management key](/docs/guides/overview/auth/management-api-keys). The optional `external` object associates the key with a partner-defined user and lookup key.
20
20
  */
21
21
  export function apiKeysCreate(client, request, options) {
22
22
  return new APIPromise($do(client, request, options));
@@ -12,7 +12,7 @@ import { Result } from "../types/fp.js";
12
12
  * Delete an API key
13
13
  *
14
14
  * @remarks
15
- * Delete an existing API key. Authenticate with a [management key](/docs/guides/overview/auth/management-api-keys), or with a Connect client secret. A client secret reaches only the keys that same client created; any other key responds as if it does not exist.
15
+ * Delete an existing API key. Authenticate with a [management key](/docs/guides/overview/auth/management-api-keys).
16
16
  */
17
17
  export declare function apiKeysDelete(client: OpenRouterCore, request: operations.DeleteKeysRequest, options?: RequestOptions): APIPromise<Result<operations.DeleteKeysResponse, errors.UnauthorizedResponseError | errors.NotFoundResponseError | errors.TooManyRequestsResponseError | errors.InternalServerResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
18
18
  //# sourceMappingURL=apiKeysDelete.d.ts.map
@@ -16,7 +16,7 @@ import { APIPromise } from "../types/async.js";
16
16
  * Delete an API key
17
17
  *
18
18
  * @remarks
19
- * Delete an existing API key. Authenticate with a [management key](/docs/guides/overview/auth/management-api-keys), or with a Connect client secret. A client secret reaches only the keys that same client created; any other key responds as if it does not exist.
19
+ * Delete an existing API key. Authenticate with a [management key](/docs/guides/overview/auth/management-api-keys).
20
20
  */
21
21
  export function apiKeysDelete(client, request, options) {
22
22
  return new APIPromise($do(client, request, options));
@@ -12,7 +12,7 @@ import { Result } from "../types/fp.js";
12
12
  * Update an API key
13
13
  *
14
14
  * @remarks
15
- * Update an existing API key. Authenticate with a [management key](/docs/guides/overview/auth/management-api-keys), or with a Connect client secret. A client secret reaches only the keys that same client created; any other key responds as if it does not exist.
15
+ * Update an existing API key. Authenticate with a [management key](/docs/guides/overview/auth/management-api-keys).
16
16
  */
17
17
  export declare function apiKeysUpdate(client: OpenRouterCore, request: operations.UpdateKeysRequest, options?: RequestOptions): APIPromise<Result<operations.UpdateKeysResponse, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.NotFoundResponseError | errors.TooManyRequestsResponseError | errors.InternalServerResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
18
18
  //# sourceMappingURL=apiKeysUpdate.d.ts.map
@@ -16,7 +16,7 @@ import { APIPromise } from "../types/async.js";
16
16
  * Update an API key
17
17
  *
18
18
  * @remarks
19
- * Update an existing API key. Authenticate with a [management key](/docs/guides/overview/auth/management-api-keys), or with a Connect client secret. A client secret reaches only the keys that same client created; any other key responds as if it does not exist.
19
+ * Update an existing API key. Authenticate with a [management key](/docs/guides/overview/auth/management-api-keys).
20
20
  */
21
21
  export function apiKeysUpdate(client, request, options) {
22
22
  return new APIPromise($do(client, request, options));
@@ -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
+ * Exchange a workload identity token
14
+ *
15
+ * @remarks
16
+ * RFC 8693 token exchange. Presents a JWT from an issuer your organization trusts (Settings → Workload identity) and receives a short-lived OpenRouter access token that acts as the API key the matching federation policy targets.
17
+ */
18
+ export declare function oAuthCreateOauthToken(client: OpenRouterCore, request: operations.CreateOauthTokenRequest, options?: RequestOptions): APIPromise<Result<models.TokenExchangeResponse, errors.OAuthErrorResponse | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
19
+ //# sourceMappingURL=oAuthCreateOauthToken.d.ts.map
@@ -0,0 +1,100 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: e5f6a20bb612
4
+ */
5
+ import { encodeBodyForm, 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
+ * Exchange a workload identity token
18
+ *
19
+ * @remarks
20
+ * RFC 8693 token exchange. Presents a JWT from an issuer your organization trusts (Settings → Workload identity) and receives a short-lived OpenRouter access token that acts as the API key the matching federation policy targets.
21
+ */
22
+ export function oAuthCreateOauthToken(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.CreateOauthTokenRequest$outboundSchema.parse(value), "Input validation failed");
27
+ if (!parsed.ok) {
28
+ return [parsed, { status: "invalid" }];
29
+ }
30
+ const payload = parsed.value;
31
+ const body = Object.entries(payload.TokenExchangeRequest || {}).map(([k, v]) => {
32
+ return encodeBodyForm(k, v, { charEncoding: "percent" });
33
+ }).join("&");
34
+ const path = pathToFunc("/oauth/token")();
35
+ const headers = new Headers(compactMap({
36
+ "Content-Type": "application/x-www-form-urlencoded",
37
+ Accept: "application/json",
38
+ "HTTP-Referer": encodeSimple("HTTP-Referer", payload["HTTP-Referer"] ?? client._options.httpReferer, { explode: false, charEncoding: "none" }),
39
+ "X-OpenRouter-Categories": encodeSimple("X-OpenRouter-Categories", payload.appCategories ?? client._options.appCategories, { explode: false, charEncoding: "none" }),
40
+ "X-OpenRouter-Title": encodeSimple("X-OpenRouter-Title", payload.appTitle ?? client._options.appTitle, { explode: false, charEncoding: "none" }),
41
+ }));
42
+ const secConfig = await extractSecurity(client._options.apiKey);
43
+ const securityInput = secConfig == null ? {} : { apiKey: secConfig };
44
+ const requestSecurity = resolveGlobalSecurity(securityInput);
45
+ const context = {
46
+ options: client._options,
47
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
48
+ operationID: "createOauthToken",
49
+ oAuth2Scopes: null,
50
+ resolvedSecurity: requestSecurity,
51
+ securitySource: client._options.apiKey,
52
+ retryConfig: options?.retries
53
+ || client._options.retryConfig
54
+ || {
55
+ strategy: "backoff",
56
+ backoff: {
57
+ initialInterval: 500,
58
+ maxInterval: 60000,
59
+ exponent: 1.5,
60
+ maxElapsedTime: 3600000,
61
+ },
62
+ retryConnectionErrors: true,
63
+ }
64
+ || { strategy: "none" },
65
+ retryCodes: options?.retryCodes || ["5XX"],
66
+ };
67
+ const requestRes = client._createRequest(context, {
68
+ security: requestSecurity,
69
+ method: "POST",
70
+ baseURL: options?.serverURL,
71
+ path: path,
72
+ headers: headers,
73
+ body: body,
74
+ userAgent: client._options.userAgent,
75
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
76
+ }, options);
77
+ if (!requestRes.ok) {
78
+ return [requestRes, { status: "invalid" }];
79
+ }
80
+ const req = requestRes.value;
81
+ const doResult = await client._do(req, {
82
+ context,
83
+ isErrorStatusCode: (statusCode) => matchStatusCode({ status: statusCode }, ["4XX", "5XX"]),
84
+ retryConfig: context.retryConfig,
85
+ retryCodes: context.retryCodes,
86
+ });
87
+ if (!doResult.ok) {
88
+ return [doResult, { status: "request-error", request: req }];
89
+ }
90
+ const response = doResult.value;
91
+ const responseFields = {
92
+ HttpMeta: { Response: response, Request: req },
93
+ };
94
+ const [result] = await M.match(M.json(200, models.TokenExchangeResponse$inboundSchema), M.jsonErr([400, 429], errors.OAuthErrorResponse$inboundSchema), M.jsonErr([500, 503], errors.OAuthErrorResponse$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
95
+ if (!result.ok) {
96
+ return [result, { status: "complete", request: req, response }];
97
+ }
98
+ return [result, { status: "complete", request: req, response }];
99
+ }
100
+ //# sourceMappingURL=oAuthCreateOauthToken.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
+ * OpenRouter access token signing keys
14
+ *
15
+ * @remarks
16
+ * RFC 7517 JWK Set containing the public keys OpenRouter signs access tokens with.
17
+ */
18
+ export declare function oAuthListOauthJwks(client: OpenRouterCore, request?: operations.ListOauthJwksRequest | undefined, options?: RequestOptions): APIPromise<Result<models.OAuthJwks, errors.InternalServerResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
19
+ //# sourceMappingURL=oAuthListOauthJwks.d.ts.map
@@ -0,0 +1,97 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: f7899acb7c1e
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
+ * OpenRouter access token signing keys
18
+ *
19
+ * @remarks
20
+ * RFC 7517 JWK Set containing the public keys OpenRouter signs access tokens with.
21
+ */
22
+ export function oAuthListOauthJwks(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.ListOauthJwksRequest$outboundSchema.optional().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 path = pathToFunc("/oauth/jwks")();
33
+ const headers = new Headers(compactMap({
34
+ Accept: "application/json",
35
+ "HTTP-Referer": encodeSimple("HTTP-Referer", payload?.["HTTP-Referer"] ?? client._options.httpReferer, { explode: false, charEncoding: "none" }),
36
+ "X-OpenRouter-Categories": encodeSimple("X-OpenRouter-Categories", payload?.appCategories ?? client._options.appCategories, { explode: false, charEncoding: "none" }),
37
+ "X-OpenRouter-Title": encodeSimple("X-OpenRouter-Title", payload?.appTitle ?? client._options.appTitle, { explode: false, charEncoding: "none" }),
38
+ }));
39
+ const secConfig = await extractSecurity(client._options.apiKey);
40
+ const securityInput = secConfig == null ? {} : { apiKey: secConfig };
41
+ const requestSecurity = resolveGlobalSecurity(securityInput);
42
+ const context = {
43
+ options: client._options,
44
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
45
+ operationID: "listOauthJwks",
46
+ oAuth2Scopes: null,
47
+ resolvedSecurity: requestSecurity,
48
+ securitySource: client._options.apiKey,
49
+ retryConfig: options?.retries
50
+ || client._options.retryConfig
51
+ || {
52
+ strategy: "backoff",
53
+ backoff: {
54
+ initialInterval: 500,
55
+ maxInterval: 60000,
56
+ exponent: 1.5,
57
+ maxElapsedTime: 3600000,
58
+ },
59
+ retryConnectionErrors: true,
60
+ }
61
+ || { strategy: "none" },
62
+ retryCodes: options?.retryCodes || ["5XX"],
63
+ };
64
+ const requestRes = client._createRequest(context, {
65
+ security: requestSecurity,
66
+ method: "GET",
67
+ baseURL: options?.serverURL,
68
+ path: path,
69
+ headers: headers,
70
+ body: body,
71
+ userAgent: client._options.userAgent,
72
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
73
+ }, options);
74
+ if (!requestRes.ok) {
75
+ return [requestRes, { status: "invalid" }];
76
+ }
77
+ const req = requestRes.value;
78
+ const doResult = await client._do(req, {
79
+ context,
80
+ isErrorStatusCode: (statusCode) => matchStatusCode({ status: statusCode }, ["4XX", "5XX"]),
81
+ retryConfig: context.retryConfig,
82
+ retryCodes: context.retryCodes,
83
+ });
84
+ if (!doResult.ok) {
85
+ return [doResult, { status: "request-error", request: req }];
86
+ }
87
+ const response = doResult.value;
88
+ const responseFields = {
89
+ HttpMeta: { Response: response, Request: req },
90
+ };
91
+ const [result] = await M.match(M.json(200, models.OAuthJwks$inboundSchema), M.jsonErr(500, errors.InternalServerResponseError$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
92
+ if (!result.ok) {
93
+ return [result, { status: "complete", request: req, response }];
94
+ }
95
+ return [result, { status: "complete", request: req, response }];
96
+ }
97
+ //# sourceMappingURL=oAuthListOauthJwks.js.map
@@ -50,8 +50,8 @@ export declare function serverURLFromOptions(options: SDKOptions): URL | null;
50
50
  export declare const SDK_METADATA: {
51
51
  readonly language: "typescript";
52
52
  readonly openapiDocVersion: "1.0.0";
53
- readonly sdkVersion: "1.2.98";
53
+ readonly sdkVersion: "1.2.100";
54
54
  readonly genVersion: "2.914.0";
55
- readonly userAgent: "speakeasy-sdk/typescript 1.2.98 2.914.0 1.0.0 @openrouter/sdk";
55
+ readonly userAgent: "speakeasy-sdk/typescript 1.2.100 2.914.0 1.0.0 @openrouter/sdk";
56
56
  };
57
57
  //# sourceMappingURL=config.d.ts.map
package/esm/lib/config.js CHANGED
@@ -29,8 +29,8 @@ export function serverURLFromOptions(options) {
29
29
  export const SDK_METADATA = {
30
30
  language: "typescript",
31
31
  openapiDocVersion: "1.0.0",
32
- sdkVersion: "1.2.98",
32
+ sdkVersion: "1.2.100",
33
33
  genVersion: "2.914.0",
34
- userAgent: "speakeasy-sdk/typescript 1.2.98 2.914.0 1.0.0 @openrouter/sdk",
34
+ userAgent: "speakeasy-sdk/typescript 1.2.100 2.914.0 1.0.0 @openrouter/sdk",
35
35
  };
36
36
  //# sourceMappingURL=config.js.map
@@ -6,6 +6,7 @@ export * from "./forbiddenresponseerror.js";
6
6
  export * from "./httpclienterrors.js";
7
7
  export * from "./internalserverresponseerror.js";
8
8
  export * from "./notfoundresponseerror.js";
9
+ export * from "./oautherrorresponse.js";
9
10
  export * from "./openrouterdefaulterror.js";
10
11
  export * from "./openroutererror.js";
11
12
  export * from "./payloadtoolargeresponseerror.js";
@@ -10,6 +10,7 @@ export * from "./forbiddenresponseerror.js";
10
10
  export * from "./httpclienterrors.js";
11
11
  export * from "./internalserverresponseerror.js";
12
12
  export * from "./notfoundresponseerror.js";
13
+ export * from "./oautherrorresponse.js";
13
14
  export * from "./openrouterdefaulterror.js";
14
15
  export * from "./openroutererror.js";
15
16
  export * from "./payloadtoolargeresponseerror.js";
@@ -0,0 +1,27 @@
1
+ import * as z from "zod/v4";
2
+ import * as models from "../index.js";
3
+ import { OpenRouterError } from "./openroutererror.js";
4
+ /**
5
+ * RFC 6749 §5.2 error response.
6
+ */
7
+ export type OAuthErrorResponseData = {
8
+ error: models.ErrorEnum;
9
+ errorDescription: string;
10
+ };
11
+ /**
12
+ * RFC 6749 §5.2 error response.
13
+ */
14
+ export declare class OAuthErrorResponse extends OpenRouterError {
15
+ error: models.ErrorEnum;
16
+ errorDescription: string;
17
+ /** The original data that was passed to this error instance. */
18
+ data$: OAuthErrorResponseData;
19
+ constructor(err: OAuthErrorResponseData, httpMeta: {
20
+ response: Response;
21
+ request: Request;
22
+ body: string;
23
+ });
24
+ }
25
+ /** @internal */
26
+ export declare const OAuthErrorResponse$inboundSchema: z.ZodType<OAuthErrorResponse, unknown>;
27
+ //# sourceMappingURL=oautherrorresponse.d.ts.map
@@ -0,0 +1,42 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: b0268e4f0a4e
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
+ import { OpenRouterError } from "./openroutererror.js";
9
+ /**
10
+ * RFC 6749 §5.2 error response.
11
+ */
12
+ export class OAuthErrorResponse extends OpenRouterError {
13
+ constructor(err, httpMeta) {
14
+ const message = "message" in err && typeof err.message === "string"
15
+ ? err.message
16
+ : `API error occurred: ${JSON.stringify(err)}`;
17
+ super(message, httpMeta);
18
+ this.data$ = err;
19
+ this.error = err.error;
20
+ this.errorDescription = err.errorDescription;
21
+ this.name = "OAuthErrorResponse";
22
+ }
23
+ }
24
+ /** @internal */
25
+ export const OAuthErrorResponse$inboundSchema = z.object({
26
+ error: models.ErrorEnum$inboundSchema,
27
+ error_description: z.string(),
28
+ request$: z.custom(x => x instanceof Request),
29
+ response$: z.custom(x => x instanceof Response),
30
+ body$: z.string(),
31
+ })
32
+ .transform((v) => {
33
+ const remapped = remap$(v, {
34
+ "error_description": "errorDescription",
35
+ });
36
+ return new OAuthErrorResponse(remapped, {
37
+ request: v.request$,
38
+ response: v.response$,
39
+ body: v.body$,
40
+ });
41
+ });
42
+ //# sourceMappingURL=oautherrorresponse.js.map
@@ -350,6 +350,8 @@ export * from "./multimodalmedia.js";
350
350
  export * from "./namespacefunctiontool.js";
351
351
  export * from "./namespacetool.js";
352
352
  export * from "./notfoundresponseerrordata.js";
353
+ export * from "./oautherrorresponse.js";
354
+ export * from "./oauthjwks.js";
353
355
  export * from "./observabilityarizedestination.js";
354
356
  export * from "./observabilitybraintrustdestination.js";
355
357
  export * from "./observabilityclickhousedestination.js";
@@ -561,6 +563,8 @@ export * from "./taskclassificationresponse.js";
561
563
  export * from "./textdeltaevent.js";
562
564
  export * from "./textdoneevent.js";
563
565
  export * from "./textextendedconfig.js";
566
+ export * from "./tokenexchangerequest.js";
567
+ export * from "./tokenexchangeresponse.js";
564
568
  export * from "./toolcallstatus.js";
565
569
  export * from "./toolchoiceallowed.js";
566
570
  export * from "./toolchoicesupport.js";
@@ -354,6 +354,8 @@ export * from "./multimodalmedia.js";
354
354
  export * from "./namespacefunctiontool.js";
355
355
  export * from "./namespacetool.js";
356
356
  export * from "./notfoundresponseerrordata.js";
357
+ export * from "./oautherrorresponse.js";
358
+ export * from "./oauthjwks.js";
357
359
  export * from "./observabilityarizedestination.js";
358
360
  export * from "./observabilitybraintrustdestination.js";
359
361
  export * from "./observabilityclickhousedestination.js";
@@ -565,6 +567,8 @@ export * from "./taskclassificationresponse.js";
565
567
  export * from "./textdeltaevent.js";
566
568
  export * from "./textdoneevent.js";
567
569
  export * from "./textextendedconfig.js";
570
+ export * from "./tokenexchangerequest.js";
571
+ export * from "./tokenexchangeresponse.js";
568
572
  export * from "./toolcallstatus.js";
569
573
  export * from "./toolchoiceallowed.js";
570
574
  export * from "./toolchoicesupport.js";
@@ -0,0 +1,14 @@
1
+ import * as z from "zod/v4";
2
+ import { OpenEnum } from "../types/enums.js";
3
+ export declare const ErrorEnum: {
4
+ readonly InvalidRequest: "invalid_request";
5
+ readonly InvalidGrant: "invalid_grant";
6
+ readonly UnsupportedGrantType: "unsupported_grant_type";
7
+ readonly InvalidScope: "invalid_scope";
8
+ readonly ServerError: "server_error";
9
+ readonly TemporarilyUnavailable: "temporarily_unavailable";
10
+ };
11
+ export type ErrorEnum = OpenEnum<typeof ErrorEnum>;
12
+ /** @internal */
13
+ export declare const ErrorEnum$inboundSchema: z.ZodType<ErrorEnum, unknown>;
14
+ //# sourceMappingURL=oautherrorresponse.d.ts.map
@@ -0,0 +1,17 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: 2e54250dbb09
4
+ */
5
+ import * as openEnums from "../types/enums.js";
6
+ export const ErrorEnum = {
7
+ InvalidRequest: "invalid_request",
8
+ InvalidGrant: "invalid_grant",
9
+ UnsupportedGrantType: "unsupported_grant_type",
10
+ InvalidScope: "invalid_scope",
11
+ ServerError: "server_error",
12
+ TemporarilyUnavailable: "temporarily_unavailable",
13
+ };
14
+ /** @internal */
15
+ export const ErrorEnum$inboundSchema = openEnums
16
+ .inboundSchema(ErrorEnum);
17
+ //# sourceMappingURL=oautherrorresponse.js.map
@@ -0,0 +1,50 @@
1
+ import * as z from "zod/v4";
2
+ import { ClosedEnum } from "../types/enums.js";
3
+ import { Result as SafeParseResult } from "../types/fp.js";
4
+ import { SDKValidationError } from "./errors/sdkvalidationerror.js";
5
+ export declare const Alg: {
6
+ readonly Es256: "ES256";
7
+ };
8
+ export type Alg = ClosedEnum<typeof Alg>;
9
+ export declare const Crv: {
10
+ readonly P256: "P-256";
11
+ };
12
+ export type Crv = ClosedEnum<typeof Crv>;
13
+ export declare const Kty: {
14
+ readonly Ec: "EC";
15
+ };
16
+ export type Kty = ClosedEnum<typeof Kty>;
17
+ export declare const Use: {
18
+ readonly Sig: "sig";
19
+ };
20
+ export type Use = ClosedEnum<typeof Use>;
21
+ export type Key = {
22
+ alg: Alg;
23
+ crv: Crv;
24
+ kid: string;
25
+ kty: Kty;
26
+ use: Use;
27
+ x: string;
28
+ y: string;
29
+ };
30
+ /**
31
+ * RFC 7517 JWK Set of the keys OpenRouter signs access tokens with.
32
+ */
33
+ export type OAuthJwks = {
34
+ keys: Array<Key>;
35
+ };
36
+ /** @internal */
37
+ export declare const Alg$inboundSchema: z.ZodEnum<typeof Alg>;
38
+ /** @internal */
39
+ export declare const Crv$inboundSchema: z.ZodEnum<typeof Crv>;
40
+ /** @internal */
41
+ export declare const Kty$inboundSchema: z.ZodEnum<typeof Kty>;
42
+ /** @internal */
43
+ export declare const Use$inboundSchema: z.ZodEnum<typeof Use>;
44
+ /** @internal */
45
+ export declare const Key$inboundSchema: z.ZodType<Key, unknown>;
46
+ export declare function keyFromJSON(jsonString: string): SafeParseResult<Key, SDKValidationError>;
47
+ /** @internal */
48
+ export declare const OAuthJwks$inboundSchema: z.ZodType<OAuthJwks, unknown>;
49
+ export declare function oAuthJwksFromJSON(jsonString: string): SafeParseResult<OAuthJwks, SDKValidationError>;
50
+ //# sourceMappingURL=oauthjwks.d.ts.map
@@ -0,0 +1,47 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: fa2c53553900
4
+ */
5
+ import * as z from "zod/v4";
6
+ import { safeParse } from "../lib/schemas.js";
7
+ export const Alg = {
8
+ Es256: "ES256",
9
+ };
10
+ export const Crv = {
11
+ P256: "P-256",
12
+ };
13
+ export const Kty = {
14
+ Ec: "EC",
15
+ };
16
+ export const Use = {
17
+ Sig: "sig",
18
+ };
19
+ /** @internal */
20
+ export const Alg$inboundSchema = z.enum(Alg);
21
+ /** @internal */
22
+ export const Crv$inboundSchema = z.enum(Crv);
23
+ /** @internal */
24
+ export const Kty$inboundSchema = z.enum(Kty);
25
+ /** @internal */
26
+ export const Use$inboundSchema = z.enum(Use);
27
+ /** @internal */
28
+ export const Key$inboundSchema = z.object({
29
+ alg: Alg$inboundSchema,
30
+ crv: Crv$inboundSchema,
31
+ kid: z.string(),
32
+ kty: Kty$inboundSchema,
33
+ use: Use$inboundSchema,
34
+ x: z.string(),
35
+ y: z.string(),
36
+ });
37
+ export function keyFromJSON(jsonString) {
38
+ return safeParse(jsonString, (x) => Key$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Key' from JSON`);
39
+ }
40
+ /** @internal */
41
+ export const OAuthJwks$inboundSchema = z.object({
42
+ keys: z.array(z.lazy(() => Key$inboundSchema)),
43
+ });
44
+ export function oAuthJwksFromJSON(jsonString) {
45
+ return safeParse(jsonString, (x) => OAuthJwks$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'OAuthJwks' from JSON`);
46
+ }
47
+ //# sourceMappingURL=oauthjwks.js.map
@@ -23,6 +23,19 @@ export type CreateKeysGlobals = {
23
23
  */
24
24
  appCategories?: string | undefined;
25
25
  };
26
+ /**
27
+ * Optional partner-defined identity associated with the created API key.
28
+ */
29
+ export type External = {
30
+ /**
31
+ * Optional partner-supplied API key with a minimum length of 32 characters and sufficient entropy. Stored as a SHA-256 hash and never returned.
32
+ */
33
+ apiKey?: string | undefined;
34
+ /**
35
+ * Partner's end-user identifier for attribution.
36
+ */
37
+ user: string;
38
+ };
26
39
  /**
27
40
  * Type of limit reset for the API key (daily, weekly, monthly, or null for no reset). Resets happen automatically at midnight UTC, and weeks are Monday through Sunday.
28
41
  */
@@ -44,6 +57,10 @@ export type CreateKeysRequestBody = {
44
57
  * Optional ISO 8601 UTC expiration timestamp. Must include seconds (YYYY-MM-DDTHH:MM:SSZ; fractional seconds allowed); minute-precision timestamps are rejected.
45
58
  */
46
59
  expiresAt?: Date | null | undefined;
60
+ /**
61
+ * Optional partner-defined identity associated with the created API key.
62
+ */
63
+ external?: External | undefined;
47
64
  /**
48
65
  * Whether to include BYOK usage in the limit
49
66
  */
@@ -194,11 +211,20 @@ export type CreateKeysResponse = {
194
211
  key: string;
195
212
  };
196
213
  /** @internal */
214
+ export type External$Outbound = {
215
+ api_key?: string | undefined;
216
+ user: string;
217
+ };
218
+ /** @internal */
219
+ export declare const External$outboundSchema: z.ZodType<External$Outbound, External>;
220
+ export declare function externalToJSON(external: External): string;
221
+ /** @internal */
197
222
  export declare const CreateKeysLimitReset$outboundSchema: z.ZodType<string, CreateKeysLimitReset>;
198
223
  /** @internal */
199
224
  export type CreateKeysRequestBody$Outbound = {
200
225
  creator_user_id?: string | null | undefined;
201
226
  expires_at?: string | null | undefined;
227
+ external?: External$Outbound | undefined;
202
228
  include_byok_in_limit?: boolean | undefined;
203
229
  limit?: number | null | undefined;
204
230
  limit_reset?: string | null | undefined;
@@ -15,11 +15,25 @@ export const CreateKeysLimitReset = {
15
15
  Monthly: "monthly",
16
16
  };
17
17
  /** @internal */
18
+ export const External$outboundSchema = z
19
+ .object({
20
+ apiKey: z.string().optional(),
21
+ user: z.string(),
22
+ }).transform((v) => {
23
+ return remap$(v, {
24
+ apiKey: "api_key",
25
+ });
26
+ });
27
+ export function externalToJSON(external) {
28
+ return JSON.stringify(External$outboundSchema.parse(external));
29
+ }
30
+ /** @internal */
18
31
  export const CreateKeysLimitReset$outboundSchema = openEnums.outboundSchema(CreateKeysLimitReset);
19
32
  /** @internal */
20
33
  export const CreateKeysRequestBody$outboundSchema = z.object({
21
34
  creatorUserId: z.nullable(z.string()).optional(),
22
35
  expiresAt: z.nullable(z.date().transform(v => v.toISOString())).optional(),
36
+ external: z.lazy(() => External$outboundSchema).optional(),
23
37
  includeByokInLimit: z.boolean().optional(),
24
38
  limit: z.nullable(z.number()).optional(),
25
39
  limitReset: z.nullable(CreateKeysLimitReset$outboundSchema).optional(),
@@ -0,0 +1,56 @@
1
+ import * as z from "zod/v4";
2
+ import * as models from "../index.js";
3
+ export type CreateOauthTokenGlobals = {
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 CreateOauthTokenRequest = {
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
+ tokenExchangeRequest: models.TokenExchangeRequest;
45
+ };
46
+ /** @internal */
47
+ export type CreateOauthTokenRequest$Outbound = {
48
+ "HTTP-Referer"?: string | undefined;
49
+ appTitle?: string | undefined;
50
+ appCategories?: string | undefined;
51
+ TokenExchangeRequest: models.TokenExchangeRequest$Outbound;
52
+ };
53
+ /** @internal */
54
+ export declare const CreateOauthTokenRequest$outboundSchema: z.ZodType<CreateOauthTokenRequest$Outbound, CreateOauthTokenRequest>;
55
+ export declare function createOauthTokenRequestToJSON(createOauthTokenRequest: CreateOauthTokenRequest): string;
56
+ //# sourceMappingURL=createoauthtoken.d.ts.map
@@ -0,0 +1,23 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: 12bca86790cc
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 CreateOauthTokenRequest$outboundSchema = z.object({
10
+ httpReferer: z.string().optional(),
11
+ appTitle: z.string().optional(),
12
+ appCategories: z.string().optional(),
13
+ tokenExchangeRequest: models.TokenExchangeRequest$outboundSchema,
14
+ }).transform((v) => {
15
+ return remap$(v, {
16
+ httpReferer: "HTTP-Referer",
17
+ tokenExchangeRequest: "TokenExchangeRequest",
18
+ });
19
+ });
20
+ export function createOauthTokenRequestToJSON(createOauthTokenRequest) {
21
+ return JSON.stringify(CreateOauthTokenRequest$outboundSchema.parse(createOauthTokenRequest));
22
+ }
23
+ //# sourceMappingURL=createoauthtoken.js.map
@@ -13,6 +13,7 @@ export * from "./createembeddings.js";
13
13
  export * from "./createguardrail.js";
14
14
  export * from "./createimages.js";
15
15
  export * from "./createkeys.js";
16
+ export * from "./createoauthtoken.js";
16
17
  export * from "./createobservabilitydestination.js";
17
18
  export * from "./createpresetschatcompletions.js";
18
19
  export * from "./createpresetsmessages.js";
@@ -74,6 +75,7 @@ export * from "./listkeyassignments.js";
74
75
  export * from "./listmemberassignments.js";
75
76
  export * from "./listmodelscount.js";
76
77
  export * from "./listmodelsuser.js";
78
+ export * from "./listoauthjwks.js";
77
79
  export * from "./listobservabilitydestinations.js";
78
80
  export * from "./listorganizationmembers.js";
79
81
  export * from "./listpresets.js";
@@ -17,6 +17,7 @@ export * from "./createembeddings.js";
17
17
  export * from "./createguardrail.js";
18
18
  export * from "./createimages.js";
19
19
  export * from "./createkeys.js";
20
+ export * from "./createoauthtoken.js";
20
21
  export * from "./createobservabilitydestination.js";
21
22
  export * from "./createpresetschatcompletions.js";
22
23
  export * from "./createpresetsmessages.js";
@@ -78,6 +79,7 @@ export * from "./listkeyassignments.js";
78
79
  export * from "./listmemberassignments.js";
79
80
  export * from "./listmodelscount.js";
80
81
  export * from "./listmodelsuser.js";
82
+ export * from "./listoauthjwks.js";
81
83
  export * from "./listobservabilitydestinations.js";
82
84
  export * from "./listorganizationmembers.js";
83
85
  export * from "./listpresets.js";
@@ -0,0 +1,53 @@
1
+ import * as z from "zod/v4";
2
+ export type ListOauthJwksGlobals = {
3
+ /**
4
+ * The app identifier should be your app's URL and is used as the primary identifier for rankings.
5
+ *
6
+ * @remarks
7
+ * This is used to track API usage per application.
8
+ */
9
+ httpReferer?: string | undefined;
10
+ /**
11
+ * The app display name allows you to customize how your app appears in OpenRouter's dashboard.
12
+ *
13
+ * @remarks
14
+ */
15
+ appTitle?: string | undefined;
16
+ /**
17
+ * Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
18
+ *
19
+ * @remarks
20
+ */
21
+ appCategories?: string | undefined;
22
+ };
23
+ export type ListOauthJwksRequest = {
24
+ /**
25
+ * The app identifier should be your app's URL and is used as the primary identifier for rankings.
26
+ *
27
+ * @remarks
28
+ * This is used to track API usage per application.
29
+ */
30
+ httpReferer?: string | undefined;
31
+ /**
32
+ * The app display name allows you to customize how your app appears in OpenRouter's dashboard.
33
+ *
34
+ * @remarks
35
+ */
36
+ appTitle?: string | undefined;
37
+ /**
38
+ * Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
39
+ *
40
+ * @remarks
41
+ */
42
+ appCategories?: string | undefined;
43
+ };
44
+ /** @internal */
45
+ export type ListOauthJwksRequest$Outbound = {
46
+ "HTTP-Referer"?: string | undefined;
47
+ appTitle?: string | undefined;
48
+ appCategories?: string | undefined;
49
+ };
50
+ /** @internal */
51
+ export declare const ListOauthJwksRequest$outboundSchema: z.ZodType<ListOauthJwksRequest$Outbound, ListOauthJwksRequest>;
52
+ export declare function listOauthJwksRequestToJSON(listOauthJwksRequest: ListOauthJwksRequest): string;
53
+ //# sourceMappingURL=listoauthjwks.d.ts.map
@@ -0,0 +1,20 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: 63db6f2762a2
4
+ */
5
+ import * as z from "zod/v4";
6
+ import { remap as remap$ } from "../../lib/primitives.js";
7
+ /** @internal */
8
+ export const ListOauthJwksRequest$outboundSchema = z.object({
9
+ httpReferer: z.string().optional(),
10
+ appTitle: z.string().optional(),
11
+ appCategories: z.string().optional(),
12
+ }).transform((v) => {
13
+ return remap$(v, {
14
+ httpReferer: "HTTP-Referer",
15
+ });
16
+ });
17
+ export function listOauthJwksRequestToJSON(listOauthJwksRequest) {
18
+ return JSON.stringify(ListOauthJwksRequest$outboundSchema.parse(listOauthJwksRequest));
19
+ }
20
+ //# sourceMappingURL=listoauthjwks.js.map
@@ -0,0 +1,92 @@
1
+ import * as z from "zod/v4";
2
+ import { ClosedEnum } from "../types/enums.js";
3
+ /**
4
+ * Must be `urn:ietf:params:oauth:grant-type:token-exchange`.
5
+ */
6
+ export declare const GrantType: {
7
+ readonly UrnIetfParamsOauthGrantTypeTokenExchange: "urn:ietf:params:oauth:grant-type:token-exchange";
8
+ };
9
+ /**
10
+ * Must be `urn:ietf:params:oauth:grant-type:token-exchange`.
11
+ */
12
+ export type GrantType = ClosedEnum<typeof GrantType>;
13
+ /**
14
+ * Optional; when present must be `urn:ietf:params:oauth:token-type:access_token`.
15
+ */
16
+ export declare const RequestedTokenType: {
17
+ readonly UrnIetfParamsOauthTokenTypeAccessToken: "urn:ietf:params:oauth:token-type:access_token";
18
+ };
19
+ /**
20
+ * Optional; when present must be `urn:ietf:params:oauth:token-type:access_token`.
21
+ */
22
+ export type RequestedTokenType = ClosedEnum<typeof RequestedTokenType>;
23
+ /**
24
+ * Optional; only `inference` is available.
25
+ */
26
+ export declare const Scope: {
27
+ readonly Inference: "inference";
28
+ };
29
+ /**
30
+ * Optional; only `inference` is available.
31
+ */
32
+ export type Scope = ClosedEnum<typeof Scope>;
33
+ /**
34
+ * Must be `urn:ietf:params:oauth:token-type:jwt`.
35
+ */
36
+ export declare const SubjectTokenType: {
37
+ readonly UrnIetfParamsOauthTokenTypeJwt: "urn:ietf:params:oauth:token-type:jwt";
38
+ };
39
+ /**
40
+ * Must be `urn:ietf:params:oauth:token-type:jwt`.
41
+ */
42
+ export type SubjectTokenType = ClosedEnum<typeof SubjectTokenType>;
43
+ /**
44
+ * RFC 8693 token exchange request body (application/x-www-form-urlencoded).
45
+ */
46
+ export type TokenExchangeRequest = {
47
+ /**
48
+ * The federation policy to evaluate, from Settings → Workload identity. Binds the exchange to one organization.
49
+ */
50
+ federationPolicyId: string;
51
+ /**
52
+ * Must be `urn:ietf:params:oauth:grant-type:token-exchange`.
53
+ */
54
+ grantType: GrantType;
55
+ /**
56
+ * Optional; when present must be `urn:ietf:params:oauth:token-type:access_token`.
57
+ */
58
+ requestedTokenType?: RequestedTokenType | undefined;
59
+ /**
60
+ * Optional; only `inference` is available.
61
+ */
62
+ scope?: Scope | undefined;
63
+ /**
64
+ * The JWT issued by your identity provider.
65
+ */
66
+ subjectToken: string;
67
+ /**
68
+ * Must be `urn:ietf:params:oauth:token-type:jwt`.
69
+ */
70
+ subjectTokenType: SubjectTokenType;
71
+ };
72
+ /** @internal */
73
+ export declare const GrantType$outboundSchema: z.ZodEnum<typeof GrantType>;
74
+ /** @internal */
75
+ export declare const RequestedTokenType$outboundSchema: z.ZodEnum<typeof RequestedTokenType>;
76
+ /** @internal */
77
+ export declare const Scope$outboundSchema: z.ZodEnum<typeof Scope>;
78
+ /** @internal */
79
+ export declare const SubjectTokenType$outboundSchema: z.ZodEnum<typeof SubjectTokenType>;
80
+ /** @internal */
81
+ export type TokenExchangeRequest$Outbound = {
82
+ federation_policy_id: string;
83
+ grant_type: string;
84
+ requested_token_type?: string | undefined;
85
+ scope?: string | undefined;
86
+ subject_token: string;
87
+ subject_token_type: string;
88
+ };
89
+ /** @internal */
90
+ export declare const TokenExchangeRequest$outboundSchema: z.ZodType<TokenExchangeRequest$Outbound, TokenExchangeRequest>;
91
+ export declare function tokenExchangeRequestToJSON(tokenExchangeRequest: TokenExchangeRequest): string;
92
+ //# sourceMappingURL=tokenexchangerequest.d.ts.map
@@ -0,0 +1,59 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: 27152e05f952
4
+ */
5
+ import * as z from "zod/v4";
6
+ import { remap as remap$ } from "../lib/primitives.js";
7
+ /**
8
+ * Must be `urn:ietf:params:oauth:grant-type:token-exchange`.
9
+ */
10
+ export const GrantType = {
11
+ UrnIetfParamsOauthGrantTypeTokenExchange: "urn:ietf:params:oauth:grant-type:token-exchange",
12
+ };
13
+ /**
14
+ * Optional; when present must be `urn:ietf:params:oauth:token-type:access_token`.
15
+ */
16
+ export const RequestedTokenType = {
17
+ UrnIetfParamsOauthTokenTypeAccessToken: "urn:ietf:params:oauth:token-type:access_token",
18
+ };
19
+ /**
20
+ * Optional; only `inference` is available.
21
+ */
22
+ export const Scope = {
23
+ Inference: "inference",
24
+ };
25
+ /**
26
+ * Must be `urn:ietf:params:oauth:token-type:jwt`.
27
+ */
28
+ export const SubjectTokenType = {
29
+ UrnIetfParamsOauthTokenTypeJwt: "urn:ietf:params:oauth:token-type:jwt",
30
+ };
31
+ /** @internal */
32
+ export const GrantType$outboundSchema = z.enum(GrantType);
33
+ /** @internal */
34
+ export const RequestedTokenType$outboundSchema = z.enum(RequestedTokenType);
35
+ /** @internal */
36
+ export const Scope$outboundSchema = z.enum(Scope);
37
+ /** @internal */
38
+ export const SubjectTokenType$outboundSchema = z.enum(SubjectTokenType);
39
+ /** @internal */
40
+ export const TokenExchangeRequest$outboundSchema = z.object({
41
+ federationPolicyId: z.string(),
42
+ grantType: GrantType$outboundSchema,
43
+ requestedTokenType: RequestedTokenType$outboundSchema.optional(),
44
+ scope: Scope$outboundSchema.optional(),
45
+ subjectToken: z.string(),
46
+ subjectTokenType: SubjectTokenType$outboundSchema,
47
+ }).transform((v) => {
48
+ return remap$(v, {
49
+ federationPolicyId: "federation_policy_id",
50
+ grantType: "grant_type",
51
+ requestedTokenType: "requested_token_type",
52
+ subjectToken: "subject_token",
53
+ subjectTokenType: "subject_token_type",
54
+ });
55
+ });
56
+ export function tokenExchangeRequestToJSON(tokenExchangeRequest) {
57
+ return JSON.stringify(TokenExchangeRequest$outboundSchema.parse(tokenExchangeRequest));
58
+ }
59
+ //# sourceMappingURL=tokenexchangerequest.js.map
@@ -0,0 +1,36 @@
1
+ import * as z from "zod/v4";
2
+ import { ClosedEnum } from "../types/enums.js";
3
+ import { Result as SafeParseResult } from "../types/fp.js";
4
+ import { SDKValidationError } from "./errors/sdkvalidationerror.js";
5
+ export declare const IssuedTokenType: {
6
+ readonly UrnIetfParamsOauthTokenTypeAccessToken: "urn:ietf:params:oauth:token-type:access_token";
7
+ };
8
+ export type IssuedTokenType = ClosedEnum<typeof IssuedTokenType>;
9
+ export declare const TokenType: {
10
+ readonly Bearer: "Bearer";
11
+ };
12
+ export type TokenType = ClosedEnum<typeof TokenType>;
13
+ /**
14
+ * RFC 8693 token exchange response.
15
+ */
16
+ export type TokenExchangeResponse = {
17
+ /**
18
+ * A short-lived JWT to send as `Authorization: Bearer` to the inference API.
19
+ */
20
+ accessToken: string;
21
+ /**
22
+ * Seconds until the access token expires: at most 15 minutes, and never later than the subject token expires.
23
+ */
24
+ expiresIn: number;
25
+ issuedTokenType: IssuedTokenType;
26
+ scope: string;
27
+ tokenType: TokenType;
28
+ };
29
+ /** @internal */
30
+ export declare const IssuedTokenType$inboundSchema: z.ZodEnum<typeof IssuedTokenType>;
31
+ /** @internal */
32
+ export declare const TokenType$inboundSchema: z.ZodEnum<typeof TokenType>;
33
+ /** @internal */
34
+ export declare const TokenExchangeResponse$inboundSchema: z.ZodType<TokenExchangeResponse, unknown>;
35
+ export declare function tokenExchangeResponseFromJSON(jsonString: string): SafeParseResult<TokenExchangeResponse, SDKValidationError>;
36
+ //# sourceMappingURL=tokenexchangeresponse.d.ts.map
@@ -0,0 +1,36 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: e2774cad9e5e
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
+ export const IssuedTokenType = {
9
+ UrnIetfParamsOauthTokenTypeAccessToken: "urn:ietf:params:oauth:token-type:access_token",
10
+ };
11
+ export const TokenType = {
12
+ Bearer: "Bearer",
13
+ };
14
+ /** @internal */
15
+ export const IssuedTokenType$inboundSchema = z.enum(IssuedTokenType);
16
+ /** @internal */
17
+ export const TokenType$inboundSchema = z.enum(TokenType);
18
+ /** @internal */
19
+ export const TokenExchangeResponse$inboundSchema = z.object({
20
+ access_token: z.string(),
21
+ expires_in: z.int(),
22
+ issued_token_type: IssuedTokenType$inboundSchema,
23
+ scope: z.string(),
24
+ token_type: TokenType$inboundSchema,
25
+ }).transform((v) => {
26
+ return remap$(v, {
27
+ "access_token": "accessToken",
28
+ "expires_in": "expiresIn",
29
+ "issued_token_type": "issuedTokenType",
30
+ "token_type": "tokenType",
31
+ });
32
+ });
33
+ export function tokenExchangeResponseFromJSON(jsonString) {
34
+ return safeParse(jsonString, (x) => TokenExchangeResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TokenExchangeResponse' from JSON`);
35
+ }
36
+ //# sourceMappingURL=tokenexchangeresponse.js.map
@@ -19,14 +19,14 @@ export declare class APIKeys extends ClientSDK {
19
19
  * Create a new API key
20
20
  *
21
21
  * @remarks
22
- * Create a new API key for the authenticated user. The plaintext `key` is returned only in this response. Treat it as a write-only, sensitive value; it cannot be retrieved later. Authenticate with a [management key](/docs/guides/overview/auth/management-api-keys), or with a Connect client secret.
22
+ * Create a new API key for the authenticated user. The plaintext `key` is returned only in this response. Treat it as a write-only, sensitive value; it cannot be retrieved later. Authenticate with a [management key](/docs/guides/overview/auth/management-api-keys). The optional `external` object associates the key with a partner-defined user and lookup key.
23
23
  */
24
24
  create(request: operations.CreateKeysRequest, options?: RequestOptions): Promise<operations.CreateKeysResponse>;
25
25
  /**
26
26
  * Delete an API key
27
27
  *
28
28
  * @remarks
29
- * Delete an existing API key. Authenticate with a [management key](/docs/guides/overview/auth/management-api-keys), or with a Connect client secret. A client secret reaches only the keys that same client created; any other key responds as if it does not exist.
29
+ * Delete an existing API key. Authenticate with a [management key](/docs/guides/overview/auth/management-api-keys).
30
30
  */
31
31
  delete(request: operations.DeleteKeysRequest, options?: RequestOptions): Promise<operations.DeleteKeysResponse>;
32
32
  /**
@@ -40,7 +40,7 @@ export declare class APIKeys extends ClientSDK {
40
40
  * Update an API key
41
41
  *
42
42
  * @remarks
43
- * Update an existing API key. Authenticate with a [management key](/docs/guides/overview/auth/management-api-keys), or with a Connect client secret. A client secret reaches only the keys that same client created; any other key responds as if it does not exist.
43
+ * Update an existing API key. Authenticate with a [management key](/docs/guides/overview/auth/management-api-keys).
44
44
  */
45
45
  update(request: operations.UpdateKeysRequest, options?: RequestOptions): Promise<operations.UpdateKeysResponse>;
46
46
  }
@@ -33,7 +33,7 @@ export class APIKeys extends ClientSDK {
33
33
  * Create a new API key
34
34
  *
35
35
  * @remarks
36
- * Create a new API key for the authenticated user. The plaintext `key` is returned only in this response. Treat it as a write-only, sensitive value; it cannot be retrieved later. Authenticate with a [management key](/docs/guides/overview/auth/management-api-keys), or with a Connect client secret.
36
+ * Create a new API key for the authenticated user. The plaintext `key` is returned only in this response. Treat it as a write-only, sensitive value; it cannot be retrieved later. Authenticate with a [management key](/docs/guides/overview/auth/management-api-keys). The optional `external` object associates the key with a partner-defined user and lookup key.
37
37
  */
38
38
  async create(request, options) {
39
39
  return unwrapAsync(apiKeysCreate(this, request, options));
@@ -42,7 +42,7 @@ export class APIKeys extends ClientSDK {
42
42
  * Delete an API key
43
43
  *
44
44
  * @remarks
45
- * Delete an existing API key. Authenticate with a [management key](/docs/guides/overview/auth/management-api-keys), or with a Connect client secret. A client secret reaches only the keys that same client created; any other key responds as if it does not exist.
45
+ * Delete an existing API key. Authenticate with a [management key](/docs/guides/overview/auth/management-api-keys).
46
46
  */
47
47
  async delete(request, options) {
48
48
  return unwrapAsync(apiKeysDelete(this, request, options));
@@ -60,7 +60,7 @@ export class APIKeys extends ClientSDK {
60
60
  * Update an API key
61
61
  *
62
62
  * @remarks
63
- * Update an existing API key. Authenticate with a [management key](/docs/guides/overview/auth/management-api-keys), or with a Connect client secret. A client secret reaches only the keys that same client created; any other key responds as if it does not exist.
63
+ * Update an existing API key. Authenticate with a [management key](/docs/guides/overview/auth/management-api-keys).
64
64
  */
65
65
  async update(request, options) {
66
66
  return unwrapAsync(apiKeysUpdate(this, request, options));
@@ -1,4 +1,5 @@
1
1
  import { ClientSDK, RequestOptions } from "../lib/sdks.js";
2
+ import * as models from "../models/index.js";
2
3
  import * as operations from "../models/operations/index.js";
3
4
  import type { CreateAuthorizationUrlRequest } from "../funcs/oAuthCreateAuthorizationUrl.js";
4
5
  import type { CreateSHA256CodeChallengeResponse } from "../funcs/oAuthCreateSHA256CodeChallenge.js";
@@ -42,5 +43,19 @@ export declare class OAuth extends ClientSDK {
42
43
  * Create an authorization code for the PKCE flow to generate a user-controlled API key
43
44
  */
44
45
  createAuthCode(request: operations.CreateAuthKeysCodeRequest, options?: RequestOptions): Promise<operations.CreateAuthKeysCodeResponse>;
46
+ /**
47
+ * OpenRouter access token signing keys
48
+ *
49
+ * @remarks
50
+ * RFC 7517 JWK Set containing the public keys OpenRouter signs access tokens with.
51
+ */
52
+ listOauthJwks(request?: operations.ListOauthJwksRequest | undefined, options?: RequestOptions): Promise<models.OAuthJwks>;
53
+ /**
54
+ * Exchange a workload identity token
55
+ *
56
+ * @remarks
57
+ * RFC 8693 token exchange. Presents a JWT from an issuer your organization trusts (Settings → Workload identity) and receives a short-lived OpenRouter access token that acts as the API key the matching federation policy targets.
58
+ */
59
+ createOauthToken(request: operations.CreateOauthTokenRequest, options?: RequestOptions): Promise<models.TokenExchangeResponse>;
45
60
  }
46
61
  //# sourceMappingURL=oauth.d.ts.map
package/esm/sdk/oauth.js CHANGED
@@ -3,7 +3,9 @@
3
3
  * @generated-id: 37b7f9b2970b
4
4
  */
5
5
  import { oAuthCreateAuthCode } from "../funcs/oAuthCreateAuthCode.js";
6
+ import { oAuthCreateOauthToken } from "../funcs/oAuthCreateOauthToken.js";
6
7
  import { oAuthExchangeAuthCodeForAPIKey } from "../funcs/oAuthExchangeAuthCodeForAPIKey.js";
8
+ import { oAuthListOauthJwks } from "../funcs/oAuthListOauthJwks.js";
7
9
  import { ClientSDK } from "../lib/sdks.js";
8
10
  import { unwrapAsync } from "../types/fp.js";
9
11
  import { oAuthCreateAuthorizationUrl } from "../funcs/oAuthCreateAuthorizationUrl.js";
@@ -63,5 +65,23 @@ export class OAuth extends ClientSDK {
63
65
  async createAuthCode(request, options) {
64
66
  return unwrapAsync(oAuthCreateAuthCode(this, request, options));
65
67
  }
68
+ /**
69
+ * OpenRouter access token signing keys
70
+ *
71
+ * @remarks
72
+ * RFC 7517 JWK Set containing the public keys OpenRouter signs access tokens with.
73
+ */
74
+ async listOauthJwks(request, options) {
75
+ return unwrapAsync(oAuthListOauthJwks(this, request, options));
76
+ }
77
+ /**
78
+ * Exchange a workload identity token
79
+ *
80
+ * @remarks
81
+ * RFC 8693 token exchange. Presents a JWT from an issuer your organization trusts (Settings → Workload identity) and receives a short-lived OpenRouter access token that acts as the API key the matching federation policy targets.
82
+ */
83
+ async createOauthToken(request, options) {
84
+ return unwrapAsync(oAuthCreateOauthToken(this, request, options));
85
+ }
66
86
  }
67
87
  //# sourceMappingURL=oauth.js.map
package/jsr.json CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  {
4
4
  "name": "@openrouter/sdk",
5
- "version": "1.2.98",
5
+ "version": "1.2.100",
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.98",
3
+ "version": "1.2.100",
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": [
@@ -21,8 +21,8 @@
21
21
  "license": "Apache-2.0",
22
22
  "packageManager": "pnpm@10.22.0",
23
23
  "publishConfig": {
24
- "provenance": true,
25
- "access": "public"
24
+ "access": "public",
25
+ "provenance": true
26
26
  },
27
27
  "type": "module",
28
28
  "main": "./esm/index.js",
@@ -73,15 +73,15 @@
73
73
  "lint": "eslint --cache --max-warnings=0 src",
74
74
  "build": "tsc",
75
75
  "prepublishOnly": "npm run build",
76
+ "prepare": "npm run build",
76
77
  "test": "vitest --run --project unit",
77
- "test:e2e": "vitest --run --project e2e",
78
78
  "typecheck": "tsc --noEmit",
79
79
  "typecheck:transit": "exit 0",
80
80
  "compile": "tsc",
81
- "postinstall": "node scripts/check-types.js || true",
81
+ "test:e2e": "vitest --run --project e2e",
82
82
  "test:transit": "exit 0",
83
83
  "test:watch": "vitest --watch --project unit",
84
- "prepare": "npm run build"
84
+ "postinstall": "node scripts/check-types.js || true"
85
85
  },
86
86
  "peerDependencies": {},
87
87
  "devDependencies": {