docs apply guard (#10923)

This commit is contained in:
Ishaan Jaff 2025-05-17 18:34:35 -07:00 • committed by GitHub
parent b4fc703d3b
commit cdf6026fdd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 71 additions and 0 deletions

View file

@ -0,0 +1,70 @@
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
# /guardrails/apply_guardrail
Use this endpoint to directly call a guardrail configured on your LiteLLM instance. This is useful when you have services that need to directly call a guardrail.
## Usage
---
In this example `mask_pii` is the guardrail name configured on LiteLLM.
```bash showLineNumbers title="Example calling the endpoint"
curl -X POST 'http://localhost:4000/guardrails/apply_guardrail' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer your-api-key' \
-d '{
"guardrail_name": "mask_pii",
"text": "My name is John Doe and my email is john@example.com",
"language": "en",
"entities": ["NAME", "EMAIL"]
}'
```
## Request Format
---
The request body should follow the ApplyGuardrailRequest format.
#### Example Request Body
```json
{
"guardrail_name": "mask_pii",
"text": "My name is John Doe and my email is john@example.com",
"language": "en",
"entities": ["NAME", "EMAIL"]
}
```
#### Required Fields
- **guardrail_name** (string):
The identifier for the guardrail to apply (e.g., "mask_pii").
- **text** (string):
The input text to process through the guardrail.
#### Optional Fields
- **language** (string):
The language of the input text (e.g., "en" for English).
- **entities** (array of strings):
Specific entities to process or filter (e.g., ["NAME", "EMAIL"]).
## Response Format
---
The response will contain the processed text after applying the guardrail.
#### Example Response
```json
{
"response_text": "My name is [REDACTED] and my email is [REDACTED]"
}
```
#### Response Fields
- **response_text** (string):
The text after applying the guardrail.

View file

@ -268,6 +268,7 @@ const sidebars = {
"realtime",
"fine_tuning",
"moderation",
"apply_guardrail",
],
},
{