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. Management key required.
Example Usage
1 import { OpenRouter } from "@openrouter/sdk"; 2 3 const openRouter = new OpenRouter({ 4 httpReferer: "<value>", 5 appTitle: "<value>", 6 appCategories: "<value>", 7 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 8 }); 9 10 async function run() { 11 const result = await openRouter.guardrails.list(); 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 { 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 httpReferer: "<value>", 8 appTitle: "<value>", 9 appCategories: "<value>", 10 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 11 }); 12 13 async function run() { 14 const res = await guardrailsList(openRouter); 15 if (res.ok) { 16 const { value: result } = res; 17 console.log(result); 18 } else { 19 console.log("guardrailsList failed:", res.error); 20 } 21 } 22 23 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. Management key required.
Example Usage
1 import { OpenRouter } from "@openrouter/sdk"; 2 3 const openRouter = new OpenRouter({ 4 httpReferer: "<value>", 5 appTitle: "<value>", 6 appCategories: "<value>", 7 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 8 }); 9 10 async function run() { 11 const result = await openRouter.guardrails.create({ 12 requestBody: { 13 name: "My New Guardrail", 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 { 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 httpReferer: "<value>", 8 appTitle: "<value>", 9 appCategories: "<value>", 10 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 11 }); 12 13 async function run() { 14 const res = await guardrailsCreate(openRouter, { 15 requestBody: { 16 name: "My New Guardrail", 17 }, 18 }); 19 if (res.ok) { 20 const { value: result } = res; 21 console.log(result); 22 } else { 23 console.log("guardrailsCreate failed:", res.error); 24 } 25 } 26 27 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. Management key required.
Example Usage
1 import { OpenRouter } from "@openrouter/sdk"; 2 3 const openRouter = new OpenRouter({ 4 httpReferer: "<value>", 5 appTitle: "<value>", 6 appCategories: "<value>", 7 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 8 }); 9 10 async function run() { 11 const result = await openRouter.guardrails.get({ 12 id: "550e8400-e29b-41d4-a716-446655440000", 13 }); 14 15 console.log(result); 16 } 17 18 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 httpReferer: "<value>", 8 appTitle: "<value>", 9 appCategories: "<value>", 10 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 11 }); 12 13 async 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 25 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. Management key required.
Example Usage
1 import { OpenRouter } from "@openrouter/sdk"; 2 3 const openRouter = new OpenRouter({ 4 httpReferer: "<value>", 5 appTitle: "<value>", 6 appCategories: "<value>", 7 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 8 }); 9 10 async function run() { 11 const result = await openRouter.guardrails.update({ 12 id: "550e8400-e29b-41d4-a716-446655440000", 13 requestBody: {}, 14 }); 15 16 console.log(result); 17 } 18 19 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 httpReferer: "<value>", 8 appTitle: "<value>", 9 appCategories: "<value>", 10 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 11 }); 12 13 async function run() { 14 const res = await guardrailsUpdate(openRouter, { 15 id: "550e8400-e29b-41d4-a716-446655440000", 16 requestBody: {}, 17 }); 18 if (res.ok) { 19 const { value: result } = res; 20 console.log(result); 21 } else { 22 console.log("guardrailsUpdate failed:", res.error); 23 } 24 } 25 26 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. Management key required.
Example Usage
1 import { OpenRouter } from "@openrouter/sdk"; 2 3 const openRouter = new OpenRouter({ 4 httpReferer: "<value>", 5 appTitle: "<value>", 6 appCategories: "<value>", 7 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 8 }); 9 10 async function run() { 11 const result = await openRouter.guardrails.delete({ 12 id: "550e8400-e29b-41d4-a716-446655440000", 13 }); 14 15 console.log(result); 16 } 17 18 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 httpReferer: "<value>", 8 appTitle: "<value>", 9 appCategories: "<value>", 10 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 11 }); 12 13 async 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 25 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. Management key required.
Example Usage
1 import { OpenRouter } from "@openrouter/sdk"; 2 3 const openRouter = new OpenRouter({ 4 httpReferer: "<value>", 5 appTitle: "<value>", 6 appCategories: "<value>", 7 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 8 }); 9 10 async function run() { 11 const result = await openRouter.guardrails.listKeyAssignments(); 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 { 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 httpReferer: "<value>", 8 appTitle: "<value>", 9 appCategories: "<value>", 10 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 11 }); 12 13 async function run() { 14 const res = await guardrailsListKeyAssignments(openRouter); 15 if (res.ok) { 16 const { value: result } = res; 17 console.log(result); 18 } else { 19 console.log("guardrailsListKeyAssignments failed:", res.error); 20 } 21 } 22 23 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. Management key required.
Example Usage
1 import { OpenRouter } from "@openrouter/sdk"; 2 3 const openRouter = new OpenRouter({ 4 httpReferer: "<value>", 5 appTitle: "<value>", 6 appCategories: "<value>", 7 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 8 }); 9 10 async function run() { 11 const result = await openRouter.guardrails.listMemberAssignments(); 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 { 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 httpReferer: "<value>", 8 appTitle: "<value>", 9 appCategories: "<value>", 10 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 11 }); 12 13 async function run() { 14 const res = await guardrailsListMemberAssignments(openRouter); 15 if (res.ok) { 16 const { value: result } = res; 17 console.log(result); 18 } else { 19 console.log("guardrailsListMemberAssignments failed:", res.error); 20 } 21 } 22 23 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. Management key required.
Example Usage
1 import { OpenRouter } from "@openrouter/sdk"; 2 3 const openRouter = new OpenRouter({ 4 httpReferer: "<value>", 5 appTitle: "<value>", 6 appCategories: "<value>", 7 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 8 }); 9 10 async function run() { 11 const result = await openRouter.guardrails.listGuardrailKeyAssignments({ 12 id: "550e8400-e29b-41d4-a716-446655440000", 13 }); 14 15 console.log(result); 16 } 17 18 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 httpReferer: "<value>", 8 appTitle: "<value>", 9 appCategories: "<value>", 10 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 11 }); 12 13 async 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 console.log(result); 20 } else { 21 console.log("guardrailsListGuardrailKeyAssignments failed:", res.error); 22 } 23 } 24 25 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. Management key required.
Example Usage
1 import { OpenRouter } from "@openrouter/sdk"; 2 3 const openRouter = new OpenRouter({ 4 httpReferer: "<value>", 5 appTitle: "<value>", 6 appCategories: "<value>", 7 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 8 }); 9 10 async function run() { 11 const result = await openRouter.guardrails.bulkAssignKeys({ 12 id: "550e8400-e29b-41d4-a716-446655440000", 13 requestBody: { 14 keyHashes: [ 15 "c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93", 16 ], 17 }, 18 }); 19 20 console.log(result); 21 } 22 23 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 httpReferer: "<value>", 8 appTitle: "<value>", 9 appCategories: "<value>", 10 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 11 }); 12 13 async function run() { 14 const res = await guardrailsBulkAssignKeys(openRouter, { 15 id: "550e8400-e29b-41d4-a716-446655440000", 16 requestBody: { 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 30 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. Management key required.
Example Usage
1 import { OpenRouter } from "@openrouter/sdk"; 2 3 const openRouter = new OpenRouter({ 4 httpReferer: "<value>", 5 appTitle: "<value>", 6 appCategories: "<value>", 7 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 8 }); 9 10 async function run() { 11 const result = await openRouter.guardrails.listGuardrailMemberAssignments({ 12 id: "550e8400-e29b-41d4-a716-446655440000", 13 }); 14 15 console.log(result); 16 } 17 18 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 httpReferer: "<value>", 8 appTitle: "<value>", 9 appCategories: "<value>", 10 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 11 }); 12 13 async 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 console.log(result); 20 } else { 21 console.log("guardrailsListGuardrailMemberAssignments failed:", res.error); 22 } 23 } 24 25 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. Management key required.
Example Usage
1 import { OpenRouter } from "@openrouter/sdk"; 2 3 const openRouter = new OpenRouter({ 4 httpReferer: "<value>", 5 appTitle: "<value>", 6 appCategories: "<value>", 7 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 8 }); 9 10 async function run() { 11 const result = await openRouter.guardrails.bulkAssignMembers({ 12 id: "550e8400-e29b-41d4-a716-446655440000", 13 requestBody: { 14 memberUserIds: [ 15 "user_abc123", 16 "user_def456", 17 ], 18 }, 19 }); 20 21 console.log(result); 22 } 23 24 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 httpReferer: "<value>", 8 appTitle: "<value>", 9 appCategories: "<value>", 10 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 11 }); 12 13 async function run() { 14 const res = await guardrailsBulkAssignMembers(openRouter, { 15 id: "550e8400-e29b-41d4-a716-446655440000", 16 requestBody: { 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 31 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. Management key required.
Example Usage
1 import { OpenRouter } from "@openrouter/sdk"; 2 3 const openRouter = new OpenRouter({ 4 httpReferer: "<value>", 5 appTitle: "<value>", 6 appCategories: "<value>", 7 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 8 }); 9 10 async function run() { 11 const result = await openRouter.guardrails.bulkUnassignKeys({ 12 id: "550e8400-e29b-41d4-a716-446655440000", 13 requestBody: { 14 keyHashes: [ 15 "c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93", 16 ], 17 }, 18 }); 19 20 console.log(result); 21 } 22 23 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 httpReferer: "<value>", 8 appTitle: "<value>", 9 appCategories: "<value>", 10 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 11 }); 12 13 async function run() { 14 const res = await guardrailsBulkUnassignKeys(openRouter, { 15 id: "550e8400-e29b-41d4-a716-446655440000", 16 requestBody: { 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 30 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. Management key required.
Example Usage
1 import { OpenRouter } from "@openrouter/sdk"; 2 3 const openRouter = new OpenRouter({ 4 httpReferer: "<value>", 5 appTitle: "<value>", 6 appCategories: "<value>", 7 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 8 }); 9 10 async function run() { 11 const result = await openRouter.guardrails.bulkUnassignMembers({ 12 id: "550e8400-e29b-41d4-a716-446655440000", 13 requestBody: { 14 memberUserIds: [ 15 "user_abc123", 16 "user_def456", 17 ], 18 }, 19 }); 20 21 console.log(result); 22 } 23 24 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 httpReferer: "<value>", 8 appTitle: "<value>", 9 appCategories: "<value>", 10 apiKey: process.env["OPENROUTER_API_KEY"] ?? "", 11 }); 12 13 async function run() { 14 const res = await guardrailsBulkUnassignMembers(openRouter, { 15 id: "550e8400-e29b-41d4-a716-446655440000", 16 requestBody: { 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 31 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 | */* |