> ## Documentation Index
> Fetch the complete documentation index at: https://openrouter.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Guardrail Policies

> Guardrail Policies endpoints

## Overview

Guardrail Policies endpoints

### Available Operations

* [list\_account\_policies](#list_account_policies) - List workspace-wide policies
* [create\_account\_policy](#create_account_policy) - Create a workspace-wide policy
* [delete\_account\_policy](#delete_account_policy) - Delete a workspace-wide policy
* [update\_account\_policy](#update_account_policy) - Update a workspace-wide policy
* [get\_api\_key\_policy\_assignment](#get_api_key_policy_assignment) - Get an API key policy assignment
* [change\_api\_key\_policy\_assignment](#change_api_key_policy_assignment) - Change an API key policy assignment
* [get\_member\_policy\_assignment](#get_member_policy_assignment) - Get a member policy assignment
* [change\_member\_policy\_assignment](#change_member_policy_assignment) - Change a member policy assignment
* [list\_scim\_group\_policy\_assignments](#list_scim_group_policy_assignments) - List SCIM group policy assignments
* [get\_scim\_group\_policy\_assignment](#get_scim_group_policy_assignment) - Get a SCIM group policy assignment
* [update\_scim\_group\_policy\_assignment](#update_scim_group_policy_assignment) - Update a SCIM group policy assignment
* [delete\_scim\_group\_policy\_opt\_out](#delete_scim_group_policy_opt_out) - Restore a member to a SCIM group policy
* [list\_scim\_group\_policy\_opt\_outs](#list_scim_group_policy_opt_outs) - List opt-outs from a SCIM group policy assignment
* [list\_budget\_policies](#list_budget_policies) - List budget policies
* [create\_budget\_policy](#create_budget_policy) - Create a budget policy
* [delete\_budget\_policy](#delete_budget_policy) - Delete a budget policy
* [get\_budget\_policy](#get_budget_policy) - Get a budget policy
* [update\_budget\_policy](#update_budget_policy) - Update a budget policy
* [list\_capacity\_policies](#list_capacity_policies) - List capacity policies
* [create\_capacity\_policy](#create_capacity_policy) - Create a capacity policy
* [delete\_capacity\_policy](#delete_capacity_policy) - Delete a capacity policy
* [get\_capacity\_policy](#get_capacity_policy) - Get a capacity policy
* [update\_capacity\_policy](#update_capacity_policy) - Update a capacity policy
* [list\_model\_availability\_policies](#list_model_availability_policies) - List model availability policies
* [create\_model\_availability\_policy](#create_model_availability_policy) - Create a model availability policy
* [delete\_model\_availability\_policy](#delete_model_availability_policy) - Delete a model availability policy
* [get\_model\_availability\_policy](#get_model_availability_policy) - Get a model availability policy
* [update\_model\_availability\_policy](#update_model_availability_policy) - Update a model availability policy
* [list\_moderation\_policies](#list_moderation_policies) - List moderation policies
* [create\_moderation\_policy](#create_moderation_policy) - Create a moderation policy
* [delete\_moderation\_policy](#delete_moderation_policy) - Delete a moderation policy
* [get\_moderation\_policy](#get_moderation_policy) - Get a moderation policy
* [update\_moderation\_policy](#update_moderation_policy) - Update a moderation policy

## list\_account\_policies

List the workspace-wide policies that apply across workspaces in the account. [Management key](https://openrouter.ai/docs/client-sdks/python/docs/guides/overview/auth/management-api-keys) required.

### Example Usage

```python theme={null}
from openrouter import OpenRouter
import os


with OpenRouter(
    http_referer="<value>",
    x_open_router_title="<value>",
    x_open_router_categories="<value>",
    api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:

    res = open_router.guardrail_policies.list_account_policies()

    while res is not None:
        # Handle items

        res = res.next()

```

### Parameters

| Parameter | Type | Required | Description | Example |
| - | - | - | - | - |
| `http_referer` | *Optional\[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings. This is used to track API usage per application.  | |
| `x_open_router_title` | *Optional\[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.  | |
| `x_open_router_categories` | *Optional\[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.  | |
| `offset` | *Optional\[int]* | ➖ | Number of records to skip for pagination. When both offset and limit are omitted, the full list is returned | 0 |
| `limit` | *Optional\[int]* | ➖ | Maximum number of records to return (max 100). When both offset and limit are omitted, the full list is returned | 50 |
| `retries` | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | |

### Response

**[operations.ListAccountPoliciesResponse](../../operations/listaccountpoliciesresponse.mdx)**

### Errors

| Error Type | Status Code | Content Type |
| - | - | - |
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |

## create\_account\_policy

Create a workspace-wide budget, moderation, or model availability policy. [Management key](https://openrouter.ai/docs/client-sdks/python/docs/guides/overview/auth/management-api-keys) required.

### Example Usage

```python theme={null}
from openrouter import OpenRouter
import os


with OpenRouter(
    http_referer="<value>",
    x_open_router_title="<value>",
    x_open_router_categories="<value>",
    api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:

    res = open_router.guardrail_policies.create_account_policy(account_guardrail_policy_request={
        "config": {
            "include_byok_in_budgets": False,
            "limit_usd": 200.0,
            "reset_interval": "monthly",
        },
        "name": "Engineering monthly budget",
        "policy_type": "budget",
    })

    # Handle response
    print(res)

```

### Parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `account_guardrail_policy_request` | [components.AccountGuardrailPolicyRequest](../../components/accountguardrailpolicyrequest.mdx) | ✔️ | N/A |
| `http_referer` | *Optional\[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings. This is used to track API usage per application.  |
| `x_open_router_title` | *Optional\[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.  |
| `x_open_router_categories` | *Optional\[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.  |
| `retries` | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. |

### Response

**[components.AccountGuardrailPolicyResponse](../../components/accountguardrailpolicyresponse.mdx)**

### Errors

| Error Type | Status Code | Content Type |
| - | - | - |
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.ConflictResponseError | 409 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |

## delete\_account\_policy

Delete a workspace-wide policy. [Management key](https://openrouter.ai/docs/client-sdks/python/docs/guides/overview/auth/management-api-keys) required.

### Example Usage

```python theme={null}
from openrouter import OpenRouter
import os


with OpenRouter(
    http_referer="<value>",
    x_open_router_title="<value>",
    x_open_router_categories="<value>",
    api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:

    res = open_router.guardrail_policies.delete_account_policy(id="550e8400-e29b-41d4-a716-446655440000")

    # Handle response
    print(res)

```

### Parameters

| Parameter | Type | Required | Description | Example |
| - | - | - | - | - |
| `id` | *str* | ✔️ | Policy ID | 550e8400-e29b-41d4-a716-446655440000 |
| `http_referer` | *Optional\[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings. This is used to track API usage per application.  | |
| `x_open_router_title` | *Optional\[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.  | |
| `x_open_router_categories` | *Optional\[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.  | |
| `retries` | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | |

### Response

**[components.DeleteGuardrailPolicyResponse](../../components/deleteguardrailpolicyresponse.mdx)**

### Errors

| Error Type | Status Code | Content Type |
| - | - | - |
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.ConflictResponseError | 409 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |

## update\_account\_policy

Replace a workspace-wide policy and its workspace coverage. [Management key](https://openrouter.ai/docs/client-sdks/python/docs/guides/overview/auth/management-api-keys) required.

### Example Usage

```python theme={null}
from openrouter import OpenRouter
import os


with OpenRouter(
    http_referer="<value>",
    x_open_router_title="<value>",
    x_open_router_categories="<value>",
    api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:

    res = open_router.guardrail_policies.update_account_policy(id="550e8400-e29b-41d4-a716-446655440000", account_guardrail_policy_request={
        "config": {
            "include_byok_in_budgets": False,
            "limit_usd": 200.0,
            "reset_interval": "monthly",
        },
        "name": "Engineering monthly budget",
        "policy_type": "budget",
    })

    # Handle response
    print(res)

```

### Parameters

| Parameter | Type | Required | Description | Example |
| - | - | - | - | - |
| `id` | *str* | ✔️ | Policy ID | 550e8400-e29b-41d4-a716-446655440000 |
| `account_guardrail_policy_request` | [components.AccountGuardrailPolicyRequest](../../components/accountguardrailpolicyrequest.mdx) | ✔️ | N/A | |
| `http_referer` | *Optional\[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings. This is used to track API usage per application.  | |
| `x_open_router_title` | *Optional\[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.  | |
| `x_open_router_categories` | *Optional\[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.  | |
| `retries` | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | |

### Response

**[components.AccountGuardrailPolicyResponse](../../components/accountguardrailpolicyresponse.mdx)**

### Errors

| Error Type | Status Code | Content Type |
| - | - | - |
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.ConflictResponseError | 409 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |

## get\_api\_key\_policy\_assignment

Get the policies of one type that apply to an API key in a workspace. Requires a management key with write access. [Management key](https://openrouter.ai/docs/client-sdks/python/docs/guides/overview/auth/management-api-keys) required.

### Example Usage

```python theme={null}
from openrouter import OpenRouter
import os


with OpenRouter(
    http_referer="<value>",
    x_open_router_title="<value>",
    x_open_router_categories="<value>",
    api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:

    res = open_router.guardrail_policies.get_api_key_policy_assignment(hash="c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93", policy_type="budget", workspace_id="0df9e665-d932-5740-b2c7-b52af166bc11")

    # Handle response
    print(res)

```

### Parameters

| Parameter | Type | Required | Description | Example |
| - | - | - | - | - |
| `hash` | *str* | ✔️ | API key hash | c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93 |
| `policy_type` | [operations.GetAPIKeyPolicyAssignmentPolicyType](../../operations/getapikeypolicyassignmentpolicytype.mdx) | ✔️ | Policy type the assignment is read or changed for. `rate_limit` is an Enterprise private beta feature and requires an organization-scoped management key and an explicit `workspace_id`. | budget |
| `http_referer` | *Optional\[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings. This is used to track API usage per application.  | |
| `x_open_router_title` | *Optional\[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.  | |
| `x_open_router_categories` | *Optional\[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.  | |
| `workspace_id` | *Optional\[str]* | ➖ | Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other. | 0df9e665-d932-5740-b2c7-b52af166bc11 |
| `retries` | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | |

### Response

**[components.GuardrailPolicyAssignmentResponse](../../components/guardrailpolicyassignmentresponse.mdx)**

### Errors

| Error Type | Status Code | Content Type |
| - | - | - |
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |

## change\_api\_key\_policy\_assignment

Assign or unassign one policy for an API key. Fails with 409 when `expected_assignment` no longer matches the stored state. [Management key](https://openrouter.ai/docs/client-sdks/python/docs/guides/overview/auth/management-api-keys) required.

### Example Usage

```python theme={null}
from openrouter import OpenRouter
import os


with OpenRouter(
    http_referer="<value>",
    x_open_router_title="<value>",
    x_open_router_categories="<value>",
    api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:

    res = open_router.guardrail_policies.change_api_key_policy_assignment(hash="c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93", assigned=True, expected_assignment={
        "opted_out": False,
        "policy_ids": [],
        "workspace_default_policy_ids": [
            "2c6f1a4e-0b7d-4e59-9a61-3f8d2e7c1b90",
        ],
    }, policy_id="550e8400-e29b-41d4-a716-446655440000", policy_type="budget")

    # Handle response
    print(res)

```

### Parameters

| Parameter | Type | Required | Description | Example |
| - | - | - | - | - |
| `hash` | *str* | ✔️ | API key hash | c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93 |
| `assigned` | *bool* | ✔️ | `true` assigns the policy to the subject, `false` removes it | true |
| `expected_assignment` | [components.GuardrailPolicyAssignmentState](../../components/guardrailpolicyassignmentstate.mdx) | ✔️ | N/A | |
| `policy_id` | *str* | ✔️ | Policy ID | 550e8400-e29b-41d4-a716-446655440000 |
| `policy_type` | [components.ChangeGuardrailPolicyAssignmentRequestPolicyType](../../components/changeguardrailpolicyassignmentrequestpolicytype.mdx) | ✔️ | Policy type the assignment is read or changed for. `rate_limit` is an Enterprise private beta feature and requires an organization-scoped management key and an explicit `workspace_id`. | budget |
| `http_referer` | *Optional\[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings. This is used to track API usage per application.  | |
| `x_open_router_title` | *Optional\[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.  | |
| `x_open_router_categories` | *Optional\[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.  | |
| `workspace_id` | *Optional\[str]* | ➖ | Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other. | 0df9e665-d932-5740-b2c7-b52af166bc11 |
| `retries` | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | |

### Response

**[components.ChangeGuardrailPolicyAssignmentResponse](../../components/changeguardrailpolicyassignmentresponse.mdx)**

### Errors

| Error Type | Status Code | Content Type |
| - | - | - |
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.ConflictResponseError | 409 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |

## get\_member\_policy\_assignment

Get the policies of one type that apply to a member in a workspace. Requires a management key with write access. [Management key](https://openrouter.ai/docs/client-sdks/python/docs/guides/overview/auth/management-api-keys) required.

### Example Usage

```python theme={null}
from openrouter import OpenRouter
import os


with OpenRouter(
    http_referer="<value>",
    x_open_router_title="<value>",
    x_open_router_categories="<value>",
    api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:

    res = open_router.guardrail_policies.get_member_policy_assignment(member_id="user_2abcDEFghiJKLmnoPQRstu", policy_type="budget", workspace_id="0df9e665-d932-5740-b2c7-b52af166bc11")

    # Handle response
    print(res)

```

### Parameters

| Parameter | Type | Required | Description | Example |
| - | - | - | - | - |
| `member_id` | *str* | ✔️ | Organization member user ID | user\_2abcDEFghiJKLmnoPQRstu |
| `policy_type` | [operations.GetMemberPolicyAssignmentPolicyType](../../operations/getmemberpolicyassignmentpolicytype.mdx) | ✔️ | Policy type the assignment is read or changed for. `rate_limit` is an Enterprise private beta feature and requires an organization-scoped management key and an explicit `workspace_id`. | budget |
| `http_referer` | *Optional\[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings. This is used to track API usage per application.  | |
| `x_open_router_title` | *Optional\[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.  | |
| `x_open_router_categories` | *Optional\[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.  | |
| `workspace_id` | *Optional\[str]* | ➖ | Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other. | 0df9e665-d932-5740-b2c7-b52af166bc11 |
| `retries` | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | |

### Response

**[components.GuardrailPolicyAssignmentResponse](../../components/guardrailpolicyassignmentresponse.mdx)**

### Errors

| Error Type | Status Code | Content Type |
| - | - | - |
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |

## change\_member\_policy\_assignment

Assign or unassign one policy for a member. Fails with 409 when `expected_assignment` no longer matches the stored state. [Management key](https://openrouter.ai/docs/client-sdks/python/docs/guides/overview/auth/management-api-keys) required.

### Example Usage

```python theme={null}
from openrouter import OpenRouter
import os


with OpenRouter(
    http_referer="<value>",
    x_open_router_title="<value>",
    x_open_router_categories="<value>",
    api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:

    res = open_router.guardrail_policies.change_member_policy_assignment(member_id="user_2abcDEFghiJKLmnoPQRstu", assigned=True, expected_assignment={
        "opted_out": False,
        "policy_ids": [],
        "workspace_default_policy_ids": [
            "2c6f1a4e-0b7d-4e59-9a61-3f8d2e7c1b90",
        ],
    }, policy_id="550e8400-e29b-41d4-a716-446655440000", policy_type="budget")

    # Handle response
    print(res)

```

### Parameters

| Parameter | Type | Required | Description | Example |
| - | - | - | - | - |
| `member_id` | *str* | ✔️ | Organization member user ID | user\_2abcDEFghiJKLmnoPQRstu |
| `assigned` | *bool* | ✔️ | `true` assigns the policy to the subject, `false` removes it | true |
| `expected_assignment` | [components.GuardrailPolicyAssignmentState](../../components/guardrailpolicyassignmentstate.mdx) | ✔️ | N/A | |
| `policy_id` | *str* | ✔️ | Policy ID | 550e8400-e29b-41d4-a716-446655440000 |
| `policy_type` | [components.ChangeGuardrailPolicyAssignmentRequestPolicyType](../../components/changeguardrailpolicyassignmentrequestpolicytype.mdx) | ✔️ | Policy type the assignment is read or changed for. `rate_limit` is an Enterprise private beta feature and requires an organization-scoped management key and an explicit `workspace_id`. | budget |
| `http_referer` | *Optional\[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings. This is used to track API usage per application.  | |
| `x_open_router_title` | *Optional\[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.  | |
| `x_open_router_categories` | *Optional\[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.  | |
| `workspace_id` | *Optional\[str]* | ➖ | Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other. | 0df9e665-d932-5740-b2c7-b52af166bc11 |
| `retries` | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | |

### Response

**[components.ChangeGuardrailPolicyAssignmentResponse](../../components/changeguardrailpolicyassignmentresponse.mdx)**

### Errors

| Error Type | Status Code | Content Type |
| - | - | - |
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.ConflictResponseError | 409 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |

## list\_scim\_group\_policy\_assignments

List the guardrail policies attached to each SCIM group mapping in the organization. Requires `scim:view` and `guardrails:view`. Enterprise private beta feature. [Management key](https://openrouter.ai/docs/client-sdks/python/docs/guides/overview/auth/management-api-keys) required.

### Example Usage

```python theme={null}
from openrouter import OpenRouter
import os


with OpenRouter(
    http_referer="<value>",
    x_open_router_title="<value>",
    x_open_router_categories="<value>",
    api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:

    res = open_router.guardrail_policies.list_scim_group_policy_assignments()

    # Handle response
    print(res)

```

### Parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `http_referer` | *Optional\[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings. This is used to track API usage per application.  |
| `x_open_router_title` | *Optional\[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.  |
| `x_open_router_categories` | *Optional\[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.  |
| `retries` | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. |

### Response

**[components.ListScimGroupPolicyAssignmentsResponse](../../components/listscimgrouppolicyassignmentsresponse.mdx)**

### Errors

| Error Type | Status Code | Content Type |
| - | - | - |
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.ConflictResponseError | 409 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |

## get\_scim\_group\_policy\_assignment

Get the guardrail policies attached to one SCIM group mapping. Requires `scim:view` and `guardrails:view`. Enterprise private beta feature. [Management key](https://openrouter.ai/docs/client-sdks/python/docs/guides/overview/auth/management-api-keys) required.

### Example Usage

```python theme={null}
from openrouter import OpenRouter
import os


with OpenRouter(
    http_referer="<value>",
    x_open_router_title="<value>",
    x_open_router_categories="<value>",
    api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:

    res = open_router.guardrail_policies.get_scim_group_policy_assignment(mapping_id="af65e842-2eb2-4feb-bc51-929aca5a7147")

    # Handle response
    print(res)

```

### Parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `mapping_id` | *str* | ✔️ | N/A |
| `http_referer` | *Optional\[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings. This is used to track API usage per application.  |
| `x_open_router_title` | *Optional\[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.  |
| `x_open_router_categories` | *Optional\[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.  |
| `retries` | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. |

### Response

**[components.ScimGroupPolicyAssignmentResponse](../../components/scimgrouppolicyassignmentresponse.mdx)**

### Errors

| Error Type | Status Code | Content Type |
| - | - | - |
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.ConflictResponseError | 409 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |

## update\_scim\_group\_policy\_assignment

Attach or remove guardrail policies on one SCIM group mapping, then update its members' policies. Every type in the request is applied, or none is. Requires `scim:view`, `guardrails:view` and `guardrails:update`. Enterprise private beta feature. [Management key](https://openrouter.ai/docs/client-sdks/python/docs/guides/overview/auth/management-api-keys) required.

### Example Usage

```python theme={null}
from openrouter import OpenRouter
import os


with OpenRouter(
    http_referer="<value>",
    x_open_router_title="<value>",
    x_open_router_categories="<value>",
    api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:

    res = open_router.guardrail_policies.update_scim_group_policy_assignment(mapping_id="10d15a71-fe5b-43e7-a9cc-284d994de944")

    # Handle response
    print(res)

```

### Parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `mapping_id` | *str* | ✔️ | N/A |
| `http_referer` | *Optional\[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings. This is used to track API usage per application.  |
| `x_open_router_title` | *Optional\[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.  |
| `x_open_router_categories` | *Optional\[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.  |
| `budget` | *OptionalNullable\[str]* | ➖ | N/A |
| `model_availability` | *OptionalNullable\[str]* | ➖ | N/A |
| `moderation` | *OptionalNullable\[str]* | ➖ | N/A |
| `rate_limit` | *OptionalNullable\[str]* | ➖ | N/A |
| `retries` | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. |

### Response

**[components.ScimGroupPolicyAssignmentResponse](../../components/scimgrouppolicyassignmentresponse.mdx)**

### Errors

| Error Type | Status Code | Content Type |
| - | - | - |
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.ConflictResponseError | 409 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |

## delete\_scim\_group\_policy\_opt\_out

Remove a member's opt-out for one policy type, so the member receives their groups' policy again right away. The member must be in the mapping's group and the mapping must set a policy of that type. Requires `scim:view`, `guardrails:view` and `guardrails:update`. Enterprise private beta feature. [Management key](https://openrouter.ai/docs/client-sdks/python/docs/guides/overview/auth/management-api-keys) required.

### Example Usage

```python theme={null}
from openrouter import OpenRouter
import os


with OpenRouter(
    http_referer="<value>",
    x_open_router_title="<value>",
    x_open_router_categories="<value>",
    api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:

    res = open_router.guardrail_policies.delete_scim_group_policy_opt_out(mapping_id="104dbbf4-a30b-427e-8207-76203c3fadc5", user_id="<id>", policy_type="rate_limit")

    # Handle response
    print(res)

```

### Parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `mapping_id` | *str* | ✔️ | N/A |
| `user_id` | *str* | ✔️ | N/A |
| `policy_type` | [operations.DeleteScimGroupPolicyOptOutPolicyType](../../operations/deletescimgrouppolicyoptoutpolicytype.mdx) | ✔️ | N/A |
| `http_referer` | *Optional\[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings. This is used to track API usage per application.  |
| `x_open_router_title` | *Optional\[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.  |
| `x_open_router_categories` | *Optional\[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.  |
| `retries` | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. |

### Response

**[components.DeleteScimGroupOptOutResponse](../../components/deletescimgroupoptoutresponse.mdx)**

### Errors

| Error Type | Status Code | Content Type |
| - | - | - |
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.ConflictResponseError | 409 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |

## list\_scim\_group\_policy\_opt\_outs

List the group's members who opted out of a guardrail policy this mapping sets, per policy type. Opted-out members keep their own assignment (or none) instead of the group policy. Requires `scim:view` and `guardrails:view`. Enterprise private beta feature. [Management key](https://openrouter.ai/docs/client-sdks/python/docs/guides/overview/auth/management-api-keys) required.

### Example Usage

```python theme={null}
from openrouter import OpenRouter
import os


with OpenRouter(
    http_referer="<value>",
    x_open_router_title="<value>",
    x_open_router_categories="<value>",
    api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:

    res = open_router.guardrail_policies.list_scim_group_policy_opt_outs(mapping_id="732784db-8051-4b40-9258-0ffc259c47ec")

    # Handle response
    print(res)

```

### Parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `mapping_id` | *str* | ✔️ | N/A |
| `http_referer` | *Optional\[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings. This is used to track API usage per application.  |
| `x_open_router_title` | *Optional\[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.  |
| `x_open_router_categories` | *Optional\[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.  |
| `retries` | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. |

### Response

**[components.ListScimGroupOptOutsResponse](../../components/listscimgroupoptoutsresponse.mdx)**

### Errors

| Error Type | Status Code | Content Type |
| - | - | - |
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.ConflictResponseError | 409 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |

## list\_budget\_policies

List the budget policies in a workspace. [Management key](https://openrouter.ai/docs/client-sdks/python/docs/guides/overview/auth/management-api-keys) required.

### Example Usage

```python theme={null}
from openrouter import OpenRouter
import os


with OpenRouter(
    http_referer="<value>",
    x_open_router_title="<value>",
    x_open_router_categories="<value>",
    api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:

    res = open_router.guardrail_policies.list_budget_policies(workspace_id="0df9e665-d932-5740-b2c7-b52af166bc11")

    while res is not None:
        # Handle items

        res = res.next()

```

### Parameters

| Parameter | Type | Required | Description | Example |
| - | - | - | - | - |
| `http_referer` | *Optional\[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings. This is used to track API usage per application.  | |
| `x_open_router_title` | *Optional\[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.  | |
| `x_open_router_categories` | *Optional\[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.  | |
| `offset` | *Optional\[int]* | ➖ | Number of records to skip for pagination. When both offset and limit are omitted, the full list is returned | 0 |
| `limit` | *Optional\[int]* | ➖ | Maximum number of records to return (max 100). When both offset and limit are omitted, the full list is returned | 50 |
| `workspace_id` | *Optional\[str]* | ➖ | Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other. | 0df9e665-d932-5740-b2c7-b52af166bc11 |
| `retries` | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | |

### Response

**[operations.ListBudgetPoliciesResponse](../../operations/listbudgetpoliciesresponse.mdx)**

### Errors

| Error Type | Status Code | Content Type |
| - | - | - |
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |

## create\_budget\_policy

Create a budget policy in a workspace. [Management key](https://openrouter.ai/docs/client-sdks/python/docs/guides/overview/auth/management-api-keys) required.

### Example Usage

```python theme={null}
from openrouter import OpenRouter
import os


with OpenRouter(
    http_referer="<value>",
    x_open_router_title="<value>",
    x_open_router_categories="<value>",
    api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:

    res = open_router.guardrail_policies.create_budget_policy(config={
        "include_byok_in_budgets": False,
        "limit_usd": 200.0,
        "reset_interval": "monthly",
    }, name="Engineering monthly budget", policy_type="budget")

    # Handle response
    print(res)

```

### Parameters

| Parameter | Type | Required | Description | Example |
| - | - | - | - | - |
| `config` | [components.GuardrailBudgetPolicyAuthoringConfig](../../components/guardrailbudgetpolicyauthoringconfig.mdx) | ✔️ | N/A | \{ "include\_byok\_in\_budgets": false, "limit\_usd": 200, "reset\_interval": "monthly" } |
| `name` | *str* | ✔️ | Policy name | Engineering monthly budget |
| `policy_type` | [components.CreateBudgetGuardrailPolicyRequestPolicyType](../../components/createbudgetguardrailpolicyrequestpolicytype.mdx) | ✔️ | N/A | |
| `http_referer` | *Optional\[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings. This is used to track API usage per application.  | |
| `x_open_router_title` | *Optional\[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.  | |
| `x_open_router_categories` | *Optional\[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.  | |
| `api_key_hashes` | List\[*str*] | ➖ | API key hashes | \[ "c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93" ] |
| `is_workspace_default` | *Optional\[bool]* | ➖ | Make this the workspace default for its policy type. Defaults to `false`. | |
| `member_ids` | List\[*str*] | ➖ | Organization member user IDs | \[ "user\_2abcDEFghiJKLmnoPQRstu" ] |
| `move_existing_assignments` | *Optional\[bool]* | ➖ | When creating a new workspace default, also move the replaced default policy's explicit member and API key assignments onto this policy. Defaults to `false`. | |
| `opted_out_api_key_hashes` | List\[*str*] | ➖ | API keys that should not inherit the policy when it is the workspace default | \[ "c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93" ] |
| `opted_out_member_ids` | List\[*str*] | ➖ | Members that should not inherit the policy when it is the workspace default | \[ "user\_2abcDEFghiJKLmnoPQRstu" ] |
| `workspace_id` | *Optional\[str]* | ➖ | Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other. | 0df9e665-d932-5740-b2c7-b52af166bc11 |
| `retries` | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | |

### Response

**[components.BudgetGuardrailPolicyResponse](../../components/budgetguardrailpolicyresponse.mdx)**

### Errors

| Error Type | Status Code | Content Type |
| - | - | - |
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.ConflictResponseError | 409 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |

## delete\_budget\_policy

Delete a budget policy. [Management key](https://openrouter.ai/docs/client-sdks/python/docs/guides/overview/auth/management-api-keys) required.

### Example Usage

```python theme={null}
from openrouter import OpenRouter
import os


with OpenRouter(
    http_referer="<value>",
    x_open_router_title="<value>",
    x_open_router_categories="<value>",
    api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:

    res = open_router.guardrail_policies.delete_budget_policy(id="550e8400-e29b-41d4-a716-446655440000", workspace_id="0df9e665-d932-5740-b2c7-b52af166bc11")

    # Handle response
    print(res)

```

### Parameters

| Parameter | Type | Required | Description | Example |
| - | - | - | - | - |
| `id` | *str* | ✔️ | Policy ID | 550e8400-e29b-41d4-a716-446655440000 |
| `http_referer` | *Optional\[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings. This is used to track API usage per application.  | |
| `x_open_router_title` | *Optional\[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.  | |
| `x_open_router_categories` | *Optional\[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.  | |
| `workspace_id` | *Optional\[str]* | ➖ | Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other. | 0df9e665-d932-5740-b2c7-b52af166bc11 |
| `retries` | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | |

### Response

**[components.DeleteGuardrailPolicyResponse](../../components/deleteguardrailpolicyresponse.mdx)**

### Errors

| Error Type | Status Code | Content Type |
| - | - | - |
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.ConflictResponseError | 409 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |

## get\_budget\_policy

Get a budget policy with its member and API key assignments. [Management key](https://openrouter.ai/docs/client-sdks/python/docs/guides/overview/auth/management-api-keys) required.

### Example Usage

```python theme={null}
from openrouter import OpenRouter
import os


with OpenRouter(
    http_referer="<value>",
    x_open_router_title="<value>",
    x_open_router_categories="<value>",
    api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:

    res = open_router.guardrail_policies.get_budget_policy(id="550e8400-e29b-41d4-a716-446655440000", workspace_id="0df9e665-d932-5740-b2c7-b52af166bc11")

    # Handle response
    print(res)

```

### Parameters

| Parameter | Type | Required | Description | Example |
| - | - | - | - | - |
| `id` | *str* | ✔️ | Policy ID | 550e8400-e29b-41d4-a716-446655440000 |
| `http_referer` | *Optional\[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings. This is used to track API usage per application.  | |
| `x_open_router_title` | *Optional\[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.  | |
| `x_open_router_categories` | *Optional\[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.  | |
| `workspace_id` | *Optional\[str]* | ➖ | Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other. | 0df9e665-d932-5740-b2c7-b52af166bc11 |
| `retries` | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | |

### Response

**[components.BudgetGuardrailPolicyDetailResponse](../../components/budgetguardrailpolicydetailresponse.mdx)**

### Errors

| Error Type | Status Code | Content Type |
| - | - | - |
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |

## update\_budget\_policy

Replace a budget policy's name and config, and optionally its assignments. [Management key](https://openrouter.ai/docs/client-sdks/python/docs/guides/overview/auth/management-api-keys) required.

### Example Usage

```python theme={null}
from openrouter import OpenRouter
import os


with OpenRouter(
    http_referer="<value>",
    x_open_router_title="<value>",
    x_open_router_categories="<value>",
    api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:

    res = open_router.guardrail_policies.update_budget_policy(id="550e8400-e29b-41d4-a716-446655440000", config={
        "include_byok_in_budgets": False,
        "limit_usd": 200.0,
        "reset_interval": "monthly",
    }, name="Engineering monthly budget")

    # Handle response
    print(res)

```

### Parameters

| Parameter | Type | Required | Description | Example |
| - | - | - | - | - |
| `id` | *str* | ✔️ | Policy ID | 550e8400-e29b-41d4-a716-446655440000 |
| `config` | [components.GuardrailBudgetPolicyAuthoringConfig](../../components/guardrailbudgetpolicyauthoringconfig.mdx) | ✔️ | N/A | \{ "include\_byok\_in\_budgets": false, "limit\_usd": 200, "reset\_interval": "monthly" } |
| `name` | *str* | ✔️ | Policy name | Engineering monthly budget |
| `http_referer` | *Optional\[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings. This is used to track API usage per application.  | |
| `x_open_router_title` | *Optional\[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.  | |
| `x_open_router_categories` | *Optional\[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.  | |
| `api_key_hashes` | List\[*str*] | ➖ | Complete new list of assigned API keys. Send together with `member_ids`, or omit both to keep the stored assignments. | \[ "c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93" ] |
| `is_workspace_default` | *Optional\[bool]* | ➖ | Omit to keep the stored default status; `false` unsets the policy as the workspace default. | |
| `member_ids` | List\[*str*] | ➖ | Complete new list of assigned members. Send together with `api_key_hashes`, or omit both to keep the stored assignments. | \[ "user\_2abcDEFghiJKLmnoPQRstu" ] |
| `opted_out_api_key_hashes` | List\[*str*] | ➖ | API key hashes | \[ "c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93" ] |
| `opted_out_member_ids` | List\[*str*] | ➖ | Organization member user IDs | \[ "user\_2abcDEFghiJKLmnoPQRstu" ] |
| `workspace_id` | *Optional\[str]* | ➖ | Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other. | 0df9e665-d932-5740-b2c7-b52af166bc11 |
| `retries` | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | |

### Response

**[components.BudgetGuardrailPolicyResponse](../../components/budgetguardrailpolicyresponse.mdx)**

### Errors

| Error Type | Status Code | Content Type |
| - | - | - |
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.ConflictResponseError | 409 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |

## list\_capacity\_policies

List the capacity policies in a workspace. Enterprise private beta feature. [Management key](https://openrouter.ai/docs/client-sdks/python/docs/guides/overview/auth/management-api-keys) required.

### Example Usage

```python theme={null}
from openrouter import OpenRouter
import os


with OpenRouter(
    http_referer="<value>",
    x_open_router_title="<value>",
    x_open_router_categories="<value>",
    api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:

    res = open_router.guardrail_policies.list_capacity_policies(workspace_id="0df9e665-d932-5740-b2c7-b52af166bc11")

    while res is not None:
        # Handle items

        res = res.next()

```

### Parameters

| Parameter | Type | Required | Description | Example |
| - | - | - | - | - |
| `workspace_id` | *str* | ✔️ | Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key. | 0df9e665-d932-5740-b2c7-b52af166bc11 |
| `http_referer` | *Optional\[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings. This is used to track API usage per application.  | |
| `x_open_router_title` | *Optional\[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.  | |
| `x_open_router_categories` | *Optional\[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.  | |
| `offset` | *Optional\[int]* | ➖ | Number of records to skip for pagination. When both offset and limit are omitted, the full list is returned | 0 |
| `limit` | *Optional\[int]* | ➖ | Maximum number of records to return (max 100). When both offset and limit are omitted, the full list is returned | 50 |
| `retries` | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | |

### Response

**[operations.ListCapacityPoliciesResponse](../../operations/listcapacitypoliciesresponse.mdx)**

### Errors

| Error Type | Status Code | Content Type |
| - | - | - |
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |

## create\_capacity\_policy

Create a capacity policy in a workspace. Enterprise private beta feature. [Management key](https://openrouter.ai/docs/client-sdks/python/docs/guides/overview/auth/management-api-keys) required.

### Example Usage

```python theme={null}
from openrouter import OpenRouter
import os


with OpenRouter(
    http_referer="<value>",
    x_open_router_title="<value>",
    x_open_router_categories="<value>",
    api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:

    res = open_router.guardrail_policies.create_capacity_policy(config={
        "bucket_by": [
            "member",
            "model",
        ],
        "limits": [
            {
                "limit": 100000,
                "models": "all",
                "unit": "tokens",
            },
        ],
    }, name="Engineering monthly budget", policy_type="rate_limit", workspace_id="0df9e665-d932-5740-b2c7-b52af166bc11")

    # Handle response
    print(res)

```

### Parameters

| Parameter | Type | Required | Description | Example |
| - | - | - | - | - |
| `config` | [components.GuardrailCapacityPolicyConfig](../../components/guardrailcapacitypolicyconfig.mdx) | ✔️ | N/A | \{ "bucket\_by": \[ "member", "model" ], "limits": \[ \{ "limit": 100000, "models": "all", "unit": "tokens" } ] } |
| `name` | *str* | ✔️ | Policy name | Engineering monthly budget |
| `policy_type` | [components.CreateCapacityGuardrailPolicyRequestPolicyType](../../components/createcapacityguardrailpolicyrequestpolicytype.mdx) | ✔️ | N/A | |
| `workspace_id` | *str* | ✔️ | Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key. | 0df9e665-d932-5740-b2c7-b52af166bc11 |
| `http_referer` | *Optional\[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings. This is used to track API usage per application.  | |
| `x_open_router_title` | *Optional\[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.  | |
| `x_open_router_categories` | *Optional\[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.  | |
| `api_key_hashes` | List\[*str*] | ➖ | API key hashes | \[ "c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93" ] |
| `is_workspace_default` | *Optional\[bool]* | ➖ | Make this the workspace default for its policy type. Defaults to `false`. | |
| `member_ids` | List\[*str*] | ➖ | Organization member user IDs | \[ "user\_2abcDEFghiJKLmnoPQRstu" ] |
| `move_existing_assignments` | *Optional\[bool]* | ➖ | When creating a new workspace default, also move the replaced default policy's explicit member and API key assignments onto this policy. Defaults to `false`. | |
| `opted_out_api_key_hashes` | List\[*str*] | ➖ | API keys that should not inherit the policy when it is the workspace default | \[ "c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93" ] |
| `opted_out_member_ids` | List\[*str*] | ➖ | Members that should not inherit the policy when it is the workspace default | \[ "user\_2abcDEFghiJKLmnoPQRstu" ] |
| `retries` | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | |

### Response

**[components.CapacityGuardrailPolicyResponse](../../components/capacityguardrailpolicyresponse.mdx)**

### Errors

| Error Type | Status Code | Content Type |
| - | - | - |
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.ConflictResponseError | 409 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |

## delete\_capacity\_policy

Delete a capacity policy. Enterprise private beta feature. [Management key](https://openrouter.ai/docs/client-sdks/python/docs/guides/overview/auth/management-api-keys) required.

### Example Usage

```python theme={null}
from openrouter import OpenRouter
import os


with OpenRouter(
    http_referer="<value>",
    x_open_router_title="<value>",
    x_open_router_categories="<value>",
    api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:

    res = open_router.guardrail_policies.delete_capacity_policy(id="550e8400-e29b-41d4-a716-446655440000", workspace_id="0df9e665-d932-5740-b2c7-b52af166bc11")

    # Handle response
    print(res)

```

### Parameters

| Parameter | Type | Required | Description | Example |
| - | - | - | - | - |
| `id` | *str* | ✔️ | Policy ID | 550e8400-e29b-41d4-a716-446655440000 |
| `workspace_id` | *str* | ✔️ | Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key. | 0df9e665-d932-5740-b2c7-b52af166bc11 |
| `http_referer` | *Optional\[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings. This is used to track API usage per application.  | |
| `x_open_router_title` | *Optional\[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.  | |
| `x_open_router_categories` | *Optional\[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.  | |
| `retries` | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | |

### Response

**[components.DeleteGuardrailPolicyResponse](../../components/deleteguardrailpolicyresponse.mdx)**

### Errors

| Error Type | Status Code | Content Type |
| - | - | - |
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.ConflictResponseError | 409 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |

## get\_capacity\_policy

Get a capacity policy with its member and API key assignments. Enterprise private beta feature. [Management key](https://openrouter.ai/docs/client-sdks/python/docs/guides/overview/auth/management-api-keys) required.

### Example Usage

```python theme={null}
from openrouter import OpenRouter
import os


with OpenRouter(
    http_referer="<value>",
    x_open_router_title="<value>",
    x_open_router_categories="<value>",
    api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:

    res = open_router.guardrail_policies.get_capacity_policy(id="550e8400-e29b-41d4-a716-446655440000", workspace_id="0df9e665-d932-5740-b2c7-b52af166bc11")

    # Handle response
    print(res)

```

### Parameters

| Parameter | Type | Required | Description | Example |
| - | - | - | - | - |
| `id` | *str* | ✔️ | Policy ID | 550e8400-e29b-41d4-a716-446655440000 |
| `workspace_id` | *str* | ✔️ | Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key. | 0df9e665-d932-5740-b2c7-b52af166bc11 |
| `http_referer` | *Optional\[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings. This is used to track API usage per application.  | |
| `x_open_router_title` | *Optional\[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.  | |
| `x_open_router_categories` | *Optional\[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.  | |
| `retries` | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | |

### Response

**[components.CapacityGuardrailPolicyDetailResponse](../../components/capacityguardrailpolicydetailresponse.mdx)**

### Errors

| Error Type | Status Code | Content Type |
| - | - | - |
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |

## update\_capacity\_policy

Replace a capacity policy's name and config, and optionally its assignments. Enterprise private beta feature. [Management key](https://openrouter.ai/docs/client-sdks/python/docs/guides/overview/auth/management-api-keys) required.

### Example Usage

```python theme={null}
from openrouter import OpenRouter
import os


with OpenRouter(
    http_referer="<value>",
    x_open_router_title="<value>",
    x_open_router_categories="<value>",
    api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:

    res = open_router.guardrail_policies.update_capacity_policy(id="550e8400-e29b-41d4-a716-446655440000", config={
        "bucket_by": [
            "member",
            "model",
        ],
        "limits": [
            {
                "limit": 100000,
                "models": "all",
                "unit": "tokens",
            },
        ],
    }, name="Engineering monthly budget", workspace_id="0df9e665-d932-5740-b2c7-b52af166bc11")

    # Handle response
    print(res)

```

### Parameters

| Parameter | Type | Required | Description | Example |
| - | - | - | - | - |
| `id` | *str* | ✔️ | Policy ID | 550e8400-e29b-41d4-a716-446655440000 |
| `config` | [components.GuardrailCapacityPolicyConfig](../../components/guardrailcapacitypolicyconfig.mdx) | ✔️ | N/A | \{ "bucket\_by": \[ "member", "model" ], "limits": \[ \{ "limit": 100000, "models": "all", "unit": "tokens" } ] } |
| `name` | *str* | ✔️ | Policy name | Engineering monthly budget |
| `workspace_id` | *str* | ✔️ | Workspace the capacity policy belongs to. Capacity policies require an organization-scoped management key. | 0df9e665-d932-5740-b2c7-b52af166bc11 |
| `http_referer` | *Optional\[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings. This is used to track API usage per application.  | |
| `x_open_router_title` | *Optional\[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.  | |
| `x_open_router_categories` | *Optional\[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.  | |
| `api_key_hashes` | List\[*str*] | ➖ | Complete new list of assigned API keys. Send together with `member_ids`, or omit both to keep the stored assignments. | \[ "c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93" ] |
| `is_workspace_default` | *Optional\[bool]* | ➖ | Omit to keep the stored default status; `false` unsets the policy as the workspace default. | |
| `member_ids` | List\[*str*] | ➖ | Complete new list of assigned members. Send together with `api_key_hashes`, or omit both to keep the stored assignments. | \[ "user\_2abcDEFghiJKLmnoPQRstu" ] |
| `opted_out_api_key_hashes` | List\[*str*] | ➖ | API key hashes | \[ "c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93" ] |
| `opted_out_member_ids` | List\[*str*] | ➖ | Organization member user IDs | \[ "user\_2abcDEFghiJKLmnoPQRstu" ] |
| `retries` | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | |

### Response

**[components.CapacityGuardrailPolicyResponse](../../components/capacityguardrailpolicyresponse.mdx)**

### Errors

| Error Type | Status Code | Content Type |
| - | - | - |
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.ConflictResponseError | 409 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |

## list\_model\_availability\_policies

List the model availability policies in a workspace. [Management key](https://openrouter.ai/docs/client-sdks/python/docs/guides/overview/auth/management-api-keys) required.

### Example Usage

```python theme={null}
from openrouter import OpenRouter
import os


with OpenRouter(
    http_referer="<value>",
    x_open_router_title="<value>",
    x_open_router_categories="<value>",
    api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:

    res = open_router.guardrail_policies.list_model_availability_policies(workspace_id="0df9e665-d932-5740-b2c7-b52af166bc11")

    while res is not None:
        # Handle items

        res = res.next()

```

### Parameters

| Parameter | Type | Required | Description | Example |
| - | - | - | - | - |
| `http_referer` | *Optional\[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings. This is used to track API usage per application.  | |
| `x_open_router_title` | *Optional\[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.  | |
| `x_open_router_categories` | *Optional\[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.  | |
| `offset` | *Optional\[int]* | ➖ | Number of records to skip for pagination. When both offset and limit are omitted, the full list is returned | 0 |
| `limit` | *Optional\[int]* | ➖ | Maximum number of records to return (max 100). When both offset and limit are omitted, the full list is returned | 50 |
| `workspace_id` | *Optional\[str]* | ➖ | Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other. | 0df9e665-d932-5740-b2c7-b52af166bc11 |
| `retries` | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | |

### Response

**[operations.ListModelAvailabilityPoliciesResponse](../../operations/listmodelavailabilitypoliciesresponse.mdx)**

### Errors

| Error Type | Status Code | Content Type |
| - | - | - |
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |

## create\_model\_availability\_policy

Create a model availability policy in a workspace. [Management key](https://openrouter.ai/docs/client-sdks/python/docs/guides/overview/auth/management-api-keys) required.

### Example Usage

```python theme={null}
from openrouter import OpenRouter
import os


with OpenRouter(
    http_referer="<value>",
    x_open_router_title="<value>",
    x_open_router_categories="<value>",
    api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:

    res = open_router.guardrail_policies.create_model_availability_policy(config={}, name="Engineering monthly budget", policy_type="model_availability")

    # Handle response
    print(res)

```

### Parameters

| Parameter | Type | Required | Description | Example |
| - | - | - | - | - |
| `config` | [components.GuardrailModelAvailabilityPolicyAuthoringConfig](../../components/guardrailmodelavailabilitypolicyauthoringconfig.mdx) | ✔️ | N/A | \{ "allowed\_models": \[ "openai/gpt-4o", "anthropic/claude-sonnet-4" ], "allowed\_providers": \[ "openai", "anthropic" ], "enforce\_zdr\_anthropic": true, "enforce\_zdr\_openai": true } |
| `name` | *str* | ✔️ | Policy name | Engineering monthly budget |
| `policy_type` | [components.CreateModelAvailabilityGuardrailPolicyRequestPolicyType](../../components/createmodelavailabilityguardrailpolicyrequestpolicytype.mdx) | ✔️ | N/A | |
| `http_referer` | *Optional\[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings. This is used to track API usage per application.  | |
| `x_open_router_title` | *Optional\[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.  | |
| `x_open_router_categories` | *Optional\[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.  | |
| `api_key_hashes` | List\[*str*] | ➖ | API key hashes | \[ "c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93" ] |
| `is_workspace_default` | *Optional\[bool]* | ➖ | Make this the workspace default for its policy type. Defaults to `false`. | |
| `member_ids` | List\[*str*] | ➖ | Organization member user IDs | \[ "user\_2abcDEFghiJKLmnoPQRstu" ] |
| `move_existing_assignments` | *Optional\[bool]* | ➖ | When creating a new workspace default, also move the replaced default policy's explicit member and API key assignments onto this policy. Defaults to `false`. | |
| `opted_out_api_key_hashes` | List\[*str*] | ➖ | API keys that should not inherit the policy when it is the workspace default | \[ "c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93" ] |
| `opted_out_member_ids` | List\[*str*] | ➖ | Members that should not inherit the policy when it is the workspace default | \[ "user\_2abcDEFghiJKLmnoPQRstu" ] |
| `workspace_id` | *Optional\[str]* | ➖ | Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other. | 0df9e665-d932-5740-b2c7-b52af166bc11 |
| `retries` | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | |

### Response

**[components.ModelAvailabilityGuardrailPolicyResponse](../../components/modelavailabilityguardrailpolicyresponse.mdx)**

### Errors

| Error Type | Status Code | Content Type |
| - | - | - |
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.ConflictResponseError | 409 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |

## delete\_model\_availability\_policy

Delete a model availability policy. [Management key](https://openrouter.ai/docs/client-sdks/python/docs/guides/overview/auth/management-api-keys) required.

### Example Usage

```python theme={null}
from openrouter import OpenRouter
import os


with OpenRouter(
    http_referer="<value>",
    x_open_router_title="<value>",
    x_open_router_categories="<value>",
    api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:

    res = open_router.guardrail_policies.delete_model_availability_policy(id="550e8400-e29b-41d4-a716-446655440000", workspace_id="0df9e665-d932-5740-b2c7-b52af166bc11")

    # Handle response
    print(res)

```

### Parameters

| Parameter | Type | Required | Description | Example |
| - | - | - | - | - |
| `id` | *str* | ✔️ | Policy ID | 550e8400-e29b-41d4-a716-446655440000 |
| `http_referer` | *Optional\[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings. This is used to track API usage per application.  | |
| `x_open_router_title` | *Optional\[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.  | |
| `x_open_router_categories` | *Optional\[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.  | |
| `workspace_id` | *Optional\[str]* | ➖ | Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other. | 0df9e665-d932-5740-b2c7-b52af166bc11 |
| `retries` | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | |

### Response

**[components.DeleteGuardrailPolicyResponse](../../components/deleteguardrailpolicyresponse.mdx)**

### Errors

| Error Type | Status Code | Content Type |
| - | - | - |
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.ConflictResponseError | 409 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |

## get\_model\_availability\_policy

Get a model availability policy with its member and API key assignments. [Management key](https://openrouter.ai/docs/client-sdks/python/docs/guides/overview/auth/management-api-keys) required.

### Example Usage

```python theme={null}
from openrouter import OpenRouter
import os


with OpenRouter(
    http_referer="<value>",
    x_open_router_title="<value>",
    x_open_router_categories="<value>",
    api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:

    res = open_router.guardrail_policies.get_model_availability_policy(id="550e8400-e29b-41d4-a716-446655440000", workspace_id="0df9e665-d932-5740-b2c7-b52af166bc11")

    # Handle response
    print(res)

```

### Parameters

| Parameter | Type | Required | Description | Example |
| - | - | - | - | - |
| `id` | *str* | ✔️ | Policy ID | 550e8400-e29b-41d4-a716-446655440000 |
| `http_referer` | *Optional\[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings. This is used to track API usage per application.  | |
| `x_open_router_title` | *Optional\[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.  | |
| `x_open_router_categories` | *Optional\[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.  | |
| `workspace_id` | *Optional\[str]* | ➖ | Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other. | 0df9e665-d932-5740-b2c7-b52af166bc11 |
| `retries` | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | |

### Response

**[components.ModelAvailabilityGuardrailPolicyDetailResponse](../../components/modelavailabilityguardrailpolicydetailresponse.mdx)**

### Errors

| Error Type | Status Code | Content Type |
| - | - | - |
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |

## update\_model\_availability\_policy

Replace a model availability policy's name and config, and optionally its assignments. [Management key](https://openrouter.ai/docs/client-sdks/python/docs/guides/overview/auth/management-api-keys) required.

### Example Usage

```python theme={null}
from openrouter import OpenRouter
import os


with OpenRouter(
    http_referer="<value>",
    x_open_router_title="<value>",
    x_open_router_categories="<value>",
    api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:

    res = open_router.guardrail_policies.update_model_availability_policy(id="550e8400-e29b-41d4-a716-446655440000", config={}, name="Engineering monthly budget")

    # Handle response
    print(res)

```

### Parameters

| Parameter | Type | Required | Description | Example |
| - | - | - | - | - |
| `id` | *str* | ✔️ | Policy ID | 550e8400-e29b-41d4-a716-446655440000 |
| `config` | [components.GuardrailModelAvailabilityPolicyAuthoringConfig](../../components/guardrailmodelavailabilitypolicyauthoringconfig.mdx) | ✔️ | N/A | \{ "allowed\_models": \[ "openai/gpt-4o", "anthropic/claude-sonnet-4" ], "allowed\_providers": \[ "openai", "anthropic" ], "enforce\_zdr\_anthropic": true, "enforce\_zdr\_openai": true } |
| `name` | *str* | ✔️ | Policy name | Engineering monthly budget |
| `http_referer` | *Optional\[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings. This is used to track API usage per application.  | |
| `x_open_router_title` | *Optional\[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.  | |
| `x_open_router_categories` | *Optional\[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.  | |
| `api_key_hashes` | List\[*str*] | ➖ | Complete new list of assigned API keys. Send together with `member_ids`, or omit both to keep the stored assignments. | \[ "c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93" ] |
| `is_workspace_default` | *Optional\[bool]* | ➖ | Omit to keep the stored default status; `false` unsets the policy as the workspace default. | |
| `member_ids` | List\[*str*] | ➖ | Complete new list of assigned members. Send together with `api_key_hashes`, or omit both to keep the stored assignments. | \[ "user\_2abcDEFghiJKLmnoPQRstu" ] |
| `opted_out_api_key_hashes` | List\[*str*] | ➖ | API key hashes | \[ "c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93" ] |
| `opted_out_member_ids` | List\[*str*] | ➖ | Organization member user IDs | \[ "user\_2abcDEFghiJKLmnoPQRstu" ] |
| `workspace_id` | *Optional\[str]* | ➖ | Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other. | 0df9e665-d932-5740-b2c7-b52af166bc11 |
| `retries` | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | |

### Response

**[components.ModelAvailabilityGuardrailPolicyResponse](../../components/modelavailabilityguardrailpolicyresponse.mdx)**

### Errors

| Error Type | Status Code | Content Type |
| - | - | - |
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.ConflictResponseError | 409 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |

## list\_moderation\_policies

List the moderation policies in a workspace. [Management key](https://openrouter.ai/docs/client-sdks/python/docs/guides/overview/auth/management-api-keys) required.

### Example Usage

```python theme={null}
from openrouter import OpenRouter
import os


with OpenRouter(
    http_referer="<value>",
    x_open_router_title="<value>",
    x_open_router_categories="<value>",
    api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:

    res = open_router.guardrail_policies.list_moderation_policies(workspace_id="0df9e665-d932-5740-b2c7-b52af166bc11")

    while res is not None:
        # Handle items

        res = res.next()

```

### Parameters

| Parameter | Type | Required | Description | Example |
| - | - | - | - | - |
| `http_referer` | *Optional\[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings. This is used to track API usage per application.  | |
| `x_open_router_title` | *Optional\[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.  | |
| `x_open_router_categories` | *Optional\[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.  | |
| `offset` | *Optional\[int]* | ➖ | Number of records to skip for pagination. When both offset and limit are omitted, the full list is returned | 0 |
| `limit` | *Optional\[int]* | ➖ | Maximum number of records to return (max 100). When both offset and limit are omitted, the full list is returned | 50 |
| `workspace_id` | *Optional\[str]* | ➖ | Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other. | 0df9e665-d932-5740-b2c7-b52af166bc11 |
| `retries` | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | |

### Response

**[operations.ListModerationPoliciesResponse](../../operations/listmoderationpoliciesresponse.mdx)**

### Errors

| Error Type | Status Code | Content Type |
| - | - | - |
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |

## create\_moderation\_policy

Create a moderation policy in a workspace. [Management key](https://openrouter.ai/docs/client-sdks/python/docs/guides/overview/auth/management-api-keys) required.

### Example Usage

```python theme={null}
from openrouter import OpenRouter, components
import os


with OpenRouter(
    http_referer="<value>",
    x_open_router_title="<value>",
    x_open_router_categories="<value>",
    api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:

    res = open_router.guardrail_policies.create_moderation_policy(config=components.GuardrailModerationPolicyConfig(), name="Engineering monthly budget", policy_type="moderation")

    # Handle response
    print(res)

```

### Parameters

| Parameter | Type | Required | Description | Example |
| - | - | - | - | - |
| `config` | [components.GuardrailModerationPolicyConfig](../../components/guardrailmoderationpolicyconfig.mdx) | ✔️ | N/A | \{ "content\_filter\_builtins": \[ \{ "action": "block", "slug": "secrets" } ] } |
| `name` | *str* | ✔️ | Policy name | Engineering monthly budget |
| `policy_type` | [components.CreateModerationGuardrailPolicyRequestPolicyType](../../components/createmoderationguardrailpolicyrequestpolicytype.mdx) | ✔️ | N/A | |
| `http_referer` | *Optional\[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings. This is used to track API usage per application.  | |
| `x_open_router_title` | *Optional\[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.  | |
| `x_open_router_categories` | *Optional\[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.  | |
| `api_key_hashes` | List\[*str*] | ➖ | API key hashes | \[ "c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93" ] |
| `is_workspace_default` | *Optional\[bool]* | ➖ | Make this the workspace default for its policy type. Defaults to `false`. | |
| `member_ids` | List\[*str*] | ➖ | Organization member user IDs | \[ "user\_2abcDEFghiJKLmnoPQRstu" ] |
| `move_existing_assignments` | *Optional\[bool]* | ➖ | When creating a new workspace default, also move the replaced default policy's explicit member and API key assignments onto this policy. Defaults to `false`. | |
| `opted_out_api_key_hashes` | List\[*str*] | ➖ | API keys that should not inherit the policy when it is the workspace default | \[ "c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93" ] |
| `opted_out_member_ids` | List\[*str*] | ➖ | Members that should not inherit the policy when it is the workspace default | \[ "user\_2abcDEFghiJKLmnoPQRstu" ] |
| `workspace_id` | *Optional\[str]* | ➖ | Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other. | 0df9e665-d932-5740-b2c7-b52af166bc11 |
| `retries` | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | |

### Response

**[components.ModerationGuardrailPolicyResponse](../../components/moderationguardrailpolicyresponse.mdx)**

### Errors

| Error Type | Status Code | Content Type |
| - | - | - |
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.ConflictResponseError | 409 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |

## delete\_moderation\_policy

Delete a moderation policy. [Management key](https://openrouter.ai/docs/client-sdks/python/docs/guides/overview/auth/management-api-keys) required.

### Example Usage

```python theme={null}
from openrouter import OpenRouter
import os


with OpenRouter(
    http_referer="<value>",
    x_open_router_title="<value>",
    x_open_router_categories="<value>",
    api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:

    res = open_router.guardrail_policies.delete_moderation_policy(id="550e8400-e29b-41d4-a716-446655440000", workspace_id="0df9e665-d932-5740-b2c7-b52af166bc11")

    # Handle response
    print(res)

```

### Parameters

| Parameter | Type | Required | Description | Example |
| - | - | - | - | - |
| `id` | *str* | ✔️ | Policy ID | 550e8400-e29b-41d4-a716-446655440000 |
| `http_referer` | *Optional\[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings. This is used to track API usage per application.  | |
| `x_open_router_title` | *Optional\[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.  | |
| `x_open_router_categories` | *Optional\[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.  | |
| `workspace_id` | *Optional\[str]* | ➖ | Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other. | 0df9e665-d932-5740-b2c7-b52af166bc11 |
| `retries` | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | |

### Response

**[components.DeleteGuardrailPolicyResponse](../../components/deleteguardrailpolicyresponse.mdx)**

### Errors

| Error Type | Status Code | Content Type |
| - | - | - |
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.ConflictResponseError | 409 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |

## get\_moderation\_policy

Get a moderation policy with its member and API key assignments. [Management key](https://openrouter.ai/docs/client-sdks/python/docs/guides/overview/auth/management-api-keys) required.

### Example Usage

```python theme={null}
from openrouter import OpenRouter
import os


with OpenRouter(
    http_referer="<value>",
    x_open_router_title="<value>",
    x_open_router_categories="<value>",
    api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:

    res = open_router.guardrail_policies.get_moderation_policy(id="550e8400-e29b-41d4-a716-446655440000", workspace_id="0df9e665-d932-5740-b2c7-b52af166bc11")

    # Handle response
    print(res)

```

### Parameters

| Parameter | Type | Required | Description | Example |
| - | - | - | - | - |
| `id` | *str* | ✔️ | Policy ID | 550e8400-e29b-41d4-a716-446655440000 |
| `http_referer` | *Optional\[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings. This is used to track API usage per application.  | |
| `x_open_router_title` | *Optional\[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.  | |
| `x_open_router_categories` | *Optional\[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.  | |
| `workspace_id` | *Optional\[str]* | ➖ | Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other. | 0df9e665-d932-5740-b2c7-b52af166bc11 |
| `retries` | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | |

### Response

**[components.ModerationGuardrailPolicyDetailResponse](../../components/moderationguardrailpolicydetailresponse.mdx)**

### Errors

| Error Type | Status Code | Content Type |
| - | - | - |
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |

## update\_moderation\_policy

Replace a moderation policy's name and config, and optionally its assignments. [Management key](https://openrouter.ai/docs/client-sdks/python/docs/guides/overview/auth/management-api-keys) required.

### Example Usage

```python theme={null}
from openrouter import OpenRouter, components
import os


with OpenRouter(
    http_referer="<value>",
    x_open_router_title="<value>",
    x_open_router_categories="<value>",
    api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:

    res = open_router.guardrail_policies.update_moderation_policy(id="550e8400-e29b-41d4-a716-446655440000", config=components.GuardrailModerationPolicyConfig(), name="Engineering monthly budget")

    # Handle response
    print(res)

```

### Parameters

| Parameter | Type | Required | Description | Example |
| - | - | - | - | - |
| `id` | *str* | ✔️ | Policy ID | 550e8400-e29b-41d4-a716-446655440000 |
| `config` | [components.GuardrailModerationPolicyConfig](../../components/guardrailmoderationpolicyconfig.mdx) | ✔️ | N/A | \{ "content\_filter\_builtins": \[ \{ "action": "block", "slug": "secrets" } ] } |
| `name` | *str* | ✔️ | Policy name | Engineering monthly budget |
| `http_referer` | *Optional\[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings. This is used to track API usage per application.  | |
| `x_open_router_title` | *Optional\[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.  | |
| `x_open_router_categories` | *Optional\[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.  | |
| `api_key_hashes` | List\[*str*] | ➖ | Complete new list of assigned API keys. Send together with `member_ids`, or omit both to keep the stored assignments. | \[ "c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93" ] |
| `is_workspace_default` | *Optional\[bool]* | ➖ | Omit to keep the stored default status; `false` unsets the policy as the workspace default. | |
| `member_ids` | List\[*str*] | ➖ | Complete new list of assigned members. Send together with `api_key_hashes`, or omit both to keep the stored assignments. | \[ "user\_2abcDEFghiJKLmnoPQRstu" ] |
| `opted_out_api_key_hashes` | List\[*str*] | ➖ | API key hashes | \[ "c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93" ] |
| `opted_out_member_ids` | List\[*str*] | ➖ | Organization member user IDs | \[ "user\_2abcDEFghiJKLmnoPQRstu" ] |
| `workspace_id` | *Optional\[str]* | ➖ | Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other. | 0df9e665-d932-5740-b2c7-b52af166bc11 |
| `retries` | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | |

### Response

**[components.ModerationGuardrailPolicyResponse](../../components/moderationguardrailpolicyresponse.mdx)**

### Errors

| Error Type | Status Code | Content Type |
| - | - | - |
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.ConflictResponseError | 409 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |
