For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
ModelsChatRankingsDocs
DocsAPI ReferenceClient SDKsAgent SDKCookbookChangelog
DocsAPI ReferenceClient SDKsAgent SDKCookbookChangelog
    • Overview
    • Usage for Agents
  • TypeScript SDK
    • Overview
      • Analytics
      • APIKeys
      • Byok
      • Chat
      • Credits
      • Embeddings
      • Endpoints
      • Generations
      • Guardrails
      • OAuth
      • Observability
      • Organization
      • Presets
      • Providers
      • Rerank
      • Beta.Responses
      • Transcriptions
      • Speech
      • VideoGeneration
      • Workspaces
  • Python SDK
    • Overview
  • Go SDK
  • DevTools
    • Overview
    • Migrating to @openrouter/agent
LogoLogo
ModelsChatRankingsDocs
On this page
  • Overview
  • Available Operations
  • list
  • Example Usage
  • Standalone function
  • Parameters
  • Response
  • Errors
  • create
  • Example Usage
  • Standalone function
  • Parameters
  • Response
  • Errors
  • delete
  • Example Usage
  • Standalone function
  • Parameters
  • Response
  • Errors
  • get
  • Example Usage
  • Standalone function
  • Parameters
  • Response
  • Errors
  • update
  • Example Usage
  • Standalone function
  • Parameters
  • Response
  • Errors
  • listGuardrailKeyAssignments
  • Example Usage
  • Standalone function
  • Parameters
  • Response
  • Errors
  • bulkAssignKeys
  • Example Usage
  • Standalone function
  • Parameters
  • Response
  • Errors
  • bulkUnassignKeys
  • Example Usage
  • Standalone function
  • Parameters
  • Response
  • Errors
  • listGuardrailMemberAssignments
  • Example Usage
  • Standalone function
  • Parameters
  • Response
  • Errors
  • bulkAssignMembers
  • Example Usage
  • Standalone function
  • Parameters
  • Response
  • Errors
  • bulkUnassignMembers
  • Example Usage
  • Standalone function
  • Parameters
  • Response
  • Errors
  • listKeyAssignments
  • Example Usage
  • Standalone function
  • Parameters
  • Response
  • Errors
  • listMemberAssignments
  • Example Usage
  • Standalone function
  • Parameters
  • Response
  • Errors
TypeScript SDKAPI Reference

Guardrails - TypeScript SDK

Guardrails method reference
Was this page helpful?
Previous

Models - TypeScript SDK

Models method reference
Next
Built with

The TypeScript SDK and docs are currently in beta. Report issues on GitHub.

Overview

Guardrails endpoints

Available Operations

  • list - List guardrails
  • create - Create a guardrail
  • delete - Delete a guardrail
  • get - Get a guardrail
  • update - Update a guardrail
  • listGuardrailKeyAssignments - List key assignments for a guardrail
  • bulkAssignKeys - Bulk assign keys to a guardrail
  • bulkUnassignKeys - Bulk unassign keys from a guardrail
  • listGuardrailMemberAssignments - List member assignments for a guardrail
  • bulkAssignMembers - Bulk assign members to a guardrail
  • bulkUnassignMembers - Bulk unassign members from a guardrail
  • listKeyAssignments - List all key assignments
  • listMemberAssignments - List all member assignments

list

List all guardrails for the authenticated user. Management key required.

Example Usage

1import { OpenRouter } from "@openrouter/sdk";
2
3const openRouter = new OpenRouter({
4 httpReferer: "<value>",
5 appTitle: "<value>",
6 appCategories: "<value>",
7 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
8});
9
10async function run() {
11 const result = await openRouter.guardrails.list();
12
13 for await (const page of result) {
14 console.log(page);
15 }
16}
17
18run();

Standalone function

The standalone function version of this method:

