Guardrails - TypeScript SDK

Guardrails method reference

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

Overview

Guardrails endpoints

Available Operations

list

List all guardrails for the authenticated user.

Example Usage

1import { OpenRouter } from "@openrouter/sdk";
2
3const openRouter = new OpenRouter({
4 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
5});
6
7async function run() {
8 const result = await openRouter.guardrails.list();
9
10 console.log(result);
11}
12
13run();

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 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
8});
9
10async function run() {
11 const res = await guardrailsList(openRouter);
12 if (res.ok) {
13 const { value: result } = res;
14 console.log(result);
15 } else {
16 console.log("guardrailsList failed:", res.error);
17 }
18}
19
20run();

Parameters

ParameterTypeRequiredDescription
requestoperations.ListGuardrailsRequest✔️The request object to use for the request.
optionsRequestOptionsUsed to set various options for making HTTP requests.
options.fetchOptionsRequestInitOptions 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.retriesRetryConfigEnables 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.

Example Usage

1import { OpenRouter } from "@openrouter/sdk";
2
3const openRouter = new OpenRouter({
4 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
5});
6
7async function run() {
8 const result = await openRouter.guardrails.create({
9 name: "My New Guardrail",
10 });
11
12 console.log(result);
13}
14
15run();

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 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
8});
9
10async function run() {
11 const res = await guardrailsCreate(openRouter, {
12 name: "My New Guardrail",
13 });
14 if (res.ok) {
15 const { value: result } = res;
16 console.log(result);
17 } else {
18 console.log("guardrailsCreate failed:", res.error);
19 }
20}
21
22run();

Parameters

ParameterTypeRequiredDescription
requestoperations.CreateGuardrailRequest✔️The request object to use for the request.
optionsRequestOptionsUsed to set various options for making HTTP requests.
options.fetchOptionsRequestInitOptions 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.retriesRetryConfigEnables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.CreateGuardrailResponse>

Errors

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

get

Get a single guardrail by ID.

Example Usage

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

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 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
8});
9
10async function run() {
11 const res = await guardrailsGet(openRouter, {
12 id: "550e8400-e29b-41d4-a716-446655440000",
13 });
14 if (res.ok) {
15 const { value: result } = res;
16 console.log(result);
17 } else {
18 console.log("guardrailsGet failed:", res.error);
19 }
20}
21
22run();

Parameters

ParameterTypeRequiredDescription
requestoperations.GetGuardrailRequest✔️The request object to use for the request.
optionsRequestOptionsUsed to set various options for making HTTP requests.
options.fetchOptionsRequestInitOptions 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.retriesRetryConfigEnables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.GetGuardrailResponse>

Errors

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

update

Update an existing guardrail.

Example Usage

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

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 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
8});
9
10async function run() {
11 const res = await guardrailsUpdate(openRouter, {
12 id: "550e8400-e29b-41d4-a716-446655440000",
13 requestBody: {},
14 });
15 if (res.ok) {
16 const { value: result } = res;
17 console.log(result);
18 } else {
19 console.log("guardrailsUpdate failed:", res.error);
20 }
21}
22
23run();

Parameters

ParameterTypeRequiredDescription
requestoperations.UpdateGuardrailRequest✔️The request object to use for the request.
optionsRequestOptionsUsed to set various options for making HTTP requests.
options.fetchOptionsRequestInitOptions 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.retriesRetryConfigEnables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.UpdateGuardrailResponse>

Errors

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

delete

Delete an existing guardrail.

Example Usage

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

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 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
8});
9
10async function run() {
11 const res = await guardrailsDelete(openRouter, {
12 id: "550e8400-e29b-41d4-a716-446655440000",
13 });
14 if (res.ok) {
15 const { value: result } = res;
16 console.log(result);
17 } else {
18 console.log("guardrailsDelete failed:", res.error);
19 }
20}
21
22run();

Parameters

ParameterTypeRequiredDescription
requestoperations.DeleteGuardrailRequest✔️The request object to use for the request.
optionsRequestOptionsUsed to set various options for making HTTP requests.
options.fetchOptionsRequestInitOptions 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.retriesRetryConfigEnables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.DeleteGuardrailResponse>

Errors

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

listKeyAssignments

List all API key guardrail assignments for the authenticated user.

Example Usage

1import { OpenRouter } from "@openrouter/sdk";
2
3const openRouter = new OpenRouter({
4 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
5});
6
7async function run() {
8 const result = await openRouter.guardrails.listKeyAssignments();
9
10 console.log(result);
11}
12
13run();

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 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
8});
9
10async function run() {
11 const res = await guardrailsListKeyAssignments(openRouter);
12 if (res.ok) {
13 const { value: result } = res;
14 console.log(result);
15 } else {
16 console.log("guardrailsListKeyAssignments failed:", res.error);
17 }
18}
19
20run();

Parameters

ParameterTypeRequiredDescription
requestoperations.ListKeyAssignmentsRequest✔️The request object to use for the request.
optionsRequestOptionsUsed to set various options for making HTTP requests.
options.fetchOptionsRequestInitOptions 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.retriesRetryConfigEnables 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.

Example Usage

1import { OpenRouter } from "@openrouter/sdk";
2
3const openRouter = new OpenRouter({
4 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
5});
6
7async function run() {
8 const result = await openRouter.guardrails.listMemberAssignments();
9
10 console.log(result);
11}
12
13run();

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 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
8});
9
10async function run() {
11 const res = await guardrailsListMemberAssignments(openRouter);
12 if (res.ok) {
13 const { value: result } = res;
14 console.log(result);
15 } else {
16 console.log("guardrailsListMemberAssignments failed:", res.error);
17 }
18}
19
20run();

