Message Filter Object Structure
Overview
The messageFilter object configures server-side message filters. In v1.3.13, the supported filter type is messageFilter.pii.
messageFilter.pii rejects submitted message text that matches credential-shaped starter patterns or operator-defined regular expressions before the text reaches moderation, a model request, or message persistence.
Example
Fields
messageFilter.pii
| Key | Type | Description | Example |
|---|---|---|---|
| pii.starterPatterns | Array of Strings | Optional subset of built-in starter pattern ids to enable. Omit to enable all starter patterns. | starterPatterns: [sk_prefix, bearer_header] |
| pii.customPatterns | Array of Objects | Operator-defined patterns. Each entry requires `id`, `label`, and `regex`. |
Built-in starter pattern ids:
sk_prefix: matchessk-style token prefixes.bearer_header: matches bearer tokens in text.api_key_header: matchesapi-keyheader-shaped text.
customPatterns
| Key | Type | Description | Example |
|---|---|---|---|
| id | String | Stable pattern id used for logs and debugging. | id: anthropic_api_key |
| label | String | Human-readable label shown in the rejection message. | label: Anthropic API key |
| regex | String | JavaScript-flavor regular expression. LibreChat validates it at config load time and compiles it with the global flag. | regex: 'sk-ant-[A-Za-z0-9_-]{20,}' |
Behavior
When submitted message text matches a configured PII pattern, LibreChat returns HTTP 400 with message_filter_pii_block and a message asking the caller to remove the matched credential type.
The filter checks:
- Chat route user text submitted through the LibreChat UI.
- Text content across all caller-supplied message roles in OpenAI-compatible Chat Completions requests.
- Text content across all caller-supplied message roles in OpenAI-compatible Responses requests.
The filter evaluates text supplied in the request body. It does not scan file contents.
How is this guide?