1import { OpenRouterCore } from "@openrouter/sdk/core.js";
2import { guardrailsList } from "@openrouter/sdk/funcs/guardrailsList.js";
3
4// Use `OpenRouterCore` for best tree-shaking performance.
5// You can create one instance of it to use across an application.
6const openRouter = new OpenRouterCore({
7 httpReferer: "<value>",
8 appTitle: "<value>",
9 appCategories: "<value>",
10 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
11});
12
13async function run() {
14 const res = await guardrailsList(openRouter);
15 if (res.ok) {
16 const { value: result } = res;
17 for await (const page of result) {
18 console.log(page);
19 }
20 } else {
21 console.log("guardrailsList failed:", res.error);
22 }
23}
24
25run();

Parameters

ParameterTypeRequiredDescription
requestoperations.ListGuardrailsRequest✔️The request object to use for the request.
optionsRequestOptions➖Used to set various options for making HTTP requests.
options.fetchOptionsRequestInit➖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.retriesRetryConfig➖Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.ListGuardrailsResponse>

Errors

Error TypeStatus CodeContent Type
errors.UnauthorizedResponseError401application/json
errors.InternalServerResponseError500application/json
errors.OpenRouterDefaultError4XX, 5XX*/*

create

Create a new guardrail for the authenticated user. Management key required.

Example Usage

1import { OpenRouter } from "@openrouter/sdk";
2
3const openRouter = new OpenRouter({
4 httpReferer: "<value>",
5 appTitle: "<value>",
6 appCategories: "<value>",
7 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
8});
9
10async function run() {
11 const result = await openRouter.guardrails.create({
12 createGuardrailRequest: {
13 allowedModels: null,
14 allowedProviders: [
15 "openai",
16 "anthropic",
17 "deepseek",
18 ],
19 description: "A guardrail for limiting API usage",
20 enforceZdrAnthropic: true,
21 enforceZdrGoogle: false,
22 enforceZdrOpenai: true,
23 enforceZdrOther: false,
24 ignoredModels: null,
25 ignoredProviders: null,
26 limitUsd: 50,
27 name: "My New Guardrail",
28 resetInterval: "monthly",
29 },
30 });
31
32 console.log(result);
33}
34
35run();

Standalone function

The standalone function version of this method:

1import { OpenRouterCore } from "@openrouter/sdk/core.js";
2import { guardrailsCreate } from "@openrouter/sdk/funcs/guardrailsCreate.js";
3
4// Use `OpenRouterCore` for best tree-shaking performance.
5// You can create one instance of it to use across an application.
6const openRouter = new OpenRouterCore({
7 httpReferer: "<value>",
8 appTitle: "<value>",
9 appCategories: "<value>",
10 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
11});
12
13async function run() {
14 const res = await guardrailsCreate(openRouter, {
15 createGuardrailRequest: {
16 allowedModels: null,
17 allowedProviders: [
18 "openai",
19 "anthropic",
20 "deepseek",
21 ],
22 description: "A guardrail for limiting API usage",
23 enforceZdrAnthropic: true,
24 enforceZdrGoogle: false,
25 enforceZdrOpenai: true,
26 enforceZdrOther: false,
27 ignoredModels: null,
28 ignoredProviders: null,
29 limitUsd: 50,
30 name: "My New Guardrail",
31 resetInterval: "monthly",
32 },
33 });
34 if (res.ok) {
35 const { value: result } = res;
36 console.log(result);
37 } else {
38 console.log("guardrailsCreate failed:", res.error);
39 }
40}
41
42run();

Parameters

ParameterTypeRequiredDescription
requestoperations.CreateGuardrailRequest✔️The request object to use for the request.
optionsRequestOptions➖Used to set various options for making HTTP requests.
options.fetchOptionsRequestInit➖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.retriesRetryConfig➖Enables retrying HTTP requests under certain failure conditions.

Response

Promise<models.CreateGuardrailResponse>

Errors

Error TypeStatus CodeContent Type
errors.BadRequestResponseError400application/json
errors.UnauthorizedResponseError401application/json
errors.ForbiddenResponseError403application/json
errors.InternalServerResponseError500application/json
errors.OpenRouterDefaultError4XX, 5XX*/*

