> For the complete documentation index, see [llms.txt](https://docs.mozilla.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mozilla.ai/any-guardrail/quickstart.md).

# Quick Start

#### Requirements

* Python 3.11 or newer

#### Installation

You can install the bare bones library as follows (only \[`any_guardrails.guardrails.any_llm.AnyLlm`] will be available):

```bash
pip install any-guardrail
```

Or you can install it with the required dependencies for different guardrails:

```bash
pip install any-guardrail[huggingface]
```

Refer to [pyproject.toml](https://github.com/mozilla-ai/any-guardrail/blob/main/pyproject.toml) for a list of the options available.

#### Basic Usage

`AnyGuardrail` provides a seamless interface for interacting with the guardrail models. It allows you to see a list of all the supported guardrails, and to instantiate each supported guardrails. Here is a full example:

```python
from any_guardrail import AnyGuardrail, GuardrailName, GuardrailOutput

guardrail = AnyGuardrail.create(GuardrailName.DEEPSET)

result: GuardrailOutput = guardrail.validate("All smiles from me!")

assert result.valid
```

#### Discovering guardrails

Every guardrail carries static, queryable metadata (what it detects, where it runs, how it executes) that you can filter and group **without importing any model backend** — handy for building your own catalog or picking a guardrail programmatically:

```python
from any_guardrail import AnyGuardrail, BackendType, GuardrailCategory, GuardrailName

# Which guardrails detect prompt injection and run as a local encoder classifier?
names = AnyGuardrail.list_guardrails(
    category=GuardrailCategory.PROMPT_INJECTION,
    backend=BackendType.LOCAL_ENCODER,
)
assert GuardrailName.PROTECTAI in names

# Inspect one guardrail's capability metadata.
meta = AnyGuardrail.metadata(GuardrailName.LLAMA_GUARD)
assert GuardrailCategory.CONTENT_SAFETY in meta.categories

# Group the whole catalog by a dimension (e.g. for docs or a picker UI).
by_category = AnyGuardrail.group_by("category")
assert GuardrailName.DEEPSET in by_category["prompt_injection"]
```

#### Troubleshooting

Some of the models on HuggingFace require extra permissions to use. To do this, you'll need to create a HuggingFace profile and manually go through the permissions. Then, you'll need to download the HuggingFace Hub and login. One way to do this is:

```bash
pip install --upgrade huggingface_hub

hf auth login
```

More information can be found here: [HuggingFace Hub](https://huggingface.co/docs/huggingface_hub/en/quick-start#login-command)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.mozilla.ai/any-guardrail/quickstart.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `build a script that syncs our docs to a CMS` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
