Beta: The LLM Gateway is in beta.
- Data retention: whether the gateway writes request and response bodies to the LangSmith trace.
- Data protection: which sensitive data the gateway scans for and redacts before a request reaches the LLM provider, how long that scan may run, and whether a request proceeds when the limit is exceeded.
Availability
Data policies are available to every organization with access to the LLM Gateway. Two entitlements shape what the Data Policy tab offers:- Data protection is on by default. If the entitlement is turned off, cloud Enterprise organizations see the tab grayed out with a Request access link, and every other organization does not see the tab at all.
- PII detection is off by default and enabled for selected organizations. Without it, the PII options are unavailable in the create and edit forms, and the API rejects any policy configured to detect PII.
Data retention
Every call through the LLM Gateway is traced to LangSmith. The Trace content toggle controls whether request and response bodies are stored in those traces. It is off for all organizations, and a data policy turns it on for the requests that policy matches. When trace content is disabled, the gateway still records metadata such as token usage, latency, status, model information, and policy evaluation results. Gateway traces are written to a shared project namedgateway in the workspace associated with the caller’s API key, plus a per-caller project that isolates traffic in the UI. For the project naming schemes, the metadata traces carry, and how to restrict trace visibility, see Traces and access control.
Data protection
When a data policy enables detection, the gateway scans outbound requests before they reach the LLM provider. Detected values are replaced with placeholders before the request is forwarded upstream, so the provider only ever sees the redacted payload. For successful responses, the gateway restores the placeholders to the original values before returning the response to the caller. Redacted content is also redacted in the LangSmith trace, so sensitive data does not persist in your observability data either. The PII and Secrets toggles are independent. On a new policy, PII detection starts on with every rule selected (for organizations that have the entitlement) and secrets detection starts off.PII detection
The Personally Identifiable Information (PII) toggle covers names, emails, phone numbers, addresses, and SSNs. Six rules sit beneath it, each selectable on its own, grouped by how the gateway detects them. Rule-based categories are matched with regular expressions and are faster to detect:
Model-based categories are matched by Presidio and are slower to detect:
Secrets detection
The Secrets toggle detects common API keys, tokens, and credentials and redacts them from the request:
Detection is deliberately narrow: only rules anchored to a recognizable token shape are applied, so high-entropy prose in a prompt does not trigger a redaction.
Scan time and timeout behavior
Each data policy caps how long the scanning pipeline may run and decides what happens when that cap is reached:- Max processing time (seconds): 2 by default, configurable from 0.1 to 30.
- On timeout: Allow request by default. Set it to Block request to reject a request whose scan does not finish in time.
Create a data policy
- In the LangSmith sidebar, click LLM Gateway.
- Open the Data Policy tab.
- Click Create data policy.
- Select the scope: Organization, Workspace, User, or API Key.
- Enter a Policy name, or keep the generated one.
- For a workspace, user, or API key scope, select the specific subjects the policy applies to.
- (Optional) Under Data retention, enable Trace content to store request and response bodies in traces.
- Under Data protection, enable Secrets, PII, or both. For PII, select the rules to apply.
- (Optional) Set Max processing time (seconds) and On timeout.
- Click Create data policy.
How redacted content appears
When PII or a secret is detected, the content is replaced with a placeholder in both the request sent to the provider and the LangSmith trace. For example: Original request:[SAFE_TO_USE:<CATEGORY>_<suffix>]:
- SAFE_TO_USE: fixed prefix marking the value as a redacted placeholder.
- <CATEGORY>: the detected type. Examples:
PERSON,LOCATION,US_SSN,US_PHONE_NUMBER,OPENAI_API_KEY,GITHUB_PAT,LANGSMITH_PERSONAL_TOKEN. - <suffix>: an 8-character tag. A value that appears twice in one request gets the same placeholder both times, and the tags cannot be correlated across requests.
What redaction covers
What it covers:- Outbound request content (the message sent to the LLM provider) is scanned and redacted before it leaves the gateway.
- The redacted version is what appears in LangSmith traces.
- Placeholders in a successful provider response, streamed or not, are restored to the original values before the response reaches the caller.
- Responses from the LLM provider: if the model generates sensitive data in its response, that content is not scanned or redacted. Only the request is scanned.
- Provider errors: when the provider returns a status of 400 or above, the gateway passes the body through untouched, so the caller sees the placeholders rather than the original values.
- Data already in your traces: redaction only applies to requests flowing through the gateway. Traces written directly to the LangSmith API (bypassing the gateway) are not scanned.
- Platform-level ingestion: if your requirement is to prevent PII from ever entering LangSmith regardless of how it arrives (for example, data residency compliance), gateway redaction alone is not sufficient. That requires ingestion-level redaction, which is a separate capability.
- System and developer prompts: these are skipped, along with assistant tool-call metadata and tool-call arguments that arrive as a single JSON string. User messages, tool results, and structured tool-call arguments are scanned.
Next steps
- Traces and access control: see where gateway traces land and who can read them.
- Spend policies: add cost controls alongside data protection.
Connect these docs to Claude, VSCode, and more via MCP for real-time answers.