Parameters

ParameterTypeRequiredDescription
requestoperations.ListMemberAssignmentsRequest✔️The request object to use for the request.
optionsRequestOptionsUsed to set various options for making HTTP requests.
options.fetchOptionsRequestInitOptions 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.retriesRetryConfigEnables 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*/*

listGuardrailKeyAssignments

List all API key assignments for a specific guardrail.

Example Usage

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

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 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
8});
9
10async function run() {
11 const res = await guardrailsListGuardrailKeyAssignments(openRouter, {
12 id: "550e8400-e29b-41d4-a716-446655440000",
13 });
14 if (res.ok) {
15 const { value: result } = res;
16 console.log(result);
17 } else {
18 console.log("guardrailsListGuardrailKeyAssignments failed:", res.error);
19 }
20}
21
22run();

Parameters

ParameterTypeRequiredDescription
requestoperations.ListGuardrailKeyAssignmentsRequest✔️The request object to use for the request.
optionsRequestOptionsUsed to set various options for making HTTP requests.
options.fetchOptionsRequestInitOptions 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.retriesRetryConfigEnables 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.

Example Usage

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

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 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
8});
9
10async function run() {
11 const res = await guardrailsBulkAssignKeys(openRouter, {
12 id: "550e8400-e29b-41d4-a716-446655440000",
13 requestBody: {
14 keyHashes: [
15 "c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93",
16 ],
17 },
18 });
19 if (res.ok) {
20 const { value: result } = res;
21 console.log(result);
22 } else {
23 console.log("guardrailsBulkAssignKeys failed:", res.error);
24 }
25}
26
27run();

Parameters

ParameterTypeRequiredDescription
requestoperations.BulkAssignKeysToGuardrailRequest✔️The request object to use for the request.
optionsRequestOptionsUsed to set various options for making HTTP requests.
options.fetchOptionsRequestInitOptions 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.retriesRetryConfigEnables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.BulkAssignKeysToGuardrailResponse>

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.

Example Usage

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

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 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
8});
9
10async function run() {
11 const res = await guardrailsListGuardrailMemberAssignments(openRouter, {
12 id: "550e8400-e29b-41d4-a716-446655440000",
13 });
14 if (res.ok) {
15 const { value: result } = res;
16 console.log(result);
17 } else {
18 console.log("guardrailsListGuardrailMemberAssignments failed:", res.error);
19 }
20}
21
22run();

Parameters

ParameterTypeRequiredDescription
requestoperations.ListGuardrailMemberAssignmentsRequest✔️The request object to use for the request.
optionsRequestOptionsUsed to set various options for making HTTP requests.
options.fetchOptionsRequestInitOptions 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.retriesRetryConfigEnables 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.

Example Usage

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

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 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
8});
9
10async function run() {
11 const res = await guardrailsBulkAssignMembers(openRouter, {
12 id: "550e8400-e29b-41d4-a716-446655440000",
13 requestBody: {
14 memberUserIds: [
15 "user_abc123",
16 "user_def456",
17 ],
18 },
19 });
20 if (res.ok) {
21 const { value: result } = res;
22 console.log(result);
23 } else {
24 console.log("guardrailsBulkAssignMembers failed:", res.error);
25 }
26}
27
28run();

Parameters

ParameterTypeRequiredDescription
requestoperations.BulkAssignMembersToGuardrailRequest✔️The request object to use for the request.
optionsRequestOptionsUsed to set various options for making HTTP requests.
options.fetchOptionsRequestInitOptions 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.retriesRetryConfigEnables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.BulkAssignMembersToGuardrailResponse>

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.

Example Usage

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

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 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
8});
9
10async function run() {
11 const res = await guardrailsBulkUnassignKeys(openRouter, {
12 id: "550e8400-e29b-41d4-a716-446655440000",
13 requestBody: {
14 keyHashes: [
15 "c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93",
16 ],
17 },
18 });
19 if (res.ok) {
20 const { value: result } = res;
21 console.log(result);
22 } else {
23 console.log("guardrailsBulkUnassignKeys failed:", res.error);
24 }
25}
26
27run();

Parameters

ParameterTypeRequiredDescription
requestoperations.BulkUnassignKeysFromGuardrailRequest✔️The request object to use for the request.
optionsRequestOptionsUsed to set various options for making HTTP requests.
options.fetchOptionsRequestInitOptions 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.retriesRetryConfigEnables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.BulkUnassignKeysFromGuardrailResponse>

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.

Example Usage

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

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 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
8});
9
10async function run() {
11 const res = await guardrailsBulkUnassignMembers(openRouter, {
12 id: "550e8400-e29b-41d4-a716-446655440000",
13 requestBody: {
14 memberUserIds: [
15 "user_abc123",
16 "user_def456",
17 ],
18 },
19 });
20 if (res.ok) {
21 const { value: result } = res;
22 console.log(result);
23 } else {
24 console.log("guardrailsBulkUnassignMembers failed:", res.error);
25 }
26}
27
28run();

Parameters

ParameterTypeRequiredDescription
requestoperations.BulkUnassignMembersFromGuardrailRequest✔️The request object to use for the request.
optionsRequestOptionsUsed to set various options for making HTTP requests.
options.fetchOptionsRequestInitOptions 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.retriesRetryConfigEnables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.BulkUnassignMembersFromGuardrailResponse>

Errors

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