The LLM Gateway is in beta.
- Which sensitive data, such as personal information or API keys, the gateway redacts before a request reaches the LLM provider.
- Whether LangSmith stores request and response bodies in traces.
- Keep customer data and credentials that developers or agents put in prompts away from third-party providers.
- Limit what LangSmith stores.
- Redact personal information (PII) and Redact secrets: which sensitive data the gateway scans for and redacts before a request reaches the LLM provider. See How redaction works.
- Store trace content: whether the gateway writes request and response bodies to the LangSmith trace. See Store trace content.
- If redaction takes too long: how long the scan may run, and whether a request proceeds when that limit is exceeded. See Scan time and timeout behavior.
Availability
Data policies are available to every organization with access to the LLM Gateway. Every such organization can create policies that redact secrets and store trace content. PII redaction requires a separate entitlement, which is off by default and enabled for selected organizations. Without it:- The Redact personal information (PII) option appears locked in the create and edit forms, with a Request access link.
- The If redaction takes too long setting is hidden, and the policy uses the default timeout behavior.
- The API rejects any policy configured to detect PII.
How redaction works
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. The Redact personal information (PII) and Redact secrets options are independent. On a new policy, PII redaction starts on with every type selected (for organizations that have the entitlement), and secrets redaction and trace content start off.Redact personal information
The Redact personal information (PII) option covers names, emails, US phone numbers, addresses, and US SSNs. When the option is selected, six types appear beneath it, each selectable on its own, in two groups based on how the gateway detects them. Types under Pattern match (instant) are matched with regular expressions:
Types under Model detection (slower) are matched by Presidio:
Redact secrets
The Redact secrets option 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. Under If redaction takes too long, set the number of seconds to wait, 2 by default and configurable from 0.1 to 30. Then select what happens when the scan does not finish in time: Allow request unredacted, the default, or Block request. This setting appears only for organizations with the PII redaction entitlement. Elsewhere the policy uses the defaults.Store trace content
The Store trace content option controls whether request and response bodies are stored in gateway traces. It is off for all organizations, and a data policy turns it on for the requests that policy matches. To store content without redacting anything, create a data policy that selects only Store trace content. When several data policies match a request, the most specific scope decides. If policies at the same scope disagree, content is not stored. With content off, traces still record metadata such as token usage, latency, status, model information, and policy evaluation results. For where gateway traces appear, what metadata they carry, and how trace content affects billing, see View LLM Gateway traces.Create a data policy
- Go to LLM Gateway and select the Policies tab.
- Click + Policy.
- Under Policy type, select Data protection.
- Enter a Name, or keep the generated one.
- Define a Scope and the subjects the policy applies to.
- Under What should this policy do, select any combination of Redact personal information (PII), Redact secrets, and Store trace content. For PII, select the types to redact.
- (Optional) Under If redaction takes too long, set the number of seconds and what happens when the scan does not finish in time.
- Click Create 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.
- Application traces outside the gateway: your application receives the restored values, so its own traces can capture them.
- 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
- View LLM Gateway traces: see where gateway traces land and who can read them.
- Spend policies: add cost controls alongside data protection.
Connect these docs to your agent of choice via MCP for real-time answers.