delete

Delete an existing guardrail. Management key required.

Example Usage

1import { OpenRouter } from "@openrouter/sdk";
2
3const openRouter = new OpenRouter({
4 httpReferer: "<value>",
5 appTitle: "<value>",
6 appCategories: "<value>",
7 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
8});
9
10async function run() {
11 const result = await openRouter.guardrails.delete({
12 id: "550e8400-e29b-41d4-a716-446655440000",
13 });
14
15 console.log(result);
16}
17
18run();

Standalone function

The standalone function version of this method:

1import { OpenRouterCore } from "@openrouter/sdk/core.js";
2import { guardrailsDelete } from "@openrouter/sdk/funcs/guardrailsDelete.js";
3
4// Use `OpenRouterCore` for best tree-shaking performance.
5// You can create one instance of it to use across an application.
6const openRouter = new OpenRouterCore({
7 httpReferer: "<value>",
8 appTitle: "<value>",
9 appCategories: "<value>",
10 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
11});
12
13async function run() {
14 const res = await guardrailsDelete(openRouter, {
15 id: "550e8400-e29b-41d4-a716-446655440000",
16 });
17 if (res.ok) {
18 const { value: result } = res;
19 console.log(result);
20 } else {
21 console.log("guardrailsDelete failed:", res.error);
22 }
23}
24
25run();

Parameters

ParameterTypeRequiredDescription
requestoperations.DeleteGuardrailRequest✔️The request object to use for the request.
optionsRequestOptions➖Used to set various options for making HTTP requests.
options.fetchOptionsRequestInit➖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.retriesRetryConfig➖Enables retrying HTTP requests under certain failure conditions.

Response

Promise<models.DeleteGuardrailResponse>

Errors

Error TypeStatus CodeContent Type
errors.UnauthorizedResponseError401application/json
errors.NotFoundResponseError404application/json
errors.InternalServerResponseError500application/json
errors.OpenRouterDefaultError4XX, 5XX*/*

get

Get a single guardrail by ID. Management key required.

Example Usage

1import { OpenRouter } from "@openrouter/sdk";
2
3const openRouter = new OpenRouter({
4 httpReferer: "<value>",
5 appTitle: "<value>",
6 appCategories: "<value>",
7 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
8});
9
10async function run() {
11 const result = await openRouter.guardrails.get({
12 id: "550e8400-e29b-41d4-a716-446655440000",
13 });
14
15 console.log(result);
16}
17
18run();

Standalone function

The standalone function version of this method:

1import { OpenRouterCore } from "@openrouter/sdk/core.js";
2import { guardrailsGet } from "@openrouter/sdk/funcs/guardrailsGet.js";
3
4// Use `OpenRouterCore` for best tree-shaking performance.
5// You can create one instance of it to use across an application.
6const openRouter = new OpenRouterCore({
7 httpReferer: "<value>",
8 appTitle: "<value>",
9 appCategories: "<value>",
10 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
11});
12
13async function run() {
14 const res = await guardrailsGet(openRouter, {
15 id: "550e8400-e29b-41d4-a716-446655440000",
16 });
17 if (res.ok) {
18 const { value: result } = res;
19 console.log(result);
20 } else {
21 console.log("guardrailsGet failed:", res.error);
22 }
23}
24
25run();

Parameters

ParameterTypeRequiredDescription
requestoperations.GetGuardrailRequest✔️The request object to use for the request.
optionsRequestOptions➖Used to set various options for making HTTP requests.
options.fetchOptionsRequestInit➖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.retriesRetryConfig➖Enables retrying HTTP requests under certain failure conditions.

Response

Promise<models.GetGuardrailResponse>

Errors

Error TypeStatus CodeContent Type
errors.UnauthorizedResponseError401application/json
errors.NotFoundResponseError404application/json
errors.InternalServerResponseError500application/json
errors.OpenRouterDefaultError4XX, 5XX*/*

update

Update an existing guardrail. Management key required.

Example Usage

