@openrouter/sdk 1.5.58 → 1.5.60
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.
- package/README.md +13 -11
- package/esm/funcs/apiKeysList.d.ts +4 -1
- package/esm/funcs/apiKeysList.js +32 -6
- package/esm/funcs/guardrailPoliciesChangeApiKeyPolicyAssignment.d.ts +19 -0
- package/esm/funcs/guardrailPoliciesChangeApiKeyPolicyAssignment.js +104 -0
- package/esm/funcs/guardrailPoliciesChangeMemberPolicyAssignment.d.ts +19 -0
- package/esm/funcs/guardrailPoliciesChangeMemberPolicyAssignment.js +104 -0
- package/esm/funcs/guardrailPoliciesCreateAccountPolicy.d.ts +19 -0
- package/esm/funcs/guardrailPoliciesCreateAccountPolicy.js +100 -0
- package/esm/funcs/guardrailPoliciesCreateBudgetPolicy.d.ts +19 -0
- package/esm/funcs/guardrailPoliciesCreateBudgetPolicy.js +100 -0
- package/esm/funcs/guardrailPoliciesCreateModelAvailabilityPolicy.d.ts +19 -0
- package/esm/funcs/guardrailPoliciesCreateModelAvailabilityPolicy.js +98 -0
- package/esm/funcs/guardrailPoliciesCreateModerationPolicy.d.ts +19 -0
- package/esm/funcs/guardrailPoliciesCreateModerationPolicy.js +98 -0
- package/esm/funcs/guardrailPoliciesDeleteAccountPolicy.d.ts +19 -0
- package/esm/funcs/guardrailPoliciesDeleteAccountPolicy.js +103 -0
- package/esm/funcs/guardrailPoliciesDeleteBudgetPolicy.d.ts +19 -0
- package/esm/funcs/guardrailPoliciesDeleteBudgetPolicy.js +107 -0
- package/esm/funcs/guardrailPoliciesDeleteModelAvailabilityPolicy.d.ts +19 -0
- package/esm/funcs/guardrailPoliciesDeleteModelAvailabilityPolicy.js +107 -0
- package/esm/funcs/guardrailPoliciesDeleteModerationPolicy.d.ts +19 -0
- package/esm/funcs/guardrailPoliciesDeleteModerationPolicy.js +107 -0
- package/esm/funcs/guardrailPoliciesGetApiKeyPolicyAssignment.d.ts +19 -0
- package/esm/funcs/guardrailPoliciesGetApiKeyPolicyAssignment.js +108 -0
- package/esm/funcs/guardrailPoliciesGetBudgetPolicy.d.ts +19 -0
- package/esm/funcs/guardrailPoliciesGetBudgetPolicy.js +107 -0
- package/esm/funcs/guardrailPoliciesGetMemberPolicyAssignment.d.ts +19 -0
- package/esm/funcs/guardrailPoliciesGetMemberPolicyAssignment.js +108 -0
- package/esm/funcs/guardrailPoliciesGetModelAvailabilityPolicy.d.ts +19 -0
- package/esm/funcs/guardrailPoliciesGetModelAvailabilityPolicy.js +107 -0
- package/esm/funcs/guardrailPoliciesGetModerationPolicy.d.ts +19 -0
- package/esm/funcs/guardrailPoliciesGetModerationPolicy.js +107 -0
- package/esm/funcs/guardrailPoliciesListAccountPolicies.d.ts +21 -0
- package/esm/funcs/guardrailPoliciesListAccountPolicies.js +133 -0
- package/esm/funcs/guardrailPoliciesListBudgetPolicies.d.ts +21 -0
- package/esm/funcs/guardrailPoliciesListBudgetPolicies.js +134 -0
- package/esm/funcs/guardrailPoliciesListModelAvailabilityPolicies.d.ts +21 -0
- package/esm/funcs/guardrailPoliciesListModelAvailabilityPolicies.js +132 -0
- package/esm/funcs/guardrailPoliciesListModerationPolicies.d.ts +21 -0
- package/esm/funcs/guardrailPoliciesListModerationPolicies.js +134 -0
- package/esm/funcs/guardrailPoliciesUpdateAccountPolicy.d.ts +19 -0
- package/esm/funcs/guardrailPoliciesUpdateAccountPolicy.js +106 -0
- package/esm/funcs/guardrailPoliciesUpdateBudgetPolicy.d.ts +19 -0
- package/esm/funcs/guardrailPoliciesUpdateBudgetPolicy.js +106 -0
- package/esm/funcs/guardrailPoliciesUpdateModelAvailabilityPolicy.d.ts +19 -0
- package/esm/funcs/guardrailPoliciesUpdateModelAvailabilityPolicy.js +104 -0
- package/esm/funcs/guardrailPoliciesUpdateModerationPolicy.d.ts +19 -0
- package/esm/funcs/guardrailPoliciesUpdateModerationPolicy.js +104 -0
- package/esm/hooks/registration.d.ts +1 -1
- package/esm/hooks/registration.js +8 -1
- package/esm/hooks/signal-hooks.d.ts +42 -0
- package/esm/hooks/signal-hooks.js +236 -0
- package/esm/lib/config.d.ts +2 -2
- package/esm/lib/config.js +2 -2
- package/esm/models/accountguardrailpolicy.d.ts +12 -0
- package/esm/models/accountguardrailpolicy.js +19 -0
- package/esm/models/accountguardrailpolicyrequest.d.ts +11 -0
- package/esm/models/accountguardrailpolicyrequest.js +18 -0
- package/esm/models/accountguardrailpolicyresponse.d.ts +11 -0
- package/esm/models/accountguardrailpolicyresponse.js +15 -0
- package/esm/models/armorautomode.d.ts +17 -0
- package/esm/models/armorautomode.js +51 -2
- package/esm/models/armorcontext.d.ts +5 -0
- package/esm/models/armorcontext.js +14 -1
- package/esm/models/armorenvironmententry.d.ts +5 -0
- package/esm/models/armorenvironmententry.js +9 -0
- package/esm/models/armorplugin.d.ts +4 -4
- package/esm/models/armorplugin.js +3 -4
- package/esm/models/armorrule.d.ts +5 -0
- package/esm/models/armorrule.js +11 -0
- package/esm/models/budgetaccountguardrailpolicy.d.ts +34 -0
- package/esm/models/budgetaccountguardrailpolicy.js +39 -0
- package/esm/models/budgetaccountguardrailpolicyrequest.d.ts +68 -0
- package/esm/models/budgetaccountguardrailpolicyrequest.js +46 -0
- package/esm/models/budgetguardrailpolicy.d.ts +27 -0
- package/esm/models/budgetguardrailpolicy.js +28 -0
- package/esm/models/budgetguardrailpolicydetail.d.ts +74 -0
- package/esm/models/budgetguardrailpolicydetail.js +58 -0
- package/esm/models/budgetguardrailpolicydetailresponse.d.ts +11 -0
- package/esm/models/budgetguardrailpolicydetailresponse.js +15 -0
- package/esm/models/budgetguardrailpolicyresponse.d.ts +11 -0
- package/esm/models/budgetguardrailpolicyresponse.js +15 -0
- package/esm/models/budgetguardrailpolicysummary.d.ts +43 -0
- package/esm/models/budgetguardrailpolicysummary.js +42 -0
- package/esm/models/changeguardrailpolicyassignmentrequest.d.ts +49 -0
- package/esm/models/changeguardrailpolicyassignmentrequest.js +38 -0
- package/esm/models/changeguardrailpolicyassignmentresponse.d.ts +13 -0
- package/esm/models/changeguardrailpolicyassignmentresponse.js +14 -0
- package/esm/models/chatrequest.d.ts +5 -0
- package/esm/models/chatrequest.js +5 -0
- package/esm/models/createbudgetguardrailpolicyrequest.d.ts +57 -0
- package/esm/models/createbudgetguardrailpolicyrequest.js +38 -0
- package/esm/models/createmodelavailabilityguardrailpolicyrequest.d.ts +57 -0
- package/esm/models/createmodelavailabilityguardrailpolicyrequest.js +39 -0
- package/esm/models/createmoderationguardrailpolicyrequest.d.ts +57 -0
- package/esm/models/createmoderationguardrailpolicyrequest.js +38 -0
- package/esm/models/deleteguardrailpolicyresponse.d.ts +13 -0
- package/esm/models/deleteguardrailpolicyresponse.js +14 -0
- package/esm/models/guardrailbudgetpolicyauthoringconfig.d.ts +25 -0
- package/esm/models/guardrailbudgetpolicyauthoringconfig.js +30 -0
- package/esm/models/guardrailbudgetpolicyconfig.d.ts +22 -0
- package/esm/models/guardrailbudgetpolicyconfig.js +24 -0
- package/esm/models/guardrailmodelavailabilitypolicyauthoringconfig.d.ts +52 -0
- package/esm/models/guardrailmodelavailabilitypolicyauthoringconfig.js +58 -0
- package/esm/models/guardrailmodelavailabilitypolicyconfig.d.ts +30 -0
- package/esm/models/guardrailmodelavailabilitypolicyconfig.js +59 -0
- package/esm/models/guardrailmoderationpolicyconfig.d.ts +240 -0
- package/esm/models/guardrailmoderationpolicyconfig.js +289 -0
- package/esm/models/guardrailpolicyassignmentresponse.d.ts +11 -0
- package/esm/models/guardrailpolicyassignmentresponse.js +15 -0
- package/esm/models/guardrailpolicyassignmentstate.d.ts +30 -0
- package/esm/models/guardrailpolicyassignmentstate.js +38 -0
- package/esm/models/index.d.ts +44 -0
- package/esm/models/index.js +44 -0
- package/esm/models/listaccountguardrailpoliciesresponse.d.ts +15 -0
- package/esm/models/listaccountguardrailpoliciesresponse.js +21 -0
- package/esm/models/listbudgetguardrailpoliciesresponse.d.ts +15 -0
- package/esm/models/listbudgetguardrailpoliciesresponse.js +21 -0
- package/esm/models/listmodelavailabilityguardrailpoliciesresponse.d.ts +15 -0
- package/esm/models/listmodelavailabilityguardrailpoliciesresponse.js +21 -0
- package/esm/models/listmoderationguardrailpoliciesresponse.d.ts +15 -0
- package/esm/models/listmoderationguardrailpoliciesresponse.js +21 -0
- package/esm/models/modelavailabilityaccountguardrailpolicy.d.ts +34 -0
- package/esm/models/modelavailabilityaccountguardrailpolicy.js +39 -0
- package/esm/models/modelavailabilityaccountguardrailpolicyrequest.d.ts +68 -0
- package/esm/models/modelavailabilityaccountguardrailpolicyrequest.js +47 -0
- package/esm/models/modelavailabilityguardrailpolicy.d.ts +27 -0
- package/esm/models/modelavailabilityguardrailpolicy.js +28 -0
- package/esm/models/modelavailabilityguardrailpolicydetail.d.ts +74 -0
- package/esm/models/modelavailabilityguardrailpolicydetail.js +57 -0
- package/esm/models/modelavailabilityguardrailpolicydetailresponse.d.ts +11 -0
- package/esm/models/modelavailabilityguardrailpolicydetailresponse.js +15 -0
- package/esm/models/modelavailabilityguardrailpolicyresponse.d.ts +11 -0
- package/esm/models/modelavailabilityguardrailpolicyresponse.js +15 -0
- package/esm/models/modelavailabilityguardrailpolicysummary.d.ts +43 -0
- package/esm/models/modelavailabilityguardrailpolicysummary.js +42 -0
- package/esm/models/moderationaccountguardrailpolicy.d.ts +34 -0
- package/esm/models/moderationaccountguardrailpolicy.js +39 -0
- package/esm/models/moderationaccountguardrailpolicyrequest.d.ts +68 -0
- package/esm/models/moderationaccountguardrailpolicyrequest.js +47 -0
- package/esm/models/moderationguardrailpolicy.d.ts +27 -0
- package/esm/models/moderationguardrailpolicy.js +28 -0
- package/esm/models/moderationguardrailpolicydetail.d.ts +78 -0
- package/esm/models/moderationguardrailpolicydetail.js +60 -0
- package/esm/models/moderationguardrailpolicydetailresponse.d.ts +11 -0
- package/esm/models/moderationguardrailpolicydetailresponse.js +15 -0
- package/esm/models/moderationguardrailpolicyresponse.d.ts +11 -0
- package/esm/models/moderationguardrailpolicyresponse.js +15 -0
- package/esm/models/moderationguardrailpolicysummary.d.ts +43 -0
- package/esm/models/moderationguardrailpolicysummary.js +42 -0
- package/esm/models/operations/changeapikeypolicyassignment.d.ts +61 -0
- package/esm/models/operations/changeapikeypolicyassignment.js +24 -0
- package/esm/models/operations/changememberpolicyassignment.d.ts +61 -0
- package/esm/models/operations/changememberpolicyassignment.js +25 -0
- package/esm/models/operations/createaccountpolicy.d.ts +56 -0
- package/esm/models/operations/createaccountpolicy.js +23 -0
- package/esm/models/operations/createbudgetpolicy.d.ts +56 -0
- package/esm/models/operations/createbudgetpolicy.js +23 -0
- package/esm/models/operations/createmodelavailabilitypolicy.d.ts +56 -0
- package/esm/models/operations/createmodelavailabilitypolicy.js +23 -0
- package/esm/models/operations/createmoderationpolicy.d.ts +56 -0
- package/esm/models/operations/createmoderationpolicy.js +23 -0
- package/esm/models/operations/deleteaccountpolicy.d.ts +58 -0
- package/esm/models/operations/deleteaccountpolicy.js +21 -0
- package/esm/models/operations/deletebudgetpolicy.d.ts +63 -0
- package/esm/models/operations/deletebudgetpolicy.js +23 -0
- package/esm/models/operations/deletemodelavailabilitypolicy.d.ts +63 -0
- package/esm/models/operations/deletemodelavailabilitypolicy.js +23 -0
- package/esm/models/operations/deletemoderationpolicy.d.ts +63 -0
- package/esm/models/operations/deletemoderationpolicy.js +23 -0
- package/esm/models/operations/getapikeypolicyassignment.d.ts +84 -0
- package/esm/models/operations/getapikeypolicyassignment.js +37 -0
- package/esm/models/operations/getbudgetpolicy.d.ts +63 -0
- package/esm/models/operations/getbudgetpolicy.js +23 -0
- package/esm/models/operations/getmemberpolicyassignment.d.ts +84 -0
- package/esm/models/operations/getmemberpolicyassignment.js +38 -0
- package/esm/models/operations/getmodelavailabilitypolicy.d.ts +63 -0
- package/esm/models/operations/getmodelavailabilitypolicy.js +23 -0
- package/esm/models/operations/getmoderationpolicy.d.ts +63 -0
- package/esm/models/operations/getmoderationpolicy.js +23 -0
- package/esm/models/operations/index.d.ts +23 -0
- package/esm/models/operations/index.js +23 -0
- package/esm/models/operations/list.d.ts +7 -1
- package/esm/models/operations/list.js +12 -1
- package/esm/models/operations/listaccountpolicies.d.ts +72 -0
- package/esm/models/operations/listaccountpolicies.js +35 -0
- package/esm/models/operations/listbudgetpolicies.d.ts +77 -0
- package/esm/models/operations/listbudgetpolicies.js +37 -0
- package/esm/models/operations/listmodelavailabilitypolicies.d.ts +77 -0
- package/esm/models/operations/listmodelavailabilitypolicies.js +37 -0
- package/esm/models/operations/listmoderationpolicies.d.ts +77 -0
- package/esm/models/operations/listmoderationpolicies.js +37 -0
- package/esm/models/operations/updateaccountpolicy.d.ts +61 -0
- package/esm/models/operations/updateaccountpolicy.js +24 -0
- package/esm/models/operations/updatebudgetpolicy.d.ts +61 -0
- package/esm/models/operations/updatebudgetpolicy.js +24 -0
- package/esm/models/operations/updatemodelavailabilitypolicy.d.ts +61 -0
- package/esm/models/operations/updatemodelavailabilitypolicy.js +24 -0
- package/esm/models/operations/updatemoderationpolicy.d.ts +61 -0
- package/esm/models/operations/updatemoderationpolicy.js +24 -0
- package/esm/models/outputmemoryservertoolitem.d.ts +5 -5
- package/esm/models/outputmemoryservertoolitem.js +5 -5
- package/esm/models/updatebudgetguardrailpolicyrequest.d.ts +48 -0
- package/esm/models/updatebudgetguardrailpolicyrequest.js +31 -0
- package/esm/models/updatemodelavailabilityguardrailpolicyrequest.d.ts +48 -0
- package/esm/models/updatemodelavailabilityguardrailpolicyrequest.js +31 -0
- package/esm/models/updatemoderationguardrailpolicyrequest.d.ts +48 -0
- package/esm/models/updatemoderationguardrailpolicyrequest.js +31 -0
- package/esm/sdk/apikeys.d.ts +4 -1
- package/esm/sdk/apikeys.js +2 -1
- package/esm/sdk/guardrailpolicies.d.ts +176 -0
- package/esm/sdk/guardrailpolicies.js +240 -0
- package/esm/sdk/sdk.d.ts +3 -0
- package/esm/sdk/sdk.js +4 -0
- package/jsr.json +1 -1
- package/package.json +9 -9
- package/scripts/check-types.js +113 -40
- package/vitest.config.ts +7 -0
|
@@ -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
|
+
* Create a model availability policy
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* Create a model availability policy in a workspace. [Management key](/docs/guides/overview/auth/management-api-keys) required.
|
|
17
|
+
*/
|
|
18
|
+
export declare function guardrailPoliciesCreateModelAvailabilityPolicy(client: OpenRouterCore, request: operations.CreateModelAvailabilityPolicyRequest, options?: RequestOptions): APIPromise<Result<models.ModelAvailabilityGuardrailPolicyResponse, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.ForbiddenResponseError | errors.NotFoundResponseError | errors.ConflictResponseError | errors.InternalServerResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|
|
19
|
+
//# sourceMappingURL=guardrailPoliciesCreateModelAvailabilityPolicy.d.ts.map
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
* @generated-id: 2b979a2c959f
|
|
4
|
+
*/
|
|
5
|
+
import { encodeJSON, 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 { BadRequestResponseError$inboundSchema as errors_BadRequestResponseError$inboundSchema } from "../models/errors/badrequestresponseerror.js"; import { ConflictResponseError$inboundSchema as errors_ConflictResponseError$inboundSchema } from "../models/errors/conflictresponseerror.js"; import { ForbiddenResponseError$inboundSchema as errors_ForbiddenResponseError$inboundSchema } from "../models/errors/forbiddenresponseerror.js"; import { InternalServerResponseError$inboundSchema as errors_InternalServerResponseError$inboundSchema } from "../models/errors/internalserverresponseerror.js"; import { NotFoundResponseError$inboundSchema as errors_NotFoundResponseError$inboundSchema } from "../models/errors/notfoundresponseerror.js"; import { UnauthorizedResponseError$inboundSchema as errors_UnauthorizedResponseError$inboundSchema } from "../models/errors/unauthorizedresponseerror.js";
|
|
13
|
+
import { ModelAvailabilityGuardrailPolicyResponse$inboundSchema as models_ModelAvailabilityGuardrailPolicyResponse$inboundSchema } from "../models/modelavailabilityguardrailpolicyresponse.js";
|
|
14
|
+
import { CreateModelAvailabilityPolicyRequest$outboundSchema as operations_CreateModelAvailabilityPolicyRequest$outboundSchema } from "../models/operations/createmodelavailabilitypolicy.js";
|
|
15
|
+
import { APIPromise } from "../types/async.js";
|
|
16
|
+
/**
|
|
17
|
+
* Create a model availability policy
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* Create a model availability policy in a workspace. [Management key](/docs/guides/overview/auth/management-api-keys) required.
|
|
21
|
+
*/
|
|
22
|
+
export function guardrailPoliciesCreateModelAvailabilityPolicy(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_CreateModelAvailabilityPolicyRequest$outboundSchema.parse(value), "Input validation failed");
|
|
27
|
+
if (!parsed.ok) {
|
|
28
|
+
return [parsed, { status: "invalid" }];
|
|
29
|
+
}
|
|
30
|
+
const payload = parsed.value;
|
|
31
|
+
const body = encodeJSON("body", payload.CreateModelAvailabilityGuardrailPolicyRequest, { explode: true });
|
|
32
|
+
const path = pathToFunc("/guardrails/policies/model-availability")();
|
|
33
|
+
const headers = new Headers(compactMap({
|
|
34
|
+
"Content-Type": "application/json",
|
|
35
|
+
Accept: "application/json",
|
|
36
|
+
"HTTP-Referer": encodeSimple("HTTP-Referer", payload["HTTP-Referer"] ?? client._options.httpReferer, { explode: false, charEncoding: "none" }),
|
|
37
|
+
"X-OpenRouter-Categories": encodeSimple("X-OpenRouter-Categories", payload.appCategories ?? client._options.appCategories, { explode: false, charEncoding: "none" }),
|
|
38
|
+
"X-OpenRouter-Title": encodeSimple("X-OpenRouter-Title", payload.appTitle ?? client._options.appTitle, { explode: false, charEncoding: "none" }),
|
|
39
|
+
}));
|
|
40
|
+
const secConfig = await extractSecurity(client._options.apiKey);
|
|
41
|
+
const securityInput = secConfig == null ? {} : { apiKey: secConfig };
|
|
42
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
43
|
+
const context = {
|
|
44
|
+
options: client._options,
|
|
45
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
46
|
+
operationID: "createModelAvailabilityPolicy",
|
|
47
|
+
oAuth2Scopes: null,
|
|
48
|
+
resolvedSecurity: requestSecurity,
|
|
49
|
+
securitySource: client._options.apiKey,
|
|
50
|
+
retryConfig: options?.retries
|
|
51
|
+
|| client._options.retryConfig
|
|
52
|
+
|| {
|
|
53
|
+
strategy: "backoff",
|
|
54
|
+
backoff: {
|
|
55
|
+
initialInterval: 500,
|
|
56
|
+
maxInterval: 60000,
|
|
57
|
+
exponent: 1.5,
|
|
58
|
+
maxElapsedTime: 3600000,
|
|
59
|
+
},
|
|
60
|
+
retryConnectionErrors: true,
|
|
61
|
+
}
|
|
62
|
+
|| { strategy: "none" },
|
|
63
|
+
retryCodes: options?.retryCodes || ["5XX"],
|
|
64
|
+
};
|
|
65
|
+
const requestRes = client._createRequest(context, {
|
|
66
|
+
security: requestSecurity,
|
|
67
|
+
method: "POST",
|
|
68
|
+
baseURL: options?.serverURL,
|
|
69
|
+
path: path,
|
|
70
|
+
headers: headers,
|
|
71
|
+
body: body,
|
|
72
|
+
userAgent: client._options.userAgent,
|
|
73
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
74
|
+
}, options);
|
|
75
|
+
if (!requestRes.ok) {
|
|
76
|
+
return [requestRes, { status: "invalid" }];
|
|
77
|
+
}
|
|
78
|
+
const req = requestRes.value;
|
|
79
|
+
const doResult = await client._do(req, {
|
|
80
|
+
context,
|
|
81
|
+
isErrorStatusCode: (statusCode) => matchStatusCode({ status: statusCode }, ["4XX", "5XX"]),
|
|
82
|
+
retryConfig: context.retryConfig,
|
|
83
|
+
retryCodes: context.retryCodes,
|
|
84
|
+
});
|
|
85
|
+
if (!doResult.ok) {
|
|
86
|
+
return [doResult, { status: "request-error", request: req }];
|
|
87
|
+
}
|
|
88
|
+
const response = doResult.value;
|
|
89
|
+
const responseFields = {
|
|
90
|
+
HttpMeta: { Response: response, Request: req },
|
|
91
|
+
};
|
|
92
|
+
const [result] = await M.match(M.json(201, models_ModelAvailabilityGuardrailPolicyResponse$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(409, errors_ConflictResponseError$inboundSchema), M.jsonErr(500, errors_InternalServerResponseError$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
|
|
93
|
+
if (!result.ok) {
|
|
94
|
+
return [result, { status: "complete", request: req, response }];
|
|
95
|
+
}
|
|
96
|
+
return [result, { status: "complete", request: req, response }];
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=guardrailPoliciesCreateModelAvailabilityPolicy.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
|
+
* Create a moderation policy
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* Create a moderation policy in a workspace. [Management key](/docs/guides/overview/auth/management-api-keys) required.
|
|
17
|
+
*/
|
|
18
|
+
export declare function guardrailPoliciesCreateModerationPolicy(client: OpenRouterCore, request: operations.CreateModerationPolicyRequest, options?: RequestOptions): APIPromise<Result<models.ModerationGuardrailPolicyResponse, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.ForbiddenResponseError | errors.NotFoundResponseError | errors.ConflictResponseError | errors.InternalServerResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|
|
19
|
+
//# sourceMappingURL=guardrailPoliciesCreateModerationPolicy.d.ts.map
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
* @generated-id: 1d87df4fec1a
|
|
4
|
+
*/
|
|
5
|
+
import { encodeJSON, 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 { BadRequestResponseError$inboundSchema as errors_BadRequestResponseError$inboundSchema } from "../models/errors/badrequestresponseerror.js"; import { ConflictResponseError$inboundSchema as errors_ConflictResponseError$inboundSchema } from "../models/errors/conflictresponseerror.js"; import { ForbiddenResponseError$inboundSchema as errors_ForbiddenResponseError$inboundSchema } from "../models/errors/forbiddenresponseerror.js"; import { InternalServerResponseError$inboundSchema as errors_InternalServerResponseError$inboundSchema } from "../models/errors/internalserverresponseerror.js"; import { NotFoundResponseError$inboundSchema as errors_NotFoundResponseError$inboundSchema } from "../models/errors/notfoundresponseerror.js"; import { UnauthorizedResponseError$inboundSchema as errors_UnauthorizedResponseError$inboundSchema } from "../models/errors/unauthorizedresponseerror.js";
|
|
13
|
+
import { ModerationGuardrailPolicyResponse$inboundSchema as models_ModerationGuardrailPolicyResponse$inboundSchema } from "../models/moderationguardrailpolicyresponse.js";
|
|
14
|
+
import { CreateModerationPolicyRequest$outboundSchema as operations_CreateModerationPolicyRequest$outboundSchema } from "../models/operations/createmoderationpolicy.js";
|
|
15
|
+
import { APIPromise } from "../types/async.js";
|
|
16
|
+
/**
|
|
17
|
+
* Create a moderation policy
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* Create a moderation policy in a workspace. [Management key](/docs/guides/overview/auth/management-api-keys) required.
|
|
21
|
+
*/
|
|
22
|
+
export function guardrailPoliciesCreateModerationPolicy(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_CreateModerationPolicyRequest$outboundSchema.parse(value), "Input validation failed");
|
|
27
|
+
if (!parsed.ok) {
|
|
28
|
+
return [parsed, { status: "invalid" }];
|
|
29
|
+
}
|
|
30
|
+
const payload = parsed.value;
|
|
31
|
+
const body = encodeJSON("body", payload.CreateModerationGuardrailPolicyRequest, { explode: true });
|
|
32
|
+
const path = pathToFunc("/guardrails/policies/moderation")();
|
|
33
|
+
const headers = new Headers(compactMap({
|
|
34
|
+
"Content-Type": "application/json",
|
|
35
|
+
Accept: "application/json",
|
|
36
|
+
"HTTP-Referer": encodeSimple("HTTP-Referer", payload["HTTP-Referer"] ?? client._options.httpReferer, { explode: false, charEncoding: "none" }),
|
|
37
|
+
"X-OpenRouter-Categories": encodeSimple("X-OpenRouter-Categories", payload.appCategories ?? client._options.appCategories, { explode: false, charEncoding: "none" }),
|
|
38
|
+
"X-OpenRouter-Title": encodeSimple("X-OpenRouter-Title", payload.appTitle ?? client._options.appTitle, { explode: false, charEncoding: "none" }),
|
|
39
|
+
}));
|
|
40
|
+
const secConfig = await extractSecurity(client._options.apiKey);
|
|
41
|
+
const securityInput = secConfig == null ? {} : { apiKey: secConfig };
|
|
42
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
43
|
+
const context = {
|
|
44
|
+
options: client._options,
|
|
45
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
46
|
+
operationID: "createModerationPolicy",
|
|
47
|
+
oAuth2Scopes: null,
|
|
48
|
+
resolvedSecurity: requestSecurity,
|
|
49
|
+
securitySource: client._options.apiKey,
|
|
50
|
+
retryConfig: options?.retries
|
|
51
|
+
|| client._options.retryConfig
|
|
52
|
+
|| {
|
|
53
|
+
strategy: "backoff",
|
|
54
|
+
backoff: {
|
|
55
|
+
initialInterval: 500,
|
|
56
|
+
maxInterval: 60000,
|
|
57
|
+
exponent: 1.5,
|
|
58
|
+
maxElapsedTime: 3600000,
|
|
59
|
+
},
|
|
60
|
+
retryConnectionErrors: true,
|
|
61
|
+
}
|
|
62
|
+
|| { strategy: "none" },
|
|
63
|
+
retryCodes: options?.retryCodes || ["5XX"],
|
|
64
|
+
};
|
|
65
|
+
const requestRes = client._createRequest(context, {
|
|
66
|
+
security: requestSecurity,
|
|
67
|
+
method: "POST",
|
|
68
|
+
baseURL: options?.serverURL,
|
|
69
|
+
path: path,
|
|
70
|
+
headers: headers,
|
|
71
|
+
body: body,
|
|
72
|
+
userAgent: client._options.userAgent,
|
|
73
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
74
|
+
}, options);
|
|
75
|
+
if (!requestRes.ok) {
|
|
76
|
+
return [requestRes, { status: "invalid" }];
|
|
77
|
+
}
|
|
78
|
+
const req = requestRes.value;
|
|
79
|
+
const doResult = await client._do(req, {
|
|
80
|
+
context,
|
|
81
|
+
isErrorStatusCode: (statusCode) => matchStatusCode({ status: statusCode }, ["4XX", "5XX"]),
|
|
82
|
+
retryConfig: context.retryConfig,
|
|
83
|
+
retryCodes: context.retryCodes,
|
|
84
|
+
});
|
|
85
|
+
if (!doResult.ok) {
|
|
86
|
+
return [doResult, { status: "request-error", request: req }];
|
|
87
|
+
}
|
|
88
|
+
const response = doResult.value;
|
|
89
|
+
const responseFields = {
|
|
90
|
+
HttpMeta: { Response: response, Request: req },
|
|
91
|
+
};
|
|
92
|
+
const [result] = await M.match(M.json(201, models_ModerationGuardrailPolicyResponse$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(409, errors_ConflictResponseError$inboundSchema), M.jsonErr(500, errors_InternalServerResponseError$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
|
|
93
|
+
if (!result.ok) {
|
|
94
|
+
return [result, { status: "complete", request: req, response }];
|
|
95
|
+
}
|
|
96
|
+
return [result, { status: "complete", request: req, response }];
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=guardrailPoliciesCreateModerationPolicy.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-wide policy
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* Delete a workspace-wide policy. [Management key](/docs/guides/overview/auth/management-api-keys) required.
|
|
17
|
+
*/
|
|
18
|
+
export declare function guardrailPoliciesDeleteAccountPolicy(client: OpenRouterCore, request: operations.DeleteAccountPolicyRequest, options?: RequestOptions): APIPromise<Result<models.DeleteGuardrailPolicyResponse, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.ForbiddenResponseError | errors.NotFoundResponseError | errors.ConflictResponseError | errors.InternalServerResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|
|
19
|
+
//# sourceMappingURL=guardrailPoliciesDeleteAccountPolicy.d.ts.map
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
* @generated-id: 7bdcf7d72d1c
|
|
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 { BadRequestResponseError$inboundSchema as errors_BadRequestResponseError$inboundSchema } from "../models/errors/badrequestresponseerror.js"; import { ConflictResponseError$inboundSchema as errors_ConflictResponseError$inboundSchema } from "../models/errors/conflictresponseerror.js"; import { ForbiddenResponseError$inboundSchema as errors_ForbiddenResponseError$inboundSchema } from "../models/errors/forbiddenresponseerror.js"; import { InternalServerResponseError$inboundSchema as errors_InternalServerResponseError$inboundSchema } from "../models/errors/internalserverresponseerror.js"; import { NotFoundResponseError$inboundSchema as errors_NotFoundResponseError$inboundSchema } from "../models/errors/notfoundresponseerror.js"; import { UnauthorizedResponseError$inboundSchema as errors_UnauthorizedResponseError$inboundSchema } from "../models/errors/unauthorizedresponseerror.js";
|
|
13
|
+
import { DeleteGuardrailPolicyResponse$inboundSchema as models_DeleteGuardrailPolicyResponse$inboundSchema } from "../models/deleteguardrailpolicyresponse.js";
|
|
14
|
+
import { DeleteAccountPolicyRequest$outboundSchema as operations_DeleteAccountPolicyRequest$outboundSchema } from "../models/operations/deleteaccountpolicy.js";
|
|
15
|
+
import { APIPromise } from "../types/async.js";
|
|
16
|
+
/**
|
|
17
|
+
* Delete a workspace-wide policy
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* Delete a workspace-wide policy. [Management key](/docs/guides/overview/auth/management-api-keys) required.
|
|
21
|
+
*/
|
|
22
|
+
export function guardrailPoliciesDeleteAccountPolicy(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_DeleteAccountPolicyRequest$outboundSchema.parse(value), "Input validation failed");
|
|
27
|
+
if (!parsed.ok) {
|
|
28
|
+
return [parsed, { status: "invalid" }];
|
|
29
|
+
}
|
|
30
|
+
const payload = parsed.value;
|
|
31
|
+
const body = null;
|
|
32
|
+
const pathParams = {
|
|
33
|
+
id: encodeSimple("id", payload.id, {
|
|
34
|
+
explode: false,
|
|
35
|
+
charEncoding: "percent",
|
|
36
|
+
}),
|
|
37
|
+
};
|
|
38
|
+
const path = pathToFunc("/guardrails/policies/account/{id}")(pathParams);
|
|
39
|
+
const headers = new Headers(compactMap({
|
|
40
|
+
Accept: "application/json",
|
|
41
|
+
"HTTP-Referer": encodeSimple("HTTP-Referer", payload["HTTP-Referer"] ?? client._options.httpReferer, { explode: false, charEncoding: "none" }),
|
|
42
|
+
"X-OpenRouter-Categories": encodeSimple("X-OpenRouter-Categories", payload.appCategories ?? client._options.appCategories, { explode: false, charEncoding: "none" }),
|
|
43
|
+
"X-OpenRouter-Title": encodeSimple("X-OpenRouter-Title", payload.appTitle ?? client._options.appTitle, { explode: false, charEncoding: "none" }),
|
|
44
|
+
}));
|
|
45
|
+
const secConfig = await extractSecurity(client._options.apiKey);
|
|
46
|
+
const securityInput = secConfig == null ? {} : { apiKey: secConfig };
|
|
47
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
48
|
+
const context = {
|
|
49
|
+
options: client._options,
|
|
50
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
51
|
+
operationID: "deleteAccountPolicy",
|
|
52
|
+
oAuth2Scopes: null,
|
|
53
|
+
resolvedSecurity: requestSecurity,
|
|
54
|
+
securitySource: client._options.apiKey,
|
|
55
|
+
retryConfig: options?.retries
|
|
56
|
+
|| client._options.retryConfig
|
|
57
|
+
|| {
|
|
58
|
+
strategy: "backoff",
|
|
59
|
+
backoff: {
|
|
60
|
+
initialInterval: 500,
|
|
61
|
+
maxInterval: 60000,
|
|
62
|
+
exponent: 1.5,
|
|
63
|
+
maxElapsedTime: 3600000,
|
|
64
|
+
},
|
|
65
|
+
retryConnectionErrors: true,
|
|
66
|
+
}
|
|
67
|
+
|| { strategy: "none" },
|
|
68
|
+
retryCodes: options?.retryCodes || ["5XX"],
|
|
69
|
+
};
|
|
70
|
+
const requestRes = client._createRequest(context, {
|
|
71
|
+
security: requestSecurity,
|
|
72
|
+
method: "DELETE",
|
|
73
|
+
baseURL: options?.serverURL,
|
|
74
|
+
path: path,
|
|
75
|
+
headers: headers,
|
|
76
|
+
body: body,
|
|
77
|
+
userAgent: client._options.userAgent,
|
|
78
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
79
|
+
}, options);
|
|
80
|
+
if (!requestRes.ok) {
|
|
81
|
+
return [requestRes, { status: "invalid" }];
|
|
82
|
+
}
|
|
83
|
+
const req = requestRes.value;
|
|
84
|
+
const doResult = await client._do(req, {
|
|
85
|
+
context,
|
|
86
|
+
isErrorStatusCode: (statusCode) => matchStatusCode({ status: statusCode }, ["4XX", "5XX"]),
|
|
87
|
+
retryConfig: context.retryConfig,
|
|
88
|
+
retryCodes: context.retryCodes,
|
|
89
|
+
});
|
|
90
|
+
if (!doResult.ok) {
|
|
91
|
+
return [doResult, { status: "request-error", request: req }];
|
|
92
|
+
}
|
|
93
|
+
const response = doResult.value;
|
|
94
|
+
const responseFields = {
|
|
95
|
+
HttpMeta: { Response: response, Request: req },
|
|
96
|
+
};
|
|
97
|
+
const [result] = await M.match(M.json(200, models_DeleteGuardrailPolicyResponse$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(409, errors_ConflictResponseError$inboundSchema), M.jsonErr(500, errors_InternalServerResponseError$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
|
|
98
|
+
if (!result.ok) {
|
|
99
|
+
return [result, { status: "complete", request: req, response }];
|
|
100
|
+
}
|
|
101
|
+
return [result, { status: "complete", request: req, response }];
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=guardrailPoliciesDeleteAccountPolicy.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 budget policy
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* Delete a budget policy. [Management key](/docs/guides/overview/auth/management-api-keys) required.
|
|
17
|
+
*/
|
|
18
|
+
export declare function guardrailPoliciesDeleteBudgetPolicy(client: OpenRouterCore, request: operations.DeleteBudgetPolicyRequest, options?: RequestOptions): APIPromise<Result<models.DeleteGuardrailPolicyResponse, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.ForbiddenResponseError | errors.NotFoundResponseError | errors.ConflictResponseError | errors.InternalServerResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|
|
19
|
+
//# sourceMappingURL=guardrailPoliciesDeleteBudgetPolicy.d.ts.map
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
* @generated-id: d1f10f2a06c4
|
|
4
|
+
*/
|
|
5
|
+
import { encodeFormQuery, 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 { BadRequestResponseError$inboundSchema as errors_BadRequestResponseError$inboundSchema } from "../models/errors/badrequestresponseerror.js"; import { ConflictResponseError$inboundSchema as errors_ConflictResponseError$inboundSchema } from "../models/errors/conflictresponseerror.js"; import { ForbiddenResponseError$inboundSchema as errors_ForbiddenResponseError$inboundSchema } from "../models/errors/forbiddenresponseerror.js"; import { InternalServerResponseError$inboundSchema as errors_InternalServerResponseError$inboundSchema } from "../models/errors/internalserverresponseerror.js"; import { NotFoundResponseError$inboundSchema as errors_NotFoundResponseError$inboundSchema } from "../models/errors/notfoundresponseerror.js"; import { UnauthorizedResponseError$inboundSchema as errors_UnauthorizedResponseError$inboundSchema } from "../models/errors/unauthorizedresponseerror.js";
|
|
13
|
+
import { DeleteGuardrailPolicyResponse$inboundSchema as models_DeleteGuardrailPolicyResponse$inboundSchema } from "../models/deleteguardrailpolicyresponse.js";
|
|
14
|
+
import { DeleteBudgetPolicyRequest$outboundSchema as operations_DeleteBudgetPolicyRequest$outboundSchema } from "../models/operations/deletebudgetpolicy.js";
|
|
15
|
+
import { APIPromise } from "../types/async.js";
|
|
16
|
+
/**
|
|
17
|
+
* Delete a budget policy
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* Delete a budget policy. [Management key](/docs/guides/overview/auth/management-api-keys) required.
|
|
21
|
+
*/
|
|
22
|
+
export function guardrailPoliciesDeleteBudgetPolicy(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_DeleteBudgetPolicyRequest$outboundSchema.parse(value), "Input validation failed");
|
|
27
|
+
if (!parsed.ok) {
|
|
28
|
+
return [parsed, { status: "invalid" }];
|
|
29
|
+
}
|
|
30
|
+
const payload = parsed.value;
|
|
31
|
+
const body = null;
|
|
32
|
+
const pathParams = {
|
|
33
|
+
id: encodeSimple("id", payload.id, {
|
|
34
|
+
explode: false,
|
|
35
|
+
charEncoding: "percent",
|
|
36
|
+
}),
|
|
37
|
+
};
|
|
38
|
+
const path = pathToFunc("/guardrails/policies/budget/{id}")(pathParams);
|
|
39
|
+
const query = encodeFormQuery({
|
|
40
|
+
"workspace_id": payload.workspace_id,
|
|
41
|
+
});
|
|
42
|
+
const headers = new Headers(compactMap({
|
|
43
|
+
Accept: "application/json",
|
|
44
|
+
"HTTP-Referer": encodeSimple("HTTP-Referer", payload["HTTP-Referer"] ?? client._options.httpReferer, { explode: false, charEncoding: "none" }),
|
|
45
|
+
"X-OpenRouter-Categories": encodeSimple("X-OpenRouter-Categories", payload.appCategories ?? client._options.appCategories, { explode: false, charEncoding: "none" }),
|
|
46
|
+
"X-OpenRouter-Title": encodeSimple("X-OpenRouter-Title", payload.appTitle ?? client._options.appTitle, { explode: false, charEncoding: "none" }),
|
|
47
|
+
}));
|
|
48
|
+
const secConfig = await extractSecurity(client._options.apiKey);
|
|
49
|
+
const securityInput = secConfig == null ? {} : { apiKey: secConfig };
|
|
50
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
51
|
+
const context = {
|
|
52
|
+
options: client._options,
|
|
53
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
54
|
+
operationID: "deleteBudgetPolicy",
|
|
55
|
+
oAuth2Scopes: null,
|
|
56
|
+
resolvedSecurity: requestSecurity,
|
|
57
|
+
securitySource: client._options.apiKey,
|
|
58
|
+
retryConfig: options?.retries
|
|
59
|
+
|| client._options.retryConfig
|
|
60
|
+
|| {
|
|
61
|
+
strategy: "backoff",
|
|
62
|
+
backoff: {
|
|
63
|
+
initialInterval: 500,
|
|
64
|
+
maxInterval: 60000,
|
|
65
|
+
exponent: 1.5,
|
|
66
|
+
maxElapsedTime: 3600000,
|
|
67
|
+
},
|
|
68
|
+
retryConnectionErrors: true,
|
|
69
|
+
}
|
|
70
|
+
|| { strategy: "none" },
|
|
71
|
+
retryCodes: options?.retryCodes || ["5XX"],
|
|
72
|
+
};
|
|
73
|
+
const requestRes = client._createRequest(context, {
|
|
74
|
+
security: requestSecurity,
|
|
75
|
+
method: "DELETE",
|
|
76
|
+
baseURL: options?.serverURL,
|
|
77
|
+
path: path,
|
|
78
|
+
headers: headers,
|
|
79
|
+
query: query,
|
|
80
|
+
body: body,
|
|
81
|
+
userAgent: client._options.userAgent,
|
|
82
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
83
|
+
}, options);
|
|
84
|
+
if (!requestRes.ok) {
|
|
85
|
+
return [requestRes, { status: "invalid" }];
|
|
86
|
+
}
|
|
87
|
+
const req = requestRes.value;
|
|
88
|
+
const doResult = await client._do(req, {
|
|
89
|
+
context,
|
|
90
|
+
isErrorStatusCode: (statusCode) => matchStatusCode({ status: statusCode }, ["4XX", "5XX"]),
|
|
91
|
+
retryConfig: context.retryConfig,
|
|
92
|
+
retryCodes: context.retryCodes,
|
|
93
|
+
});
|
|
94
|
+
if (!doResult.ok) {
|
|
95
|
+
return [doResult, { status: "request-error", request: req }];
|
|
96
|
+
}
|
|
97
|
+
const response = doResult.value;
|
|
98
|
+
const responseFields = {
|
|
99
|
+
HttpMeta: { Response: response, Request: req },
|
|
100
|
+
};
|
|
101
|
+
const [result] = await M.match(M.json(200, models_DeleteGuardrailPolicyResponse$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(409, errors_ConflictResponseError$inboundSchema), M.jsonErr(500, errors_InternalServerResponseError$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
|
|
102
|
+
if (!result.ok) {
|
|
103
|
+
return [result, { status: "complete", request: req, response }];
|
|
104
|
+
}
|
|
105
|
+
return [result, { status: "complete", request: req, response }];
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=guardrailPoliciesDeleteBudgetPolicy.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 model availability policy
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* Delete a model availability policy. [Management key](/docs/guides/overview/auth/management-api-keys) required.
|
|
17
|
+
*/
|
|
18
|
+
export declare function guardrailPoliciesDeleteModelAvailabilityPolicy(client: OpenRouterCore, request: operations.DeleteModelAvailabilityPolicyRequest, options?: RequestOptions): APIPromise<Result<models.DeleteGuardrailPolicyResponse, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.ForbiddenResponseError | errors.NotFoundResponseError | errors.ConflictResponseError | errors.InternalServerResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|
|
19
|
+
//# sourceMappingURL=guardrailPoliciesDeleteModelAvailabilityPolicy.d.ts.map
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
* @generated-id: 1e732901786e
|
|
4
|
+
*/
|
|
5
|
+
import { encodeFormQuery, 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 { BadRequestResponseError$inboundSchema as errors_BadRequestResponseError$inboundSchema } from "../models/errors/badrequestresponseerror.js"; import { ConflictResponseError$inboundSchema as errors_ConflictResponseError$inboundSchema } from "../models/errors/conflictresponseerror.js"; import { ForbiddenResponseError$inboundSchema as errors_ForbiddenResponseError$inboundSchema } from "../models/errors/forbiddenresponseerror.js"; import { InternalServerResponseError$inboundSchema as errors_InternalServerResponseError$inboundSchema } from "../models/errors/internalserverresponseerror.js"; import { NotFoundResponseError$inboundSchema as errors_NotFoundResponseError$inboundSchema } from "../models/errors/notfoundresponseerror.js"; import { UnauthorizedResponseError$inboundSchema as errors_UnauthorizedResponseError$inboundSchema } from "../models/errors/unauthorizedresponseerror.js";
|
|
13
|
+
import { DeleteGuardrailPolicyResponse$inboundSchema as models_DeleteGuardrailPolicyResponse$inboundSchema } from "../models/deleteguardrailpolicyresponse.js";
|
|
14
|
+
import { DeleteModelAvailabilityPolicyRequest$outboundSchema as operations_DeleteModelAvailabilityPolicyRequest$outboundSchema } from "../models/operations/deletemodelavailabilitypolicy.js";
|
|
15
|
+
import { APIPromise } from "../types/async.js";
|
|
16
|
+
/**
|
|
17
|
+
* Delete a model availability policy
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* Delete a model availability policy. [Management key](/docs/guides/overview/auth/management-api-keys) required.
|
|
21
|
+
*/
|
|
22
|
+
export function guardrailPoliciesDeleteModelAvailabilityPolicy(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_DeleteModelAvailabilityPolicyRequest$outboundSchema.parse(value), "Input validation failed");
|
|
27
|
+
if (!parsed.ok) {
|
|
28
|
+
return [parsed, { status: "invalid" }];
|
|
29
|
+
}
|
|
30
|
+
const payload = parsed.value;
|
|
31
|
+
const body = null;
|
|
32
|
+
const pathParams = {
|
|
33
|
+
id: encodeSimple("id", payload.id, {
|
|
34
|
+
explode: false,
|
|
35
|
+
charEncoding: "percent",
|
|
36
|
+
}),
|
|
37
|
+
};
|
|
38
|
+
const path = pathToFunc("/guardrails/policies/model-availability/{id}")(pathParams);
|
|
39
|
+
const query = encodeFormQuery({
|
|
40
|
+
"workspace_id": payload.workspace_id,
|
|
41
|
+
});
|
|
42
|
+
const headers = new Headers(compactMap({
|
|
43
|
+
Accept: "application/json",
|
|
44
|
+
"HTTP-Referer": encodeSimple("HTTP-Referer", payload["HTTP-Referer"] ?? client._options.httpReferer, { explode: false, charEncoding: "none" }),
|
|
45
|
+
"X-OpenRouter-Categories": encodeSimple("X-OpenRouter-Categories", payload.appCategories ?? client._options.appCategories, { explode: false, charEncoding: "none" }),
|
|
46
|
+
"X-OpenRouter-Title": encodeSimple("X-OpenRouter-Title", payload.appTitle ?? client._options.appTitle, { explode: false, charEncoding: "none" }),
|
|
47
|
+
}));
|
|
48
|
+
const secConfig = await extractSecurity(client._options.apiKey);
|
|
49
|
+
const securityInput = secConfig == null ? {} : { apiKey: secConfig };
|
|
50
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
51
|
+
const context = {
|
|
52
|
+
options: client._options,
|
|
53
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
54
|
+
operationID: "deleteModelAvailabilityPolicy",
|
|
55
|
+
oAuth2Scopes: null,
|
|
56
|
+
resolvedSecurity: requestSecurity,
|
|
57
|
+
securitySource: client._options.apiKey,
|
|
58
|
+
retryConfig: options?.retries
|
|
59
|
+
|| client._options.retryConfig
|
|
60
|
+
|| {
|
|
61
|
+
strategy: "backoff",
|
|
62
|
+
backoff: {
|
|
63
|
+
initialInterval: 500,
|
|
64
|
+
maxInterval: 60000,
|
|
65
|
+
exponent: 1.5,
|
|
66
|
+
maxElapsedTime: 3600000,
|
|
67
|
+
},
|
|
68
|
+
retryConnectionErrors: true,
|
|
69
|
+
}
|
|
70
|
+
|| { strategy: "none" },
|
|
71
|
+
retryCodes: options?.retryCodes || ["5XX"],
|
|
72
|
+
};
|
|
73
|
+
const requestRes = client._createRequest(context, {
|
|
74
|
+
security: requestSecurity,
|
|
75
|
+
method: "DELETE",
|
|
76
|
+
baseURL: options?.serverURL,
|
|
77
|
+
path: path,
|
|
78
|
+
headers: headers,
|
|
79
|
+
query: query,
|
|
80
|
+
body: body,
|
|
81
|
+
userAgent: client._options.userAgent,
|
|
82
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
83
|
+
}, options);
|
|
84
|
+
if (!requestRes.ok) {
|
|
85
|
+
return [requestRes, { status: "invalid" }];
|
|
86
|
+
}
|
|
87
|
+
const req = requestRes.value;
|
|
88
|
+
const doResult = await client._do(req, {
|
|
89
|
+
context,
|
|
90
|
+
isErrorStatusCode: (statusCode) => matchStatusCode({ status: statusCode }, ["4XX", "5XX"]),
|
|
91
|
+
retryConfig: context.retryConfig,
|
|
92
|
+
retryCodes: context.retryCodes,
|
|
93
|
+
});
|
|
94
|
+
if (!doResult.ok) {
|
|
95
|
+
return [doResult, { status: "request-error", request: req }];
|
|
96
|
+
}
|
|
97
|
+
const response = doResult.value;
|
|
98
|
+
const responseFields = {
|
|
99
|
+
HttpMeta: { Response: response, Request: req },
|
|
100
|
+
};
|
|
101
|
+
const [result] = await M.match(M.json(200, models_DeleteGuardrailPolicyResponse$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(409, errors_ConflictResponseError$inboundSchema), M.jsonErr(500, errors_InternalServerResponseError$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
|
|
102
|
+
if (!result.ok) {
|
|
103
|
+
return [result, { status: "complete", request: req, response }];
|
|
104
|
+
}
|
|
105
|
+
return [result, { status: "complete", request: req, response }];
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=guardrailPoliciesDeleteModelAvailabilityPolicy.js.map
|