> ## Documentation Index > Fetch the complete documentation index at: https://openrouter.ai/docs/llms.txt > Use this file to discover all available pages before exploring further. # Guardrail Policies > Guardrail Policies endpoints ## Overview Guardrail Policies endpoints ### Available Operations * [listAccountPolicies](#listaccountpolicies) - List workspace-wide policies * [createAccountPolicy](#createaccountpolicy) - Create a workspace-wide policy * [deleteAccountPolicy](#deleteaccountpolicy) - Delete a workspace-wide policy * [updateAccountPolicy](#updateaccountpolicy) - Update a workspace-wide policy * [getApiKeyPolicyAssignment](#getapikeypolicyassignment) - Get an API key policy assignment * [changeApiKeyPolicyAssignment](#changeapikeypolicyassignment) - Change an API key policy assignment * [getMemberPolicyAssignment](#getmemberpolicyassignment) - Get a member policy assignment * [changeMemberPolicyAssignment](#changememberpolicyassignment) - Change a member policy assignment * [listBudgetPolicies](#listbudgetpolicies) - List budget policies * [createBudgetPolicy](#createbudgetpolicy) - Create a budget policy * [deleteBudgetPolicy](#deletebudgetpolicy) - Delete a budget policy * [getBudgetPolicy](#getbudgetpolicy) - Get a budget policy * [updateBudgetPolicy](#updatebudgetpolicy) - Update a budget policy * [listModelAvailabilityPolicies](#listmodelavailabilitypolicies) - List model availability policies * [createModelAvailabilityPolicy](#createmodelavailabilitypolicy) - Create a model availability policy * [deleteModelAvailabilityPolicy](#deletemodelavailabilitypolicy) - Delete a model availability policy * [getModelAvailabilityPolicy](#getmodelavailabilitypolicy) - Get a model availability policy * [updateModelAvailabilityPolicy](#updatemodelavailabilitypolicy) - Update a model availability policy * [listModerationPolicies](#listmoderationpolicies) - List moderation policies * [createModerationPolicy](#createmoderationpolicy) - Create a moderation policy * [deleteModerationPolicy](#deletemoderationpolicy) - Delete a moderation policy * [getModerationPolicy](#getmoderationpolicy) - Get a moderation policy * [updateModerationPolicy](#updatemoderationpolicy) - Update a moderation policy ## listAccountPolicies List the workspace-wide policies that apply across workspaces in the account. [Management key](https://openrouter.ai/docs/client-sdks/typescript/docs/guides/overview/auth/management-api-keys) required. ### Example Usage ```typescript theme={null} import { OpenRouter } from "@openrouter/sdk"; const openRouter = new OpenRouter({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const result = await openRouter.guardrailPolicies.listAccountPolicies(); for await (const page of result) { console.log(page); } } run(); ``` ### Standalone function The standalone function version of this method: ```typescript theme={null} import { OpenRouterCore } from "@openrouter/sdk/core.js"; import { guardrailPoliciesListAccountPolicies } from "@openrouter/sdk/funcs/guardrailPoliciesListAccountPolicies.js"; // Use `OpenRouterCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const openRouter = new OpenRouterCore({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const res = await guardrailPoliciesListAccountPolicies(openRouter); if (res.ok) { const { value: result } = res; for await (const page of result) { console.log(page); } } else { console.log("guardrailPoliciesListAccountPolicies failed:", res.error); } } run(); ``` ### Parameters | Parameter | Type | Required | Description | | - | - | - | - | | `request` | [operations.ListAccountPoliciesRequest](../../models/operations/listaccountpoliciesrequest.mdx) | ✔️ | The request object to use for the request. | | `options` | RequestOptions | ➖ | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.mdx) | ➖ | Enables retrying HTTP requests under certain failure conditions. | ### Response **Promise\<[operations.ListAccountPoliciesResponse](../../models/operations/listaccountpoliciesresponse.mdx)>** ### Errors | Error Type | Status Code | Content Type | | - | - | - | | errors.BadRequestResponseError | 400 | application/json | | errors.UnauthorizedResponseError | 401 | application/json | | errors.ForbiddenResponseError | 403 | application/json | | errors.NotFoundResponseError | 404 | application/json | | errors.InternalServerResponseError | 500 | application/json | | errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | ## createAccountPolicy Create a workspace-wide budget, moderation, or model availability policy. [Management key](https://openrouter.ai/docs/client-sdks/typescript/docs/guides/overview/auth/management-api-keys) required. ### Example Usage ```typescript theme={null} import { OpenRouter } from "@openrouter/sdk"; const openRouter = new OpenRouter({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const result = await openRouter.guardrailPolicies.createAccountPolicy({ accountGuardrailPolicyRequest: { config: { includeByokInBudgets: false, limitUsd: 200, resetInterval: "monthly", }, name: "Engineering monthly budget", policyType: "budget", }, }); console.log(result); } run(); ``` ### Standalone function The standalone function version of this method: ```typescript theme={null} import { OpenRouterCore } from "@openrouter/sdk/core.js"; import { guardrailPoliciesCreateAccountPolicy } from "@openrouter/sdk/funcs/guardrailPoliciesCreateAccountPolicy.js"; // Use `OpenRouterCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const openRouter = new OpenRouterCore({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const res = await guardrailPoliciesCreateAccountPolicy(openRouter, { accountGuardrailPolicyRequest: { config: { includeByokInBudgets: false, limitUsd: 200, resetInterval: "monthly", }, name: "Engineering monthly budget", policyType: "budget", }, }); if (res.ok) { const { value: result } = res; console.log(result); } else { console.log("guardrailPoliciesCreateAccountPolicy failed:", res.error); } } run(); ``` ### Parameters | Parameter | Type | Required | Description | | - | - | - | - | | `request` | [operations.CreateAccountPolicyRequest](../../models/operations/createaccountpolicyrequest.mdx) | ✔️ | The request object to use for the request. | | `options` | RequestOptions | ➖ | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.mdx) | ➖ | Enables retrying HTTP requests under certain failure conditions. | ### Response **Promise\<[models.AccountGuardrailPolicyResponse](../../models/accountguardrailpolicyresponse.mdx)>** ### Errors | Error Type | Status Code | Content Type | | - | - | - | | errors.BadRequestResponseError | 400 | application/json | | errors.UnauthorizedResponseError | 401 | application/json | | errors.ForbiddenResponseError | 403 | application/json | | errors.NotFoundResponseError | 404 | application/json | | errors.ConflictResponseError | 409 | application/json | | errors.InternalServerResponseError | 500 | application/json | | errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | ## deleteAccountPolicy Delete a workspace-wide policy. [Management key](https://openrouter.ai/docs/client-sdks/typescript/docs/guides/overview/auth/management-api-keys) required. ### Example Usage ```typescript theme={null} import { OpenRouter } from "@openrouter/sdk"; const openRouter = new OpenRouter({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const result = await openRouter.guardrailPolicies.deleteAccountPolicy({ id: "550e8400-e29b-41d4-a716-446655440000", }); console.log(result); } run(); ``` ### Standalone function The standalone function version of this method: ```typescript theme={null} import { OpenRouterCore } from "@openrouter/sdk/core.js"; import { guardrailPoliciesDeleteAccountPolicy } from "@openrouter/sdk/funcs/guardrailPoliciesDeleteAccountPolicy.js"; // Use `OpenRouterCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const openRouter = new OpenRouterCore({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const res = await guardrailPoliciesDeleteAccountPolicy(openRouter, { id: "550e8400-e29b-41d4-a716-446655440000", }); if (res.ok) { const { value: result } = res; console.log(result); } else { console.log("guardrailPoliciesDeleteAccountPolicy failed:", res.error); } } run(); ``` ### Parameters | Parameter | Type | Required | Description | | - | - | - | - | | `request` | [operations.DeleteAccountPolicyRequest](../../models/operations/deleteaccountpolicyrequest.mdx) | ✔️ | The request object to use for the request. | | `options` | RequestOptions | ➖ | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.mdx) | ➖ | Enables retrying HTTP requests under certain failure conditions. | ### Response **Promise\<[models.DeleteGuardrailPolicyResponse](../../models/deleteguardrailpolicyresponse.mdx)>** ### Errors | Error Type | Status Code | Content Type | | - | - | - | | errors.BadRequestResponseError | 400 | application/json | | errors.UnauthorizedResponseError | 401 | application/json | | errors.ForbiddenResponseError | 403 | application/json | | errors.NotFoundResponseError | 404 | application/json | | errors.ConflictResponseError | 409 | application/json | | errors.InternalServerResponseError | 500 | application/json | | errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | ## updateAccountPolicy Replace a workspace-wide policy and its workspace coverage. [Management key](https://openrouter.ai/docs/client-sdks/typescript/docs/guides/overview/auth/management-api-keys) required. ### Example Usage ```typescript theme={null} import { OpenRouter } from "@openrouter/sdk"; const openRouter = new OpenRouter({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const result = await openRouter.guardrailPolicies.updateAccountPolicy({ id: "550e8400-e29b-41d4-a716-446655440000", accountGuardrailPolicyRequest: { config: { includeByokInBudgets: false, limitUsd: 200, resetInterval: "monthly", }, name: "Engineering monthly budget", policyType: "budget", }, }); console.log(result); } run(); ``` ### Standalone function The standalone function version of this method: ```typescript theme={null} import { OpenRouterCore } from "@openrouter/sdk/core.js"; import { guardrailPoliciesUpdateAccountPolicy } from "@openrouter/sdk/funcs/guardrailPoliciesUpdateAccountPolicy.js"; // Use `OpenRouterCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const openRouter = new OpenRouterCore({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const res = await guardrailPoliciesUpdateAccountPolicy(openRouter, { id: "550e8400-e29b-41d4-a716-446655440000", accountGuardrailPolicyRequest: { config: { includeByokInBudgets: false, limitUsd: 200, resetInterval: "monthly", }, name: "Engineering monthly budget", policyType: "budget", }, }); if (res.ok) { const { value: result } = res; console.log(result); } else { console.log("guardrailPoliciesUpdateAccountPolicy failed:", res.error); } } run(); ``` ### Parameters | Parameter | Type | Required | Description | | - | - | - | - | | `request` | [operations.UpdateAccountPolicyRequest](../../models/operations/updateaccountpolicyrequest.mdx) | ✔️ | The request object to use for the request. | | `options` | RequestOptions | ➖ | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.mdx) | ➖ | Enables retrying HTTP requests under certain failure conditions. | ### Response **Promise\<[models.AccountGuardrailPolicyResponse](../../models/accountguardrailpolicyresponse.mdx)>** ### Errors | Error Type | Status Code | Content Type | | - | - | - | | errors.BadRequestResponseError | 400 | application/json | | errors.UnauthorizedResponseError | 401 | application/json | | errors.ForbiddenResponseError | 403 | application/json | | errors.NotFoundResponseError | 404 | application/json | | errors.ConflictResponseError | 409 | application/json | | errors.InternalServerResponseError | 500 | application/json | | errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | ## getApiKeyPolicyAssignment Get the policies of one type that apply to an API key in a workspace. Requires a management key with write access. [Management key](https://openrouter.ai/docs/client-sdks/typescript/docs/guides/overview/auth/management-api-keys) required. ### Example Usage ```typescript theme={null} import { OpenRouter } from "@openrouter/sdk"; const openRouter = new OpenRouter({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const result = await openRouter.guardrailPolicies.getApiKeyPolicyAssignment({ hash: "c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93", workspaceId: "0df9e665-d932-5740-b2c7-b52af166bc11", policyType: "budget", }); console.log(result); } run(); ``` ### Standalone function The standalone function version of this method: ```typescript theme={null} import { OpenRouterCore } from "@openrouter/sdk/core.js"; import { guardrailPoliciesGetApiKeyPolicyAssignment } from "@openrouter/sdk/funcs/guardrailPoliciesGetApiKeyPolicyAssignment.js"; // Use `OpenRouterCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const openRouter = new OpenRouterCore({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const res = await guardrailPoliciesGetApiKeyPolicyAssignment(openRouter, { hash: "c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93", workspaceId: "0df9e665-d932-5740-b2c7-b52af166bc11", policyType: "budget", }); if (res.ok) { const { value: result } = res; console.log(result); } else { console.log("guardrailPoliciesGetApiKeyPolicyAssignment failed:", res.error); } } run(); ``` ### Parameters | Parameter | Type | Required | Description | | - | - | - | - | | `request` | [operations.GetApiKeyPolicyAssignmentRequest](../../models/operations/getapikeypolicyassignmentrequest.mdx) | ✔️ | The request object to use for the request. | | `options` | RequestOptions | ➖ | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.mdx) | ➖ | Enables retrying HTTP requests under certain failure conditions. | ### Response **Promise\<[models.GuardrailPolicyAssignmentResponse](../../models/guardrailpolicyassignmentresponse.mdx)>** ### Errors | Error Type | Status Code | Content Type | | - | - | - | | errors.BadRequestResponseError | 400 | application/json | | errors.UnauthorizedResponseError | 401 | application/json | | errors.ForbiddenResponseError | 403 | application/json | | errors.NotFoundResponseError | 404 | application/json | | errors.InternalServerResponseError | 500 | application/json | | errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | ## changeApiKeyPolicyAssignment Assign or unassign one policy for an API key. Fails with 409 when `expected_assignment` no longer matches the stored state. [Management key](https://openrouter.ai/docs/client-sdks/typescript/docs/guides/overview/auth/management-api-keys) required. ### Example Usage ```typescript theme={null} import { OpenRouter } from "@openrouter/sdk"; const openRouter = new OpenRouter({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const result = await openRouter.guardrailPolicies.changeApiKeyPolicyAssignment({ hash: "c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93", changeGuardrailPolicyAssignmentRequest: { assigned: true, expectedAssignment: { optedOut: false, policyIds: [], workspaceDefaultPolicyIds: [ "2c6f1a4e-0b7d-4e59-9a61-3f8d2e7c1b90", ], }, policyId: "550e8400-e29b-41d4-a716-446655440000", policyType: "budget", }, }); console.log(result); } run(); ``` ### Standalone function The standalone function version of this method: ```typescript theme={null} import { OpenRouterCore } from "@openrouter/sdk/core.js"; import { guardrailPoliciesChangeApiKeyPolicyAssignment } from "@openrouter/sdk/funcs/guardrailPoliciesChangeApiKeyPolicyAssignment.js"; // Use `OpenRouterCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const openRouter = new OpenRouterCore({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const res = await guardrailPoliciesChangeApiKeyPolicyAssignment(openRouter, { hash: "c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93", changeGuardrailPolicyAssignmentRequest: { assigned: true, expectedAssignment: { optedOut: false, policyIds: [], workspaceDefaultPolicyIds: [ "2c6f1a4e-0b7d-4e59-9a61-3f8d2e7c1b90", ], }, policyId: "550e8400-e29b-41d4-a716-446655440000", policyType: "budget", }, }); if (res.ok) { const { value: result } = res; console.log(result); } else { console.log("guardrailPoliciesChangeApiKeyPolicyAssignment failed:", res.error); } } run(); ``` ### Parameters | Parameter | Type | Required | Description | | - | - | - | - | | `request` | [operations.ChangeApiKeyPolicyAssignmentRequest](../../models/operations/changeapikeypolicyassignmentrequest.mdx) | ✔️ | The request object to use for the request. | | `options` | RequestOptions | ➖ | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.mdx) | ➖ | Enables retrying HTTP requests under certain failure conditions. | ### Response **Promise\<[models.ChangeGuardrailPolicyAssignmentResponse](../../models/changeguardrailpolicyassignmentresponse.mdx)>** ### Errors | Error Type | Status Code | Content Type | | - | - | - | | errors.BadRequestResponseError | 400 | application/json | | errors.UnauthorizedResponseError | 401 | application/json | | errors.ForbiddenResponseError | 403 | application/json | | errors.NotFoundResponseError | 404 | application/json | | errors.ConflictResponseError | 409 | application/json | | errors.InternalServerResponseError | 500 | application/json | | errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | ## getMemberPolicyAssignment Get the policies of one type that apply to a member in a workspace. Requires a management key with write access. [Management key](https://openrouter.ai/docs/client-sdks/typescript/docs/guides/overview/auth/management-api-keys) required. ### Example Usage ```typescript theme={null} import { OpenRouter } from "@openrouter/sdk"; const openRouter = new OpenRouter({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const result = await openRouter.guardrailPolicies.getMemberPolicyAssignment({ memberId: "user_2abcDEFghiJKLmnoPQRstu", workspaceId: "0df9e665-d932-5740-b2c7-b52af166bc11", policyType: "budget", }); console.log(result); } run(); ``` ### Standalone function The standalone function version of this method: ```typescript theme={null} import { OpenRouterCore } from "@openrouter/sdk/core.js"; import { guardrailPoliciesGetMemberPolicyAssignment } from "@openrouter/sdk/funcs/guardrailPoliciesGetMemberPolicyAssignment.js"; // Use `OpenRouterCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const openRouter = new OpenRouterCore({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const res = await guardrailPoliciesGetMemberPolicyAssignment(openRouter, { memberId: "user_2abcDEFghiJKLmnoPQRstu", workspaceId: "0df9e665-d932-5740-b2c7-b52af166bc11", policyType: "budget", }); if (res.ok) { const { value: result } = res; console.log(result); } else { console.log("guardrailPoliciesGetMemberPolicyAssignment failed:", res.error); } } run(); ``` ### Parameters | Parameter | Type | Required | Description | | - | - | - | - | | `request` | [operations.GetMemberPolicyAssignmentRequest](../../models/operations/getmemberpolicyassignmentrequest.mdx) | ✔️ | The request object to use for the request. | | `options` | RequestOptions | ➖ | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.mdx) | ➖ | Enables retrying HTTP requests under certain failure conditions. | ### Response **Promise\<[models.GuardrailPolicyAssignmentResponse](../../models/guardrailpolicyassignmentresponse.mdx)>** ### Errors | Error Type | Status Code | Content Type | | - | - | - | | errors.BadRequestResponseError | 400 | application/json | | errors.UnauthorizedResponseError | 401 | application/json | | errors.ForbiddenResponseError | 403 | application/json | | errors.NotFoundResponseError | 404 | application/json | | errors.InternalServerResponseError | 500 | application/json | | errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | ## changeMemberPolicyAssignment Assign or unassign one policy for a member. Fails with 409 when `expected_assignment` no longer matches the stored state. [Management key](https://openrouter.ai/docs/client-sdks/typescript/docs/guides/overview/auth/management-api-keys) required. ### Example Usage ```typescript theme={null} import { OpenRouter } from "@openrouter/sdk"; const openRouter = new OpenRouter({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const result = await openRouter.guardrailPolicies.changeMemberPolicyAssignment({ memberId: "user_2abcDEFghiJKLmnoPQRstu", changeGuardrailPolicyAssignmentRequest: { assigned: true, expectedAssignment: { optedOut: false, policyIds: [], workspaceDefaultPolicyIds: [ "2c6f1a4e-0b7d-4e59-9a61-3f8d2e7c1b90", ], }, policyId: "550e8400-e29b-41d4-a716-446655440000", policyType: "budget", }, }); console.log(result); } run(); ``` ### Standalone function The standalone function version of this method: ```typescript theme={null} import { OpenRouterCore } from "@openrouter/sdk/core.js"; import { guardrailPoliciesChangeMemberPolicyAssignment } from "@openrouter/sdk/funcs/guardrailPoliciesChangeMemberPolicyAssignment.js"; // Use `OpenRouterCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const openRouter = new OpenRouterCore({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const res = await guardrailPoliciesChangeMemberPolicyAssignment(openRouter, { memberId: "user_2abcDEFghiJKLmnoPQRstu", changeGuardrailPolicyAssignmentRequest: { assigned: true, expectedAssignment: { optedOut: false, policyIds: [], workspaceDefaultPolicyIds: [ "2c6f1a4e-0b7d-4e59-9a61-3f8d2e7c1b90", ], }, policyId: "550e8400-e29b-41d4-a716-446655440000", policyType: "budget", }, }); if (res.ok) { const { value: result } = res; console.log(result); } else { console.log("guardrailPoliciesChangeMemberPolicyAssignment failed:", res.error); } } run(); ``` ### Parameters | Parameter | Type | Required | Description | | - | - | - | - | | `request` | [operations.ChangeMemberPolicyAssignmentRequest](../../models/operations/changememberpolicyassignmentrequest.mdx) | ✔️ | The request object to use for the request. | | `options` | RequestOptions | ➖ | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.mdx) | ➖ | Enables retrying HTTP requests under certain failure conditions. | ### Response **Promise\<[models.ChangeGuardrailPolicyAssignmentResponse](../../models/changeguardrailpolicyassignmentresponse.mdx)>** ### Errors | Error Type | Status Code | Content Type | | - | - | - | | errors.BadRequestResponseError | 400 | application/json | | errors.UnauthorizedResponseError | 401 | application/json | | errors.ForbiddenResponseError | 403 | application/json | | errors.NotFoundResponseError | 404 | application/json | | errors.ConflictResponseError | 409 | application/json | | errors.InternalServerResponseError | 500 | application/json | | errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | ## listBudgetPolicies List the budget policies in a workspace. [Management key](https://openrouter.ai/docs/client-sdks/typescript/docs/guides/overview/auth/management-api-keys) required. ### Example Usage ```typescript theme={null} import { OpenRouter } from "@openrouter/sdk"; const openRouter = new OpenRouter({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const result = await openRouter.guardrailPolicies.listBudgetPolicies(); for await (const page of result) { console.log(page); } } run(); ``` ### Standalone function The standalone function version of this method: ```typescript theme={null} import { OpenRouterCore } from "@openrouter/sdk/core.js"; import { guardrailPoliciesListBudgetPolicies } from "@openrouter/sdk/funcs/guardrailPoliciesListBudgetPolicies.js"; // Use `OpenRouterCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const openRouter = new OpenRouterCore({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const res = await guardrailPoliciesListBudgetPolicies(openRouter); if (res.ok) { const { value: result } = res; for await (const page of result) { console.log(page); } } else { console.log("guardrailPoliciesListBudgetPolicies failed:", res.error); } } run(); ``` ### Parameters | Parameter | Type | Required | Description | | - | - | - | - | | `request` | [operations.ListBudgetPoliciesRequest](../../models/operations/listbudgetpoliciesrequest.mdx) | ✔️ | The request object to use for the request. | | `options` | RequestOptions | ➖ | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.mdx) | ➖ | Enables retrying HTTP requests under certain failure conditions. | ### Response **Promise\<[operations.ListBudgetPoliciesResponse](../../models/operations/listbudgetpoliciesresponse.mdx)>** ### Errors | Error Type | Status Code | Content Type | | - | - | - | | errors.BadRequestResponseError | 400 | application/json | | errors.UnauthorizedResponseError | 401 | application/json | | errors.ForbiddenResponseError | 403 | application/json | | errors.NotFoundResponseError | 404 | application/json | | errors.InternalServerResponseError | 500 | application/json | | errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | ## createBudgetPolicy Create a budget policy in a workspace. [Management key](https://openrouter.ai/docs/client-sdks/typescript/docs/guides/overview/auth/management-api-keys) required. ### Example Usage ```typescript theme={null} import { OpenRouter } from "@openrouter/sdk"; const openRouter = new OpenRouter({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const result = await openRouter.guardrailPolicies.createBudgetPolicy({ createBudgetGuardrailPolicyRequest: { config: { includeByokInBudgets: false, limitUsd: 200, resetInterval: "monthly", }, name: "Engineering monthly budget", policyType: "budget", }, }); console.log(result); } run(); ``` ### Standalone function The standalone function version of this method: ```typescript theme={null} import { OpenRouterCore } from "@openrouter/sdk/core.js"; import { guardrailPoliciesCreateBudgetPolicy } from "@openrouter/sdk/funcs/guardrailPoliciesCreateBudgetPolicy.js"; // Use `OpenRouterCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const openRouter = new OpenRouterCore({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const res = await guardrailPoliciesCreateBudgetPolicy(openRouter, { createBudgetGuardrailPolicyRequest: { config: { includeByokInBudgets: false, limitUsd: 200, resetInterval: "monthly", }, name: "Engineering monthly budget", policyType: "budget", }, }); if (res.ok) { const { value: result } = res; console.log(result); } else { console.log("guardrailPoliciesCreateBudgetPolicy failed:", res.error); } } run(); ``` ### Parameters | Parameter | Type | Required | Description | | - | - | - | - | | `request` | [operations.CreateBudgetPolicyRequest](../../models/operations/createbudgetpolicyrequest.mdx) | ✔️ | The request object to use for the request. | | `options` | RequestOptions | ➖ | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.mdx) | ➖ | Enables retrying HTTP requests under certain failure conditions. | ### Response **Promise\<[models.BudgetGuardrailPolicyResponse](../../models/budgetguardrailpolicyresponse.mdx)>** ### Errors | Error Type | Status Code | Content Type | | - | - | - | | errors.BadRequestResponseError | 400 | application/json | | errors.UnauthorizedResponseError | 401 | application/json | | errors.ForbiddenResponseError | 403 | application/json | | errors.NotFoundResponseError | 404 | application/json | | errors.ConflictResponseError | 409 | application/json | | errors.InternalServerResponseError | 500 | application/json | | errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | ## deleteBudgetPolicy Delete a budget policy. [Management key](https://openrouter.ai/docs/client-sdks/typescript/docs/guides/overview/auth/management-api-keys) required. ### Example Usage ```typescript theme={null} import { OpenRouter } from "@openrouter/sdk"; const openRouter = new OpenRouter({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const result = await openRouter.guardrailPolicies.deleteBudgetPolicy({ id: "550e8400-e29b-41d4-a716-446655440000", workspaceId: "0df9e665-d932-5740-b2c7-b52af166bc11", }); console.log(result); } run(); ``` ### Standalone function The standalone function version of this method: ```typescript theme={null} import { OpenRouterCore } from "@openrouter/sdk/core.js"; import { guardrailPoliciesDeleteBudgetPolicy } from "@openrouter/sdk/funcs/guardrailPoliciesDeleteBudgetPolicy.js"; // Use `OpenRouterCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const openRouter = new OpenRouterCore({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const res = await guardrailPoliciesDeleteBudgetPolicy(openRouter, { id: "550e8400-e29b-41d4-a716-446655440000", workspaceId: "0df9e665-d932-5740-b2c7-b52af166bc11", }); if (res.ok) { const { value: result } = res; console.log(result); } else { console.log("guardrailPoliciesDeleteBudgetPolicy failed:", res.error); } } run(); ``` ### Parameters | Parameter | Type | Required | Description | | - | - | - | - | | `request` | [operations.DeleteBudgetPolicyRequest](../../models/operations/deletebudgetpolicyrequest.mdx) | ✔️ | The request object to use for the request. | | `options` | RequestOptions | ➖ | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.mdx) | ➖ | Enables retrying HTTP requests under certain failure conditions. | ### Response **Promise\<[models.DeleteGuardrailPolicyResponse](../../models/deleteguardrailpolicyresponse.mdx)>** ### Errors | Error Type | Status Code | Content Type | | - | - | - | | errors.BadRequestResponseError | 400 | application/json | | errors.UnauthorizedResponseError | 401 | application/json | | errors.ForbiddenResponseError | 403 | application/json | | errors.NotFoundResponseError | 404 | application/json | | errors.ConflictResponseError | 409 | application/json | | errors.InternalServerResponseError | 500 | application/json | | errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | ## getBudgetPolicy Get a budget policy with its member and API key assignments. [Management key](https://openrouter.ai/docs/client-sdks/typescript/docs/guides/overview/auth/management-api-keys) required. ### Example Usage ```typescript theme={null} import { OpenRouter } from "@openrouter/sdk"; const openRouter = new OpenRouter({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const result = await openRouter.guardrailPolicies.getBudgetPolicy({ id: "550e8400-e29b-41d4-a716-446655440000", workspaceId: "0df9e665-d932-5740-b2c7-b52af166bc11", }); console.log(result); } run(); ``` ### Standalone function The standalone function version of this method: ```typescript theme={null} import { OpenRouterCore } from "@openrouter/sdk/core.js"; import { guardrailPoliciesGetBudgetPolicy } from "@openrouter/sdk/funcs/guardrailPoliciesGetBudgetPolicy.js"; // Use `OpenRouterCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const openRouter = new OpenRouterCore({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const res = await guardrailPoliciesGetBudgetPolicy(openRouter, { id: "550e8400-e29b-41d4-a716-446655440000", workspaceId: "0df9e665-d932-5740-b2c7-b52af166bc11", }); if (res.ok) { const { value: result } = res; console.log(result); } else { console.log("guardrailPoliciesGetBudgetPolicy failed:", res.error); } } run(); ``` ### Parameters | Parameter | Type | Required | Description | | - | - | - | - | | `request` | [operations.GetBudgetPolicyRequest](../../models/operations/getbudgetpolicyrequest.mdx) | ✔️ | The request object to use for the request. | | `options` | RequestOptions | ➖ | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.mdx) | ➖ | Enables retrying HTTP requests under certain failure conditions. | ### Response **Promise\<[models.BudgetGuardrailPolicyDetailResponse](../../models/budgetguardrailpolicydetailresponse.mdx)>** ### Errors | Error Type | Status Code | Content Type | | - | - | - | | errors.BadRequestResponseError | 400 | application/json | | errors.UnauthorizedResponseError | 401 | application/json | | errors.ForbiddenResponseError | 403 | application/json | | errors.NotFoundResponseError | 404 | application/json | | errors.InternalServerResponseError | 500 | application/json | | errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | ## updateBudgetPolicy Replace a budget policy's name and config, and optionally its assignments. [Management key](https://openrouter.ai/docs/client-sdks/typescript/docs/guides/overview/auth/management-api-keys) required. ### Example Usage ```typescript theme={null} import { OpenRouter } from "@openrouter/sdk"; const openRouter = new OpenRouter({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const result = await openRouter.guardrailPolicies.updateBudgetPolicy({ id: "550e8400-e29b-41d4-a716-446655440000", updateBudgetGuardrailPolicyRequest: { config: { includeByokInBudgets: false, limitUsd: 200, resetInterval: "monthly", }, name: "Engineering monthly budget", }, }); console.log(result); } run(); ``` ### Standalone function The standalone function version of this method: ```typescript theme={null} import { OpenRouterCore } from "@openrouter/sdk/core.js"; import { guardrailPoliciesUpdateBudgetPolicy } from "@openrouter/sdk/funcs/guardrailPoliciesUpdateBudgetPolicy.js"; // Use `OpenRouterCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const openRouter = new OpenRouterCore({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const res = await guardrailPoliciesUpdateBudgetPolicy(openRouter, { id: "550e8400-e29b-41d4-a716-446655440000", updateBudgetGuardrailPolicyRequest: { config: { includeByokInBudgets: false, limitUsd: 200, resetInterval: "monthly", }, name: "Engineering monthly budget", }, }); if (res.ok) { const { value: result } = res; console.log(result); } else { console.log("guardrailPoliciesUpdateBudgetPolicy failed:", res.error); } } run(); ``` ### Parameters | Parameter | Type | Required | Description | | - | - | - | - | | `request` | [operations.UpdateBudgetPolicyRequest](../../models/operations/updatebudgetpolicyrequest.mdx) | ✔️ | The request object to use for the request. | | `options` | RequestOptions | ➖ | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.mdx) | ➖ | Enables retrying HTTP requests under certain failure conditions. | ### Response **Promise\<[models.BudgetGuardrailPolicyResponse](../../models/budgetguardrailpolicyresponse.mdx)>** ### Errors | Error Type | Status Code | Content Type | | - | - | - | | errors.BadRequestResponseError | 400 | application/json | | errors.UnauthorizedResponseError | 401 | application/json | | errors.ForbiddenResponseError | 403 | application/json | | errors.NotFoundResponseError | 404 | application/json | | errors.ConflictResponseError | 409 | application/json | | errors.InternalServerResponseError | 500 | application/json | | errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | ## listModelAvailabilityPolicies List the model availability policies in a workspace. [Management key](https://openrouter.ai/docs/client-sdks/typescript/docs/guides/overview/auth/management-api-keys) required. ### Example Usage ```typescript theme={null} import { OpenRouter } from "@openrouter/sdk"; const openRouter = new OpenRouter({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const result = await openRouter.guardrailPolicies.listModelAvailabilityPolicies(); for await (const page of result) { console.log(page); } } run(); ``` ### Standalone function The standalone function version of this method: ```typescript theme={null} import { OpenRouterCore } from "@openrouter/sdk/core.js"; import { guardrailPoliciesListModelAvailabilityPolicies } from "@openrouter/sdk/funcs/guardrailPoliciesListModelAvailabilityPolicies.js"; // Use `OpenRouterCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const openRouter = new OpenRouterCore({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const res = await guardrailPoliciesListModelAvailabilityPolicies(openRouter); if (res.ok) { const { value: result } = res; for await (const page of result) { console.log(page); } } else { console.log("guardrailPoliciesListModelAvailabilityPolicies failed:", res.error); } } run(); ``` ### Parameters | Parameter | Type | Required | Description | | - | - | - | - | | `request` | [operations.ListModelAvailabilityPoliciesRequest](../../models/operations/listmodelavailabilitypoliciesrequest.mdx) | ✔️ | The request object to use for the request. | | `options` | RequestOptions | ➖ | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.mdx) | ➖ | Enables retrying HTTP requests under certain failure conditions. | ### Response **Promise\<[operations.ListModelAvailabilityPoliciesResponse](../../models/operations/listmodelavailabilitypoliciesresponse.mdx)>** ### Errors | Error Type | Status Code | Content Type | | - | - | - | | errors.BadRequestResponseError | 400 | application/json | | errors.UnauthorizedResponseError | 401 | application/json | | errors.ForbiddenResponseError | 403 | application/json | | errors.NotFoundResponseError | 404 | application/json | | errors.InternalServerResponseError | 500 | application/json | | errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | ## createModelAvailabilityPolicy Create a model availability policy in a workspace. [Management key](https://openrouter.ai/docs/client-sdks/typescript/docs/guides/overview/auth/management-api-keys) required. ### Example Usage ```typescript theme={null} import { OpenRouter } from "@openrouter/sdk"; const openRouter = new OpenRouter({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const result = await openRouter.guardrailPolicies.createModelAvailabilityPolicy({ createModelAvailabilityGuardrailPolicyRequest: { config: {}, name: "Engineering monthly budget", policyType: "model_availability", }, }); console.log(result); } run(); ``` ### Standalone function The standalone function version of this method: ```typescript theme={null} import { OpenRouterCore } from "@openrouter/sdk/core.js"; import { guardrailPoliciesCreateModelAvailabilityPolicy } from "@openrouter/sdk/funcs/guardrailPoliciesCreateModelAvailabilityPolicy.js"; // Use `OpenRouterCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const openRouter = new OpenRouterCore({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const res = await guardrailPoliciesCreateModelAvailabilityPolicy(openRouter, { createModelAvailabilityGuardrailPolicyRequest: { config: {}, name: "Engineering monthly budget", policyType: "model_availability", }, }); if (res.ok) { const { value: result } = res; console.log(result); } else { console.log("guardrailPoliciesCreateModelAvailabilityPolicy failed:", res.error); } } run(); ``` ### Parameters | Parameter | Type | Required | Description | | - | - | - | - | | `request` | [operations.CreateModelAvailabilityPolicyRequest](../../models/operations/createmodelavailabilitypolicyrequest.mdx) | ✔️ | The request object to use for the request. | | `options` | RequestOptions | ➖ | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.mdx) | ➖ | Enables retrying HTTP requests under certain failure conditions. | ### Response **Promise\<[models.ModelAvailabilityGuardrailPolicyResponse](../../models/modelavailabilityguardrailpolicyresponse.mdx)>** ### Errors | Error Type | Status Code | Content Type | | - | - | - | | errors.BadRequestResponseError | 400 | application/json | | errors.UnauthorizedResponseError | 401 | application/json | | errors.ForbiddenResponseError | 403 | application/json | | errors.NotFoundResponseError | 404 | application/json | | errors.ConflictResponseError | 409 | application/json | | errors.InternalServerResponseError | 500 | application/json | | errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | ## deleteModelAvailabilityPolicy Delete a model availability policy. [Management key](https://openrouter.ai/docs/client-sdks/typescript/docs/guides/overview/auth/management-api-keys) required. ### Example Usage ```typescript theme={null} import { OpenRouter } from "@openrouter/sdk"; const openRouter = new OpenRouter({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const result = await openRouter.guardrailPolicies.deleteModelAvailabilityPolicy({ id: "550e8400-e29b-41d4-a716-446655440000", workspaceId: "0df9e665-d932-5740-b2c7-b52af166bc11", }); console.log(result); } run(); ``` ### Standalone function The standalone function version of this method: ```typescript theme={null} import { OpenRouterCore } from "@openrouter/sdk/core.js"; import { guardrailPoliciesDeleteModelAvailabilityPolicy } from "@openrouter/sdk/funcs/guardrailPoliciesDeleteModelAvailabilityPolicy.js"; // Use `OpenRouterCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const openRouter = new OpenRouterCore({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const res = await guardrailPoliciesDeleteModelAvailabilityPolicy(openRouter, { id: "550e8400-e29b-41d4-a716-446655440000", workspaceId: "0df9e665-d932-5740-b2c7-b52af166bc11", }); if (res.ok) { const { value: result } = res; console.log(result); } else { console.log("guardrailPoliciesDeleteModelAvailabilityPolicy failed:", res.error); } } run(); ``` ### Parameters | Parameter | Type | Required | Description | | - | - | - | - | | `request` | [operations.DeleteModelAvailabilityPolicyRequest](../../models/operations/deletemodelavailabilitypolicyrequest.mdx) | ✔️ | The request object to use for the request. | | `options` | RequestOptions | ➖ | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.mdx) | ➖ | Enables retrying HTTP requests under certain failure conditions. | ### Response **Promise\<[models.DeleteGuardrailPolicyResponse](../../models/deleteguardrailpolicyresponse.mdx)>** ### Errors | Error Type | Status Code | Content Type | | - | - | - | | errors.BadRequestResponseError | 400 | application/json | | errors.UnauthorizedResponseError | 401 | application/json | | errors.ForbiddenResponseError | 403 | application/json | | errors.NotFoundResponseError | 404 | application/json | | errors.ConflictResponseError | 409 | application/json | | errors.InternalServerResponseError | 500 | application/json | | errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | ## getModelAvailabilityPolicy Get a model availability policy with its member and API key assignments. [Management key](https://openrouter.ai/docs/client-sdks/typescript/docs/guides/overview/auth/management-api-keys) required. ### Example Usage ```typescript theme={null} import { OpenRouter } from "@openrouter/sdk"; const openRouter = new OpenRouter({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const result = await openRouter.guardrailPolicies.getModelAvailabilityPolicy({ id: "550e8400-e29b-41d4-a716-446655440000", workspaceId: "0df9e665-d932-5740-b2c7-b52af166bc11", }); console.log(result); } run(); ``` ### Standalone function The standalone function version of this method: ```typescript theme={null} import { OpenRouterCore } from "@openrouter/sdk/core.js"; import { guardrailPoliciesGetModelAvailabilityPolicy } from "@openrouter/sdk/funcs/guardrailPoliciesGetModelAvailabilityPolicy.js"; // Use `OpenRouterCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const openRouter = new OpenRouterCore({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const res = await guardrailPoliciesGetModelAvailabilityPolicy(openRouter, { id: "550e8400-e29b-41d4-a716-446655440000", workspaceId: "0df9e665-d932-5740-b2c7-b52af166bc11", }); if (res.ok) { const { value: result } = res; console.log(result); } else { console.log("guardrailPoliciesGetModelAvailabilityPolicy failed:", res.error); } } run(); ``` ### Parameters | Parameter | Type | Required | Description | | - | - | - | - | | `request` | [operations.GetModelAvailabilityPolicyRequest](../../models/operations/getmodelavailabilitypolicyrequest.mdx) | ✔️ | The request object to use for the request. | | `options` | RequestOptions | ➖ | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.mdx) | ➖ | Enables retrying HTTP requests under certain failure conditions. | ### Response **Promise\<[models.ModelAvailabilityGuardrailPolicyDetailResponse](../../models/modelavailabilityguardrailpolicydetailresponse.mdx)>** ### Errors | Error Type | Status Code | Content Type | | - | - | - | | errors.BadRequestResponseError | 400 | application/json | | errors.UnauthorizedResponseError | 401 | application/json | | errors.ForbiddenResponseError | 403 | application/json | | errors.NotFoundResponseError | 404 | application/json | | errors.InternalServerResponseError | 500 | application/json | | errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | ## updateModelAvailabilityPolicy Replace a model availability policy's name and config, and optionally its assignments. [Management key](https://openrouter.ai/docs/client-sdks/typescript/docs/guides/overview/auth/management-api-keys) required. ### Example Usage ```typescript theme={null} import { OpenRouter } from "@openrouter/sdk"; const openRouter = new OpenRouter({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const result = await openRouter.guardrailPolicies.updateModelAvailabilityPolicy({ id: "550e8400-e29b-41d4-a716-446655440000", updateModelAvailabilityGuardrailPolicyRequest: { config: {}, name: "Engineering monthly budget", }, }); console.log(result); } run(); ``` ### Standalone function The standalone function version of this method: ```typescript theme={null} import { OpenRouterCore } from "@openrouter/sdk/core.js"; import { guardrailPoliciesUpdateModelAvailabilityPolicy } from "@openrouter/sdk/funcs/guardrailPoliciesUpdateModelAvailabilityPolicy.js"; // Use `OpenRouterCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const openRouter = new OpenRouterCore({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const res = await guardrailPoliciesUpdateModelAvailabilityPolicy(openRouter, { id: "550e8400-e29b-41d4-a716-446655440000", updateModelAvailabilityGuardrailPolicyRequest: { config: {}, name: "Engineering monthly budget", }, }); if (res.ok) { const { value: result } = res; console.log(result); } else { console.log("guardrailPoliciesUpdateModelAvailabilityPolicy failed:", res.error); } } run(); ``` ### Parameters | Parameter | Type | Required | Description | | - | - | - | - | | `request` | [operations.UpdateModelAvailabilityPolicyRequest](../../models/operations/updatemodelavailabilitypolicyrequest.mdx) | ✔️ | The request object to use for the request. | | `options` | RequestOptions | ➖ | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.mdx) | ➖ | Enables retrying HTTP requests under certain failure conditions. | ### Response **Promise\<[models.ModelAvailabilityGuardrailPolicyResponse](../../models/modelavailabilityguardrailpolicyresponse.mdx)>** ### Errors | Error Type | Status Code | Content Type | | - | - | - | | errors.BadRequestResponseError | 400 | application/json | | errors.UnauthorizedResponseError | 401 | application/json | | errors.ForbiddenResponseError | 403 | application/json | | errors.NotFoundResponseError | 404 | application/json | | errors.ConflictResponseError | 409 | application/json | | errors.InternalServerResponseError | 500 | application/json | | errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | ## listModerationPolicies List the moderation policies in a workspace. [Management key](https://openrouter.ai/docs/client-sdks/typescript/docs/guides/overview/auth/management-api-keys) required. ### Example Usage ```typescript theme={null} import { OpenRouter } from "@openrouter/sdk"; const openRouter = new OpenRouter({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const result = await openRouter.guardrailPolicies.listModerationPolicies(); for await (const page of result) { console.log(page); } } run(); ``` ### Standalone function The standalone function version of this method: ```typescript theme={null} import { OpenRouterCore } from "@openrouter/sdk/core.js"; import { guardrailPoliciesListModerationPolicies } from "@openrouter/sdk/funcs/guardrailPoliciesListModerationPolicies.js"; // Use `OpenRouterCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const openRouter = new OpenRouterCore({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const res = await guardrailPoliciesListModerationPolicies(openRouter); if (res.ok) { const { value: result } = res; for await (const page of result) { console.log(page); } } else { console.log("guardrailPoliciesListModerationPolicies failed:", res.error); } } run(); ``` ### Parameters | Parameter | Type | Required | Description | | - | - | - | - | | `request` | [operations.ListModerationPoliciesRequest](../../models/operations/listmoderationpoliciesrequest.mdx) | ✔️ | The request object to use for the request. | | `options` | RequestOptions | ➖ | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.mdx) | ➖ | Enables retrying HTTP requests under certain failure conditions. | ### Response **Promise\<[operations.ListModerationPoliciesResponse](../../models/operations/listmoderationpoliciesresponse.mdx)>** ### Errors | Error Type | Status Code | Content Type | | - | - | - | | errors.BadRequestResponseError | 400 | application/json | | errors.UnauthorizedResponseError | 401 | application/json | | errors.ForbiddenResponseError | 403 | application/json | | errors.NotFoundResponseError | 404 | application/json | | errors.InternalServerResponseError | 500 | application/json | | errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | ## createModerationPolicy Create a moderation policy in a workspace. [Management key](https://openrouter.ai/docs/client-sdks/typescript/docs/guides/overview/auth/management-api-keys) required. ### Example Usage ```typescript theme={null} import { OpenRouter } from "@openrouter/sdk"; const openRouter = new OpenRouter({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const result = await openRouter.guardrailPolicies.createModerationPolicy({ createModerationGuardrailPolicyRequest: { config: {}, name: "Engineering monthly budget", policyType: "moderation", }, }); console.log(result); } run(); ``` ### Standalone function The standalone function version of this method: ```typescript theme={null} import { OpenRouterCore } from "@openrouter/sdk/core.js"; import { guardrailPoliciesCreateModerationPolicy } from "@openrouter/sdk/funcs/guardrailPoliciesCreateModerationPolicy.js"; // Use `OpenRouterCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const openRouter = new OpenRouterCore({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const res = await guardrailPoliciesCreateModerationPolicy(openRouter, { createModerationGuardrailPolicyRequest: { config: {}, name: "Engineering monthly budget", policyType: "moderation", }, }); if (res.ok) { const { value: result } = res; console.log(result); } else { console.log("guardrailPoliciesCreateModerationPolicy failed:", res.error); } } run(); ``` ### Parameters | Parameter | Type | Required | Description | | - | - | - | - | | `request` | [operations.CreateModerationPolicyRequest](../../models/operations/createmoderationpolicyrequest.mdx) | ✔️ | The request object to use for the request. | | `options` | RequestOptions | ➖ | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.mdx) | ➖ | Enables retrying HTTP requests under certain failure conditions. | ### Response **Promise\<[models.ModerationGuardrailPolicyResponse](../../models/moderationguardrailpolicyresponse.mdx)>** ### Errors | Error Type | Status Code | Content Type | | - | - | - | | errors.BadRequestResponseError | 400 | application/json | | errors.UnauthorizedResponseError | 401 | application/json | | errors.ForbiddenResponseError | 403 | application/json | | errors.NotFoundResponseError | 404 | application/json | | errors.ConflictResponseError | 409 | application/json | | errors.InternalServerResponseError | 500 | application/json | | errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | ## deleteModerationPolicy Delete a moderation policy. [Management key](https://openrouter.ai/docs/client-sdks/typescript/docs/guides/overview/auth/management-api-keys) required. ### Example Usage ```typescript theme={null} import { OpenRouter } from "@openrouter/sdk"; const openRouter = new OpenRouter({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const result = await openRouter.guardrailPolicies.deleteModerationPolicy({ id: "550e8400-e29b-41d4-a716-446655440000", workspaceId: "0df9e665-d932-5740-b2c7-b52af166bc11", }); console.log(result); } run(); ``` ### Standalone function The standalone function version of this method: ```typescript theme={null} import { OpenRouterCore } from "@openrouter/sdk/core.js"; import { guardrailPoliciesDeleteModerationPolicy } from "@openrouter/sdk/funcs/guardrailPoliciesDeleteModerationPolicy.js"; // Use `OpenRouterCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const openRouter = new OpenRouterCore({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const res = await guardrailPoliciesDeleteModerationPolicy(openRouter, { id: "550e8400-e29b-41d4-a716-446655440000", workspaceId: "0df9e665-d932-5740-b2c7-b52af166bc11", }); if (res.ok) { const { value: result } = res; console.log(result); } else { console.log("guardrailPoliciesDeleteModerationPolicy failed:", res.error); } } run(); ``` ### Parameters | Parameter | Type | Required | Description | | - | - | - | - | | `request` | [operations.DeleteModerationPolicyRequest](../../models/operations/deletemoderationpolicyrequest.mdx) | ✔️ | The request object to use for the request. | | `options` | RequestOptions | ➖ | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.mdx) | ➖ | Enables retrying HTTP requests under certain failure conditions. | ### Response **Promise\<[models.DeleteGuardrailPolicyResponse](../../models/deleteguardrailpolicyresponse.mdx)>** ### Errors | Error Type | Status Code | Content Type | | - | - | - | | errors.BadRequestResponseError | 400 | application/json | | errors.UnauthorizedResponseError | 401 | application/json | | errors.ForbiddenResponseError | 403 | application/json | | errors.NotFoundResponseError | 404 | application/json | | errors.ConflictResponseError | 409 | application/json | | errors.InternalServerResponseError | 500 | application/json | | errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | ## getModerationPolicy Get a moderation policy with its member and API key assignments. [Management key](https://openrouter.ai/docs/client-sdks/typescript/docs/guides/overview/auth/management-api-keys) required. ### Example Usage ```typescript theme={null} import { OpenRouter } from "@openrouter/sdk"; const openRouter = new OpenRouter({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const result = await openRouter.guardrailPolicies.getModerationPolicy({ id: "550e8400-e29b-41d4-a716-446655440000", workspaceId: "0df9e665-d932-5740-b2c7-b52af166bc11", }); console.log(result); } run(); ``` ### Standalone function The standalone function version of this method: ```typescript theme={null} import { OpenRouterCore } from "@openrouter/sdk/core.js"; import { guardrailPoliciesGetModerationPolicy } from "@openrouter/sdk/funcs/guardrailPoliciesGetModerationPolicy.js"; // Use `OpenRouterCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const openRouter = new OpenRouterCore({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const res = await guardrailPoliciesGetModerationPolicy(openRouter, { id: "550e8400-e29b-41d4-a716-446655440000", workspaceId: "0df9e665-d932-5740-b2c7-b52af166bc11", }); if (res.ok) { const { value: result } = res; console.log(result); } else { console.log("guardrailPoliciesGetModerationPolicy failed:", res.error); } } run(); ``` ### Parameters | Parameter | Type | Required | Description | | - | - | - | - | | `request` | [operations.GetModerationPolicyRequest](../../models/operations/getmoderationpolicyrequest.mdx) | ✔️ | The request object to use for the request. | | `options` | RequestOptions | ➖ | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.mdx) | ➖ | Enables retrying HTTP requests under certain failure conditions. | ### Response **Promise\<[models.ModerationGuardrailPolicyDetailResponse](../../models/moderationguardrailpolicydetailresponse.mdx)>** ### Errors | Error Type | Status Code | Content Type | | - | - | - | | errors.BadRequestResponseError | 400 | application/json | | errors.UnauthorizedResponseError | 401 | application/json | | errors.ForbiddenResponseError | 403 | application/json | | errors.NotFoundResponseError | 404 | application/json | | errors.InternalServerResponseError | 500 | application/json | | errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | ## updateModerationPolicy Replace a moderation policy's name and config, and optionally its assignments. [Management key](https://openrouter.ai/docs/client-sdks/typescript/docs/guides/overview/auth/management-api-keys) required. ### Example Usage ```typescript theme={null} import { OpenRouter } from "@openrouter/sdk"; const openRouter = new OpenRouter({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const result = await openRouter.guardrailPolicies.updateModerationPolicy({ id: "550e8400-e29b-41d4-a716-446655440000", updateModerationGuardrailPolicyRequest: { config: {}, name: "Engineering monthly budget", }, }); console.log(result); } run(); ``` ### Standalone function The standalone function version of this method: ```typescript theme={null} import { OpenRouterCore } from "@openrouter/sdk/core.js"; import { guardrailPoliciesUpdateModerationPolicy } from "@openrouter/sdk/funcs/guardrailPoliciesUpdateModerationPolicy.js"; // Use `OpenRouterCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const openRouter = new OpenRouterCore({ httpReferer: "", appTitle: "", appCategories: "", apiKey: process.env["OPENROUTER_API_KEY"] ?? "", }); async function run() { const res = await guardrailPoliciesUpdateModerationPolicy(openRouter, { id: "550e8400-e29b-41d4-a716-446655440000", updateModerationGuardrailPolicyRequest: { config: {}, name: "Engineering monthly budget", }, }); if (res.ok) { const { value: result } = res; console.log(result); } else { console.log("guardrailPoliciesUpdateModerationPolicy failed:", res.error); } } run(); ``` ### Parameters | Parameter | Type | Required | Description | | - | - | - | - | | `request` | [operations.UpdateModerationPolicyRequest](../../models/operations/updatemoderationpolicyrequest.mdx) | ✔️ | The request object to use for the request. | | `options` | RequestOptions | ➖ | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.mdx) | ➖ | Enables retrying HTTP requests under certain failure conditions. | ### Response **Promise\<[models.ModerationGuardrailPolicyResponse](../../models/moderationguardrailpolicyresponse.mdx)>** ### Errors | Error Type | Status Code | Content Type | | - | - | - | | errors.BadRequestResponseError | 400 | application/json | | errors.UnauthorizedResponseError | 401 | application/json | | errors.ForbiddenResponseError | 403 | application/json | | errors.NotFoundResponseError | 404 | application/json | | errors.ConflictResponseError | 409 | application/json | | errors.InternalServerResponseError | 500 | application/json | | errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |