Guardrails
Guardrails are safety layers that inspect and transform LLM requests and responses in real time.
What guardrails do
Depending on the activated guardrail, the LLM API applies it in two stages:
- Pre-call — scans and transforms your input before it reaches the model
- Post-call — scans and transforms the model's response before it reaches you
Architecture
Setup
Guardrails are opt-in per request. No upfront configuration is needed — just add the guardrails parameter to any chat completion call. They are composable, you can pass multiple guardrail names in the request to combine them. Your request/response structure stays the same. Guardrails modify content in-place.
1. Choose a guardrail
List available guardrails for your endpoint:
curl -s "https://llm.api.caip.bmw.cloud/guardrails/list" \
-H "Authorization: Bearer $YOUR_API_KEY" | jq .
2. Add it to your request
Pass the guardrail name(s) in the guardrails array:
curl -X POST 'https://llm.api.caip.bmw.cloud/v1/chat/completions' \
-H "Authorization: Bearer $YOUR_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Hello world"}],
"guardrails": ["pii-data-masking-en"]
}'
3. Use with OpenAI SDK
Python:
from openai import OpenAI
client = OpenAI(
base_url="https://llm.api.caip.bmw.cloud/v1",
api_key="your-api-key"
)
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Your message here"}],
extra_body={"guardrails": ["pii-data-masking-en"]}
)
Available guardrails
| Guardrail | Description | Languages | Stage |
|---|---|---|---|
| PII Data Masking | Detects and masks general personally identifiable information (names, emails, credit cards, …). Does not mask VINs. | English, German | pre_call masking, post_call unmasking |
| VIN Masking | Detects and masks Vehicle Identification Numbers (VINs) only | English, German | pre_call masking, post_call unmasking |
Guardrails can be combined. To mask general PII and VINs, request both:
"guardrails": ["pii-data-masking-en", "vin-masking-en"].
We are actively developing additional guardrails (content filtering, topic restriction, etc.). Check this page for updates.
Request a new guardrail
Need a guardrail we don't offer yet? Reach out to the CAIP team for Technical Support or Consulting. Describe your use case and what kind of content you want to detect, block, or transform.
Include the following in your request:
- What content should be detected (e.g., specific entity types, topics, patterns)
- Whether it should apply to input, output, or both
- Whether the action should be mask (replace) or block (reject the request)
- Which languages need to be supported
API reference
| Endpoint | Method | Description |
|---|---|---|
/guardrails/list | GET | Returns all available guardrail names |
/v1/chat/completions | POST | Accepts guardrails array in request body |