1import { OpenRouter } from "@openrouter/sdk";
2
3const openRouter = new OpenRouter({
4 httpReferer: "<value>",
5 appTitle: "<value>",
6 appCategories: "<value>",
7 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
8});
9
10async function run() {
11 const result = await openRouter.guardrails.update({
12 id: "550e8400-e29b-41d4-a716-446655440000",
13 updateGuardrailRequest: {
14 description: "Updated description",
15 limitUsd: 75,
16 name: "Updated Guardrail Name",
17 resetInterval: "weekly",
18 },
19 });
20
21 console.log(result);
22}
23
24run();

Standalone function

The standalone function version of this method:

1import { OpenRouterCore } from "@openrouter/sdk/core.js";
2import { guardrailsUpdate } from "@openrouter/sdk/funcs/guardrailsUpdate.js";
3
4// Use `OpenRouterCore` for best tree-shaking performance.
5// You can create one instance of it to use across an application.
6const openRouter = new OpenRouterCore({
7 httpReferer: "<value>",
8 appTitle: "<value>",
9 appCategories: "<value>",
10 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
11});
12
13async function run() {
14 const res = await guardrailsUpdate(openRouter, {
15 id: "550e8400-e29b-41d4-a716-446655440000",
16 updateGuardrailRequest: {
17 description: "Updated description",
18 limitUsd: 75,
19 name: "Updated Guardrail Name",
20 resetInterval: "weekly",
21 },
22 });
23 if (res.ok) {
24 const { value: result } = res;
25 console.log(result);
26 } else {
27 console.log("guardrailsUpdate failed:", res.error);
28 }
29}
30
31run();

Parameters

ParameterTypeRequiredDescription
requestoperations.UpdateGuardrailRequest✔️The request object to use for the request.
optionsRequestOptions➖Used to set various options for making HTTP requests.
options.fetchOptionsRequestInit➖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.retriesRetryConfig➖Enables retrying HTTP requests under certain failure conditions.

Response

Promise<models.UpdateGuardrailResponse>

Errors

Error TypeStatus CodeContent Type
errors.BadRequestResponseError400application/json
errors.UnauthorizedResponseError401application/json
errors.NotFoundResponseError404application/json
errors.InternalServerResponseError500application/json
errors.OpenRouterDefaultError4XX, 5XX*/*

listGuardrailKeyAssignments

List all API key assignments for a specific guardrail. Management key required.

Example Usage

1import { OpenRouter } from "@openrouter/sdk";
2
3const openRouter = new OpenRouter({
4 httpReferer: "<value>",
5 appTitle: "<value>",
6 appCategories: "<value>",
7 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
8});
9
10async function run() {
11 const result = await openRouter.guardrails.listGuardrailKeyAssignments({
12 id: "550e8400-e29b-41d4-a716-446655440000",
13 });
14
15 for await (const page of result) {
16 console.log(page);
17 }
18}
19
20run();

Standalone function

The standalone function version of this method:

1import { OpenRouterCore } from "@openrouter/sdk/core.js";
2import { guardrailsListGuardrailKeyAssignments } from "@openrouter/sdk/funcs/guardrailsListGuardrailKeyAssignments.js";
3
4// Use `OpenRouterCore` for best tree-shaking performance.
5// You can create one instance of it to use across an application.
6const openRouter = new OpenRouterCore({
7 httpReferer: "<value>",
8 appTitle: "<value>",
9 appCategories: "<value>",
10 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
11});
12
13async function run() {
14 const res = await guardrailsListGuardrailKeyAssignments(openRouter, {
15 id: "550e8400-e29b-41d4-a716-446655440000",
16 });
17 if (res.ok) {
18 const { value: result } = res;
19 for await (const page of result) {
20 console.log(page);
21 }
22 } else {
23 console.log("guardrailsListGuardrailKeyAssignments failed:", res.error);
24 }
25}
26
27run();

Parameters

ParameterTypeRequiredDescription
requestoperations.ListGuardrailKeyAssignmentsRequest✔️The request object to use for the request.
optionsRequestOptions➖Used to set various options for making HTTP requests.
options.fetchOptionsRequestInit➖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.retriesRetryConfig➖Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.ListGuardrailKeyAssignmentsResponse>

Errors

Error TypeStatus CodeContent Type
errors.UnauthorizedResponseError401application/json
errors.NotFoundResponseError404application/json
errors.InternalServerResponseError500application/json
errors.OpenRouterDefaultError4XX, 5XX*/*

