@openrouter/sdk 0.12.15 → 0.12.16

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.
@@ -14,5 +14,5 @@ import { Result } from "../types/fp.js";
14
14
  * @remarks
15
15
  * Create a new API key for the authenticated user. [Management key](/docs/guides/overview/auth/management-api-keys) required.
16
16
  */
17
- export declare function apiKeysCreate(client: OpenRouterCore, request: operations.CreateKeysRequest, options?: RequestOptions): APIPromise<Result<operations.CreateKeysResponse, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.TooManyRequestsResponseError | errors.InternalServerResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
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
@@ -76,7 +76,7 @@ async function $do(client, request, options) {
76
76
  const req = requestRes.value;
77
77
  const doResult = await client._do(req, {
78
78
  context,
79
- errorCodes: ["400", "401", "429", "4XX", "500", "5XX"],
79
+ errorCodes: ["400", "401", "403", "429", "4XX", "500", "5XX"],
80
80
  retryConfig: context.retryConfig,
81
81
  retryCodes: context.retryCodes,
82
82
  });
@@ -87,7 +87,7 @@ async function $do(client, request, options) {
87
87
  const responseFields = {
88
88
  HttpMeta: { Response: response, Request: req },
89
89
  };
90
- const [result] = await M.match(M.json(201, operations.CreateKeysResponse$inboundSchema), M.jsonErr(400, errors.BadRequestResponseError$inboundSchema), M.jsonErr(401, errors.UnauthorizedResponseError$inboundSchema), M.jsonErr(429, errors.TooManyRequestsResponseError$inboundSchema), M.jsonErr(500, errors.InternalServerResponseError$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
90
+ const [result] = await M.match(M.json(201, operations.CreateKeysResponse$inboundSchema), M.jsonErr(400, errors.BadRequestResponseError$inboundSchema), M.jsonErr(401, errors.UnauthorizedResponseError$inboundSchema), M.jsonErr(403, errors.ForbiddenResponseError$inboundSchema), M.jsonErr(429, errors.TooManyRequestsResponseError$inboundSchema), M.jsonErr(500, errors.InternalServerResponseError$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
91
91
  if (!result.ok) {
92
92
  return [result, { status: "complete", request: req, response }];
93
93
  }
@@ -15,5 +15,5 @@ import { Result } from "../types/fp.js";
15
15
  * @remarks
16
16
  * Create a new guardrail for the authenticated user. [Management key](/docs/guides/overview/auth/management-api-keys) required.
17
17
  */
18
- export declare function guardrailsCreate(client: OpenRouterCore, request: operations.CreateGuardrailRequest, options?: RequestOptions): APIPromise<Result<models.CreateGuardrailResponse, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.InternalServerResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
18
+ export declare function guardrailsCreate(client: OpenRouterCore, request: operations.CreateGuardrailRequest, options?: RequestOptions): APIPromise<Result<models.CreateGuardrailResponse, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.ForbiddenResponseError | errors.InternalServerResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
19
19
  //# sourceMappingURL=guardrailsCreate.d.ts.map
@@ -79,7 +79,7 @@ async function $do(client, request, options) {
79
79
  const req = requestRes.value;
80
80
  const doResult = await client._do(req, {
81
81
  context,
82
- errorCodes: ["400", "401", "4XX", "500", "5XX"],
82
+ errorCodes: ["400", "401", "403", "4XX", "500", "5XX"],
83
83
  retryConfig: context.retryConfig,
84
84
  retryCodes: context.retryCodes,
85
85
  });
@@ -90,7 +90,7 @@ async function $do(client, request, options) {
90
90
  const responseFields = {
91
91
  HttpMeta: { Response: response, Request: req },
92
92
  };
93
- const [result] = await M.match(M.json(201, models.CreateGuardrailResponse$inboundSchema), M.jsonErr(400, errors.BadRequestResponseError$inboundSchema), M.jsonErr(401, errors.UnauthorizedResponseError$inboundSchema), M.jsonErr(500, errors.InternalServerResponseError$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
93
+ const [result] = await M.match(M.json(201, models.CreateGuardrailResponse$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
94
  if (!result.ok) {
95
95
  return [result, { status: "complete", request: req, response }];
96
96
  }
@@ -33,6 +33,7 @@ async function $do(client, request, options) {
33
33
  const query = encodeFormQuery({
34
34
  "limit": payload?.limit,
35
35
  "offset": payload?.offset,
36
+ "workspace_id": payload?.workspace_id,
36
37
  });
37
38
  const headers = new Headers(compactMap({
38
39
  Accept: "application/json",
@@ -0,0 +1,18 @@
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
+ /**
12
+ * Create speech
13
+ *
14
+ * @remarks
15
+ * Synthesizes audio from the input text
16
+ */
17
+ export declare function ttsCreateSpeech(client: OpenRouterCore, request: operations.CreateTtsRequest, options?: RequestOptions): APIPromise<Result<ReadableStream<Uint8Array>, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.PaymentRequiredResponseError | errors.NotFoundResponseError | errors.TooManyRequestsResponseError | errors.InternalServerResponseError | errors.BadGatewayResponseError | errors.ServiceUnavailableResponseError | errors.EdgeNetworkTimeoutResponseError | errors.ProviderOverloadedResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
18
+ //# sourceMappingURL=ttsCreateSpeech.d.ts.map
@@ -0,0 +1,110 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: ed304f5d6ad8
4
+ */
5
+ import * as z from "zod/v4";
6
+ import { encodeJSON, 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
+ /**
16
+ * Create speech
17
+ *
18
+ * @remarks
19
+ * Synthesizes audio from the input text
20
+ */
21
+ export function ttsCreateSpeech(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.CreateTtsRequest$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.RequestBody, { explode: true });
31
+ const path = pathToFunc("/tts")();
32
+ const headers = new Headers(compactMap({
33
+ "Content-Type": "application/json",
34
+ Accept: "application/octet-stream",
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: "createTts",
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: "POST",
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
+ errorCodes: [
81
+ "400",
82
+ "401",
83
+ "402",
84
+ "404",
85
+ "429",
86
+ "4XX",
87
+ "500",
88
+ "502",
89
+ "503",
90
+ "524",
91
+ "529",
92
+ "5XX",
93
+ ],
94
+ retryConfig: context.retryConfig,
95
+ retryCodes: context.retryCodes,
96
+ });
97
+ if (!doResult.ok) {
98
+ return [doResult, { status: "request-error", request: req }];
99
+ }
100
+ const response = doResult.value;
101
+ const responseFields = {
102
+ HttpMeta: { Response: response, Request: req },
103
+ };
104
+ const [result] = await M.match(M.stream(200, z.custom(x => x instanceof ReadableStream)), M.jsonErr(400, errors.BadRequestResponseError$inboundSchema), M.jsonErr(401, errors.UnauthorizedResponseError$inboundSchema), M.jsonErr(402, errors.PaymentRequiredResponseError$inboundSchema), M.jsonErr(404, errors.NotFoundResponseError$inboundSchema), M.jsonErr(429, errors.TooManyRequestsResponseError$inboundSchema), M.jsonErr(500, errors.InternalServerResponseError$inboundSchema), M.jsonErr(502, errors.BadGatewayResponseError$inboundSchema), M.jsonErr(503, errors.ServiceUnavailableResponseError$inboundSchema), M.jsonErr(524, errors.EdgeNetworkTimeoutResponseError$inboundSchema), M.jsonErr(529, errors.ProviderOverloadedResponseError$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
105
+ if (!result.ok) {
106
+ return [result, { status: "complete", request: req, response }];
107
+ }
108
+ return [result, { status: "complete", request: req, response }];
109
+ }
110
+ //# sourceMappingURL=ttsCreateSpeech.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.16";
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.16 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.16",
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.16 2.879.1 1.0.0 @openrouter/sdk",
32
32
  };
33
33
  //# sourceMappingURL=config.js.map
@@ -37,6 +37,10 @@ export type CreateGuardrailRequest = {
37
37
  * Interval at which the limit resets (daily, weekly, monthly)
38
38
  */
39
39
  resetInterval?: GuardrailInterval | null | undefined;
40
+ /**
41
+ * The workspace to create the guardrail in. Defaults to the default workspace if not provided.
42
+ */
43
+ workspaceId?: string | undefined;
40
44
  };
41
45
  /** @internal */
42
46
  export type CreateGuardrailRequest$Outbound = {
@@ -49,6 +53,7 @@ export type CreateGuardrailRequest$Outbound = {
49
53
  limit_usd?: number | null | undefined;
50
54
  name: string;
51
55
  reset_interval?: string | null | undefined;
56
+ workspace_id?: string | undefined;
52
57
  };
53
58
  /** @internal */
54
59
  export declare const CreateGuardrailRequest$outboundSchema: z.ZodType<CreateGuardrailRequest$Outbound, CreateGuardrailRequest>;
@@ -16,6 +16,7 @@ export const CreateGuardrailRequest$outboundSchema = z.object({
16
16
  limitUsd: z.nullable(z.number()).optional(),
17
17
  name: z.string(),
18
18
  resetInterval: z.nullable(GuardrailInterval$outboundSchema).optional(),
19
+ workspaceId: z.string().optional(),
19
20
  }).transform((v) => {
20
21
  return remap$(v, {
21
22
  allowedModels: "allowed_models",
@@ -25,6 +26,7 @@ export const CreateGuardrailRequest$outboundSchema = z.object({
25
26
  ignoredProviders: "ignored_providers",
26
27
  limitUsd: "limit_usd",
27
28
  resetInterval: "reset_interval",
29
+ workspaceId: "workspace_id",
28
30
  });
29
31
  });
30
32
  export function createGuardrailRequestToJSON(createGuardrailRequest) {
@@ -51,6 +51,10 @@ export type Guardrail = {
51
51
  * ISO 8601 timestamp of when the guardrail was last updated
52
52
  */
53
53
  updatedAt?: string | null | undefined;
54
+ /**
55
+ * The workspace ID this guardrail belongs to.
56
+ */
57
+ workspaceId: string;
54
58
  };
55
59
  /** @internal */
56
60
  export declare const Guardrail$inboundSchema: z.ZodType<Guardrail, unknown>;
@@ -20,6 +20,7 @@ export const Guardrail$inboundSchema = z.object({
20
20
  name: z.string(),
21
21
  reset_interval: z.nullable(GuardrailInterval$inboundSchema).optional(),
22
22
  updated_at: z.nullable(z.string()).optional(),
23
+ workspace_id: z.string(),
23
24
  }).transform((v) => {
24
25
  return remap$(v, {
25
26
  "allowed_models": "allowedModels",
@@ -31,6 +32,7 @@ export const Guardrail$inboundSchema = z.object({
31
32
  "limit_usd": "limitUsd",
32
33
  "reset_interval": "resetInterval",
33
34
  "updated_at": "updatedAt",
35
+ "workspace_id": "workspaceId",
34
36
  });
35
37
  });
36
38
  export function guardrailFromJSON(jsonString) {
@@ -60,6 +60,10 @@ export type CreateKeysRequestBody = {
60
60
  * Name for the new API key
61
61
  */
62
62
  name: string;
63
+ /**
64
+ * The workspace to create the API key in. Defaults to the default workspace if not provided.
65
+ */
66
+ workspaceId?: string | undefined;
63
67
  };
64
68
  export type CreateKeysRequest = {
65
69
  /**
@@ -195,6 +199,7 @@ export type CreateKeysRequestBody$Outbound = {
195
199
  limit?: number | null | undefined;
196
200
  limit_reset?: string | null | undefined;
197
201
  name: string;
202
+ workspace_id?: string | undefined;
198
203
  };
199
204
  /** @internal */
200
205
  export declare const CreateKeysRequestBody$outboundSchema: z.ZodType<CreateKeysRequestBody$Outbound, CreateKeysRequestBody>;
@@ -24,12 +24,14 @@ export const CreateKeysRequestBody$outboundSchema = z.object({
24
24
  limit: z.nullable(z.number()).optional(),
25
25
  limitReset: z.nullable(CreateKeysLimitReset$outboundSchema).optional(),
26
26
  name: z.string(),
27
+ workspaceId: z.string().optional(),
27
28
  }).transform((v) => {
28
29
  return remap$(v, {
29
30
  creatorUserId: "creator_user_id",
30
31
  expiresAt: "expires_at",
31
32
  includeByokInLimit: "include_byok_in_limit",
32
33
  limitReset: "limit_reset",
34
+ workspaceId: "workspace_id",
33
35
  });
34
36
  });
35
37
  export function createKeysRequestBodyToJSON(createKeysRequestBody) {