Guardrails - TypeScript SDK
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
- get - Get a guardrail
- update - Update a guardrail
- delete - Delete a guardrail
- listKeyAssignments - List all key assignments
- listMemberAssignments - List all member assignments
- listGuardrailKeyAssignments - List key assignments for a guardrail
- bulkAssignKeys - Bulk assign keys to a guardrail
- listGuardrailMemberAssignments - List member assignments for a guardrail
- bulkAssignMembers - Bulk assign members to a guardrail
- bulkUnassignKeys - Bulk unassign keys from a guardrail
- bulkUnassignMembers - Bulk unassign members from a guardrail
list
List all guardrails for the authenticated user.
Example Usage
1 import { OpenRouter } from "@openrouter/sdk"; 2 3 const openRouter = new OpenRouter({ 4 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 5 }); 6 7 async function run() { 8 const result = await openRouter.guardrails.list(); 9 10 console.log(result); 11 } 12 13 run();
Standalone function
The standalone function version of this method:
1 import { OpenRouterCore } from "@openrouter/sdk/core.js"; 2 import { 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. 6 const openRouter = new OpenRouterCore({ 7 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 8 }); 9 10 async 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 20 run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.ListGuardrailsRequest | ✔️ | The request object to use for the request. |
options | RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions | RequestInit | ➖ | 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 | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<operations.ListGuardrailsResponse>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | */* |
create
Create a new guardrail for the authenticated user.
Example Usage
1 import { OpenRouter } from "@openrouter/sdk"; 2 3 const openRouter = new OpenRouter({ 4 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 5 }); 6 7 async function run() { 8 const result = await openRouter.guardrails.create({ 9 name: "My New Guardrail", 10 }); 11 12 console.log(result); 13 } 14 15 run();
Standalone function
The standalone function version of this method:
1 import { OpenRouterCore } from "@openrouter/sdk/core.js"; 2 import { 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. 6 const openRouter = new OpenRouterCore({ 7 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 8 }); 9 10 async 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 22 run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.CreateGuardrailRequest | ✔️ | The request object to use for the request. |
options | RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions | RequestInit | ➖ | 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 | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<operations.CreateGuardrailResponse>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | */* |
get
Get a single guardrail by ID.
Example Usage
1 import { OpenRouter } from "@openrouter/sdk"; 2 3 const openRouter = new OpenRouter({ 4 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 5 }); 6 7 async function run() { 8 const result = await openRouter.guardrails.get({ 9 id: "550e8400-e29b-41d4-a716-446655440000", 10 }); 11 12 console.log(result); 13 } 14 15 run();
Standalone function
The standalone function version of this method:
1 import { OpenRouterCore } from "@openrouter/sdk/core.js"; 2 import { 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. 6 const openRouter = new OpenRouterCore({ 7 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 8 }); 9 10 async 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 22 run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.GetGuardrailRequest | ✔️ | The request object to use for the request. |
options | RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions | RequestInit | ➖ | 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 | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<operations.GetGuardrailResponse>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | */* |
update
Update an existing guardrail.
Example Usage
1 import { OpenRouter } from "@openrouter/sdk"; 2 3 const openRouter = new OpenRouter({ 4 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 5 }); 6 7 async 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 16 run();
Standalone function
The standalone function version of this method:
1 import { OpenRouterCore } from "@openrouter/sdk/core.js"; 2 import { 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. 6 const openRouter = new OpenRouterCore({ 7 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 8 }); 9 10 async 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 23 run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.UpdateGuardrailRequest | ✔️ | The request object to use for the request. |
options | RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions | RequestInit | ➖ | 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 | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<operations.UpdateGuardrailResponse>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | */* |
delete
Delete an existing guardrail.
Example Usage
1 import { OpenRouter } from "@openrouter/sdk"; 2 3 const openRouter = new OpenRouter({ 4 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 5 }); 6 7 async function run() { 8 const result = await openRouter.guardrails.delete({ 9 id: "550e8400-e29b-41d4-a716-446655440000", 10 }); 11 12 console.log(result); 13 } 14 15 run();
Standalone function
The standalone function version of this method:
1 import { OpenRouterCore } from "@openrouter/sdk/core.js"; 2 import { 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. 6 const openRouter = new OpenRouterCore({ 7 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 8 }); 9 10 async 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 22 run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.DeleteGuardrailRequest | ✔️ | The request object to use for the request. |
options | RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions | RequestInit | ➖ | 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 | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<operations.DeleteGuardrailResponse>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | */* |
listKeyAssignments
List all API key guardrail assignments for the authenticated user.
Example Usage
1 import { OpenRouter } from "@openrouter/sdk"; 2 3 const openRouter = new OpenRouter({ 4 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 5 }); 6 7 async function run() { 8 const result = await openRouter.guardrails.listKeyAssignments(); 9 10 console.log(result); 11 } 12 13 run();
Standalone function
The standalone function version of this method:
1 import { OpenRouterCore } from "@openrouter/sdk/core.js"; 2 import { 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. 6 const openRouter = new OpenRouterCore({ 7 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 8 }); 9 10 async 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 20 run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.ListKeyAssignmentsRequest | ✔️ | The request object to use for the request. |
options | RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions | RequestInit | ➖ | 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 | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<operations.ListKeyAssignmentsResponse>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | */* |
listMemberAssignments
List all organization member guardrail assignments for the authenticated user.
Example Usage
1 import { OpenRouter } from "@openrouter/sdk"; 2 3 const openRouter = new OpenRouter({ 4 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 5 }); 6 7 async function run() { 8 const result = await openRouter.guardrails.listMemberAssignments(); 9 10 console.log(result); 11 } 12 13 run();
Standalone function
The standalone function version of this method:
1 import { OpenRouterCore } from "@openrouter/sdk/core.js"; 2 import { 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. 6 const openRouter = new OpenRouterCore({ 7 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 8 }); 9 10 async 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 20 run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.ListMemberAssignmentsRequest | ✔️ | The request object to use for the request. |
options | RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions | RequestInit | ➖ | 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 | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<operations.ListMemberAssignmentsResponse>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | */* |
listGuardrailKeyAssignments
List all API key assignments for a specific guardrail.
Example Usage
1 import { OpenRouter } from "@openrouter/sdk"; 2 3 const openRouter = new OpenRouter({ 4 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 5 }); 6 7 async function run() { 8 const result = await openRouter.guardrails.listGuardrailKeyAssignments({ 9 id: "550e8400-e29b-41d4-a716-446655440000", 10 }); 11 12 console.log(result); 13 } 14 15 run();
Standalone function
The standalone function version of this method:
1 import { OpenRouterCore } from "@openrouter/sdk/core.js"; 2 import { 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. 6 const openRouter = new OpenRouterCore({ 7 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 8 }); 9 10 async 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 22 run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.ListGuardrailKeyAssignmentsRequest | ✔️ | The request object to use for the request. |
options | RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions | RequestInit | ➖ | 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 | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<operations.ListGuardrailKeyAssignmentsResponse>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | */* |
bulkAssignKeys
Assign multiple API keys to a specific guardrail.
Example Usage
1 import { OpenRouter } from "@openrouter/sdk"; 2 3 const openRouter = new OpenRouter({ 4 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 5 }); 6 7 async 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 20 run();
Standalone function
The standalone function version of this method:
1 import { OpenRouterCore } from "@openrouter/sdk/core.js"; 2 import { 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. 6 const openRouter = new OpenRouterCore({ 7 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 8 }); 9 10 async 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 27 run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.BulkAssignKeysToGuardrailRequest | ✔️ | The request object to use for the request. |
options | RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions | RequestInit | ➖ | 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 | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<operations.BulkAssignKeysToGuardrailResponse>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | */* |
listGuardrailMemberAssignments
List all organization member assignments for a specific guardrail.
Example Usage
1 import { OpenRouter } from "@openrouter/sdk"; 2 3 const openRouter = new OpenRouter({ 4 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 5 }); 6 7 async function run() { 8 const result = await openRouter.guardrails.listGuardrailMemberAssignments({ 9 id: "550e8400-e29b-41d4-a716-446655440000", 10 }); 11 12 console.log(result); 13 } 14 15 run();
Standalone function
The standalone function version of this method:
1 import { OpenRouterCore } from "@openrouter/sdk/core.js"; 2 import { 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. 6 const openRouter = new OpenRouterCore({ 7 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 8 }); 9 10 async 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 22 run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.ListGuardrailMemberAssignmentsRequest | ✔️ | The request object to use for the request. |
options | RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions | RequestInit | ➖ | 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 | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<operations.ListGuardrailMemberAssignmentsResponse>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | */* |
bulkAssignMembers
Assign multiple organization members to a specific guardrail.
Example Usage
1 import { OpenRouter } from "@openrouter/sdk"; 2 3 const openRouter = new OpenRouter({ 4 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 5 }); 6 7 async 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 21 run();
Standalone function
The standalone function version of this method:
1 import { OpenRouterCore } from "@openrouter/sdk/core.js"; 2 import { 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. 6 const openRouter = new OpenRouterCore({ 7 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 8 }); 9 10 async 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 28 run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.BulkAssignMembersToGuardrailRequest | ✔️ | The request object to use for the request. |
options | RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions | RequestInit | ➖ | 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 | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<operations.BulkAssignMembersToGuardrailResponse>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | */* |
bulkUnassignKeys
Unassign multiple API keys from a specific guardrail.
Example Usage
1 import { OpenRouter } from "@openrouter/sdk"; 2 3 const openRouter = new OpenRouter({ 4 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 5 }); 6 7 async 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 20 run();
Standalone function
The standalone function version of this method:
1 import { OpenRouterCore } from "@openrouter/sdk/core.js"; 2 import { 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. 6 const openRouter = new OpenRouterCore({ 7 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 8 }); 9 10 async 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 27 run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.BulkUnassignKeysFromGuardrailRequest | ✔️ | The request object to use for the request. |
options | RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions | RequestInit | ➖ | 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 | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<operations.BulkUnassignKeysFromGuardrailResponse>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | */* |
bulkUnassignMembers
Unassign multiple organization members from a specific guardrail.
Example Usage
1 import { OpenRouter } from "@openrouter/sdk"; 2 3 const openRouter = new OpenRouter({ 4 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 5 }); 6 7 async 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 21 run();
Standalone function
The standalone function version of this method:
1 import { OpenRouterCore } from "@openrouter/sdk/core.js"; 2 import { 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. 6 const openRouter = new OpenRouterCore({ 7 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 8 }); 9 10 async 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 28 run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.BulkUnassignMembersFromGuardrailRequest | ✔️ | The request object to use for the request. |
options | RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions | RequestInit | ➖ | 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 | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<operations.BulkUnassignMembersFromGuardrailResponse>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | */* |