bulkAssignKeys

Assign multiple API keys to a specific guardrail. Management key required.

Example Usage

1import { OpenRouter } from "@openrouter/sdk";
2
3const openRouter = new OpenRouter({
4 httpReferer: "<value>",
5 appTitle: "<value>",
6 appCategories: "<value>",
7 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
8});
9
10async function run() {
11 const result = await openRouter.guardrails.bulkAssignKeys({
12 id: "550e8400-e29b-41d4-a716-446655440000",
13 bulkAssignKeysRequest: {
14 keyHashes: [
15 "c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93",
16 ],
17 },
18 });
19
20 console.log(result);
21}
22
23run();

Standalone function

The standalone function version of this method:

1import { OpenRouterCore } from "@openrouter/sdk/core.js";
2import { guardrailsBulkAssignKeys } from "@openrouter/sdk/funcs/guardrailsBulkAssignKeys.js";
3
4// Use `OpenRouterCore` for best tree-shaking performance.
5// You can create one instance of it to use across an application.
6const openRouter = new OpenRouterCore({
7 httpReferer: "<value>",
8 appTitle: "<value>",
9 appCategories: "<value>",
10 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
11});
12
13async function run() {
14 const res = await guardrailsBulkAssignKeys(openRouter, {
15 id: "550e8400-e29b-41d4-a716-446655440000",
16 bulkAssignKeysRequest: {
17 keyHashes: [
18 "c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93",
19 ],
20 },
21 });
22 if (res.ok) {
23 const { value: result } = res;
24 console.log(result);
25 } else {
26 console.log("guardrailsBulkAssignKeys failed:", res.error);
27 }
28}
29
30run();

Parameters

ParameterTypeRequiredDescription
requestoperations.BulkAssignKeysToGuardrailRequest✔️The request object to use for the request.
optionsRequestOptions➖Used to set various options for making HTTP requests.
options.fetchOptionsRequestInit➖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.retriesRetryConfig➖Enables retrying HTTP requests under certain failure conditions.

Response

Promise<models.BulkAssignKeysResponse>

Errors

Error TypeStatus CodeContent Type
errors.BadRequestResponseError400application/json
errors.UnauthorizedResponseError401application/json
errors.NotFoundResponseError404application/json
errors.InternalServerResponseError500application/json
errors.OpenRouterDefaultError4XX, 5XX*/*

bulkUnassignKeys

Unassign multiple API keys from a specific guardrail. Management key required.

Example Usage

1import { OpenRouter } from "@openrouter/sdk";
2
3const openRouter = new OpenRouter({
4 httpReferer: "<value>",
5 appTitle: "<value>",
6 appCategories: "<value>",
7 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
8});
9
10async function run() {
11 const result = await openRouter.guardrails.bulkUnassignKeys({
12 id: "550e8400-e29b-41d4-a716-446655440000",
13 bulkUnassignKeysRequest: {
14 keyHashes: [
15 "c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93",
16 ],
17 },
18 });
19
20 console.log(result);
21}
22
23run();

Standalone function

The standalone function version of this method:

1import { OpenRouterCore } from "@openrouter/sdk/core.js";
2import { guardrailsBulkUnassignKeys } from "@openrouter/sdk/funcs/guardrailsBulkUnassignKeys.js";
3
4// Use `OpenRouterCore` for best tree-shaking performance.
5// You can create one instance of it to use across an application.
6const openRouter = new OpenRouterCore({
7 httpReferer: "<value>",
8 appTitle: "<value>",
9 appCategories: "<value>",
10 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
11});
12
13async function run() {
14 const res = await guardrailsBulkUnassignKeys(openRouter, {
15 id: "550e8400-e29b-41d4-a716-446655440000",
16 bulkUnassignKeysRequest: {
17 keyHashes: [
18 "c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93",
19 ],
20 },
21 });
22 if (res.ok) {
23 const { value: result } = res;
24 console.log(result);
25 } else {
26 console.log("guardrailsBulkUnassignKeys failed:", res.error);
27 }
28}
29
30run();

Parameters

ParameterTypeRequiredDescription
requestoperations.BulkUnassignKeysFromGuardrailRequest✔️The request object to use for the request.
optionsRequestOptions➖Used to set various options for making HTTP requests.
options.fetchOptionsRequestInit➖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.retriesRetryConfig➖Enables retrying HTTP requests under certain failure conditions.

Response

Promise<models.BulkUnassignKeysResponse>

Errors

Error TypeStatus CodeContent Type
errors.BadRequestResponseError400application/json
errors.UnauthorizedResponseError401application/json
errors.NotFoundResponseError404application/json
errors.InternalServerResponseError500application/json
errors.OpenRouterDefaultError4XX, 5XX*/*

listGuardrailMemberAssignments

List all organization member assignments for a specific guardrail. Management key required.

Example Usage

1import { OpenRouter } from "@openrouter/sdk";
2
3const openRouter = new OpenRouter({
4 httpReferer: "<value>",
5 appTitle: "<value>",
6 appCategories: "<value>",
7 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
8});
9
10async function run() {
11 const result = await openRouter.guardrails.listGuardrailMemberAssignments({
12 id: "550e8400-e29b-41d4-a716-446655440000",
13 });
14
15 for await (const page of result) {
16 console.log(page);
17 }
18}
19
20run();

Standalone function

The standalone function version of this method:

1import { OpenRouterCore } from "@openrouter/sdk/core.js";
2import { guardrailsListGuardrailMemberAssignments } from "@openrouter/sdk/funcs/guardrailsListGuardrailMemberAssignments.js";
3
4// Use `OpenRouterCore` for best tree-shaking performance.
5// You can create one instance of it to use across an application.
6const openRouter = new OpenRouterCore({
7 httpReferer: "<value>",
8 appTitle: "<value>",
9 appCategories: "<value>",
10 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
11});
12
13async function run() {
14 const res = await guardrailsListGuardrailMemberAssignments(openRouter, {
15 id: "550e8400-e29b-41d4-a716-446655440000",
16 });
17 if (res.ok) {
18 const { value: result } = res;
19 for await (const page of result) {
20 console.log(page);
21 }
22 } else {
23 console.log("guardrailsListGuardrailMemberAssignments failed:", res.error);
24 }
25}
26
27run();

Parameters

ParameterTypeRequiredDescription
requestoperations.ListGuardrailMemberAssignmentsRequest✔️The request object to use for the request.
optionsRequestOptions➖Used to set various options for making HTTP requests.
options.fetchOptionsRequestInit➖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.retriesRetryConfig➖Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.ListGuardrailMemberAssignmentsResponse>

Errors

Error TypeStatus CodeContent Type
errors.UnauthorizedResponseError401application/json
errors.NotFoundResponseError404application/json
errors.InternalServerResponseError500application/json
errors.OpenRouterDefaultError4XX, 5XX*/*

bulkAssignMembers

Assign multiple organization members to a specific guardrail. Management key required.

Example Usage

1import { OpenRouter } from "@openrouter/sdk";
2
3const openRouter = new OpenRouter({
4 httpReferer: "<value>",
5 appTitle: "<value>",
6 appCategories: "<value>",
7 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
8});
9
10async function run() {
11 const result = await openRouter.guardrails.bulkAssignMembers({
12 id: "550e8400-e29b-41d4-a716-446655440000",
13 bulkAssignMembersRequest: {
14 memberUserIds: [
15 "user_abc123",
16 "user_def456",
17 ],
18 },
19 });
20
21 console.log(result);
22}
23
24run();

Standalone function

The standalone function version of this method:

1import { OpenRouterCore } from "@openrouter/sdk/core.js";
2import { guardrailsBulkAssignMembers } from "@openrouter/sdk/funcs/guardrailsBulkAssignMembers.js";
3
4// Use `OpenRouterCore` for best tree-shaking performance.
5// You can create one instance of it to use across an application.
6const openRouter = new OpenRouterCore({
7 httpReferer: "<value>",
8 appTitle: "<value>",
9 appCategories: "<value>",
10 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
11});
12
13async function run() {
14 const res = await guardrailsBulkAssignMembers(openRouter, {
15 id: "550e8400-e29b-41d4-a716-446655440000",
16 bulkAssignMembersRequest: {
17 memberUserIds: [
18 "user_abc123",
19 "user_def456",
20 ],
21 },
22 });
23 if (res.ok) {
24 const { value: result } = res;
25 console.log(result);
26 } else {
27 console.log("guardrailsBulkAssignMembers failed:", res.error);
28 }
29}
30
31run();

Parameters

ParameterTypeRequiredDescription
requestoperations.BulkAssignMembersToGuardrailRequest✔️The request object to use for the request.
optionsRequestOptions➖Used to set various options for making HTTP requests.
options.fetchOptionsRequestInit➖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.retriesRetryConfig➖Enables retrying HTTP requests under certain failure conditions.

Response

Promise<models.BulkAssignMembersResponse>

Errors

Error TypeStatus CodeContent Type
errors.BadRequestResponseError400application/json
errors.UnauthorizedResponseError401application/json
errors.NotFoundResponseError404application/json
errors.InternalServerResponseError500application/json
errors.OpenRouterDefaultError4XX, 5XX*/*

bulkUnassignMembers

Unassign multiple organization members from a specific guardrail. Management key required.

Example Usage

1import { OpenRouter } from "@openrouter/sdk";
2
3const openRouter = new OpenRouter({
4 httpReferer: "<value>",
5 appTitle: "<value>",
6 appCategories: "<value>",
7 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
8});
9
10async function run() {
11 const result = await openRouter.guardrails.bulkUnassignMembers({
12 id: "550e8400-e29b-41d4-a716-446655440000",
13 bulkUnassignMembersRequest: {
14 memberUserIds: [
15 "user_abc123",
16 "user_def456",
17 ],
18 },
19 });
20
21 console.log(result);
22}
23
24run();

Standalone function

The standalone function version of this method:

1import { OpenRouterCore } from "@openrouter/sdk/core.js";
2import { guardrailsBulkUnassignMembers } from "@openrouter/sdk/funcs/guardrailsBulkUnassignMembers.js";
3
4// Use `OpenRouterCore` for best tree-shaking performance.
5// You can create one instance of it to use across an application.
6const openRouter = new OpenRouterCore({
7 httpReferer: "<value>",
8 appTitle: "<value>",
9 appCategories: "<value>",
10 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
11});
12
13async function run() {
14 const res = await guardrailsBulkUnassignMembers(openRouter, {
15 id: "550e8400-e29b-41d4-a716-446655440000",
16 bulkUnassignMembersRequest: {
17 memberUserIds: [
18 "user_abc123",
19 "user_def456",
20 ],
21 },
22 });
23 if (res.ok) {
24 const { value: result } = res;
25 console.log(result);
26 } else {
27 console.log("guardrailsBulkUnassignMembers failed:", res.error);
28 }
29}
30
31run();

Parameters

ParameterTypeRequiredDescription
requestoperations.BulkUnassignMembersFromGuardrailRequest✔️The request object to use for the request.
optionsRequestOptions➖Used to set various options for making HTTP requests.
options.fetchOptionsRequestInit➖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.retriesRetryConfig➖Enables retrying HTTP requests under certain failure conditions.

Response

Promise<models.BulkUnassignMembersResponse>

Errors

Error TypeStatus CodeContent Type
errors.BadRequestResponseError400application/json
errors.UnauthorizedResponseError401application/json
errors.NotFoundResponseError404application/json
errors.InternalServerResponseError500application/json
errors.OpenRouterDefaultError4XX, 5XX*/*

listKeyAssignments

List all API key guardrail assignments for the authenticated user. Management key required.

Example Usage

1import { OpenRouter } from "@openrouter/sdk";
2
3const openRouter = new OpenRouter({
4 httpReferer: "<value>",
5 appTitle: "<value>",
6 appCategories: "<value>",
7 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
8});
9
10async function run() {
11 const result = await openRouter.guardrails.listKeyAssignments();
12
13 for await (const page of result) {
14 console.log(page);
15 }
16}
17
18run();

Standalone function

The standalone function version of this method:

1import { OpenRouterCore } from "@openrouter/sdk/core.js";
2import { guardrailsListKeyAssignments } from "@openrouter/sdk/funcs/guardrailsListKeyAssignments.js";
3
4// Use `OpenRouterCore` for best tree-shaking performance.
5// You can create one instance of it to use across an application.
6const openRouter = new OpenRouterCore({
7 httpReferer: "<value>",
8 appTitle: "<value>",
9 appCategories: "<value>",
10 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
11});
12
13async function run() {
14 const res = await guardrailsListKeyAssignments(openRouter);
15 if (res.ok) {
16 const { value: result } = res;
17 for await (const page of result) {
18 console.log(page);
19 }
20 } else {
21 console.log("guardrailsListKeyAssignments failed:", res.error);
22 }
23}
24
25run();

Parameters

ParameterTypeRequiredDescription
requestoperations.ListKeyAssignmentsRequest✔️The request object to use for the request.
optionsRequestOptions➖Used to set various options for making HTTP requests.
options.fetchOptionsRequestInit➖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.retriesRetryConfig➖Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.ListKeyAssignmentsResponse>

Errors

Error TypeStatus CodeContent Type
errors.UnauthorizedResponseError401application/json
errors.InternalServerResponseError500application/json
errors.OpenRouterDefaultError4XX, 5XX*/*

listMemberAssignments

List all organization member guardrail assignments for the authenticated user. Management key required.

Example Usage

1import { OpenRouter } from "@openrouter/sdk";
2
3const openRouter = new OpenRouter({
4 httpReferer: "<value>",
5 appTitle: "<value>",
6 appCategories: "<value>",
7 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
8});
9
10async function run() {
11 const result = await openRouter.guardrails.listMemberAssignments();
12
13 for await (const page of result) {
14 console.log(page);
15 }
16}
17
18run();

Standalone function

The standalone function version of this method:

1import { OpenRouterCore } from "@openrouter/sdk/core.js";
2import { guardrailsListMemberAssignments } from "@openrouter/sdk/funcs/guardrailsListMemberAssignments.js";
3
4// Use `OpenRouterCore` for best tree-shaking performance.
5// You can create one instance of it to use across an application.
6const openRouter = new OpenRouterCore({
7 httpReferer: "<value>",
8 appTitle: "<value>",
9 appCategories: "<value>",
10 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
11});
12
13async function run() {
14 const res = await guardrailsListMemberAssignments(openRouter);
15 if (res.ok) {
16 const { value: result } = res;
17 for await (const page of result) {
18 console.log(page);
19 }
20 } else {
21 console.log("guardrailsListMemberAssignments failed:", res.error);
22 }
23}
24
25run();

Parameters

ParameterTypeRequiredDescription
requestoperations.ListMemberAssignmentsRequest✔️The request object to use for the request.
optionsRequestOptions➖Used to set various options for making HTTP requests.
options.fetchOptionsRequestInit➖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.retriesRetryConfig➖Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.ListMemberAssignmentsResponse>

Errors

Error TypeStatus CodeContent Type
errors.UnauthorizedResponseError401application/json
errors.InternalServerResponseError500application/json
errors.OpenRouterDefaultError4XX, 5XX*/*