The LLM Gateway is in beta.
agent-gateway service) proxies model calls from agents and coding agents to upstream LLM providers. The gateway applies policies at granular scopes for reliability, spend limits, and redaction of PII and secrets. You can also route your LangSmith deployment’s model calls through the gateway.
This guide enables it on a self-hosted Kubernetes install using the Helm chart. For the SaaS equivalent, see LLM Gateway.
Enabling the gateway requires Helm chart version 0.17.1 or later, which ships LangSmith version 0.17.30.
The Spend Monitoring dashboard is available with SmithDB, but not ClickHouse.
Enable the gateway
Add Helm values
The
agent-gateway service requires access to Postgres and Redis, and network access to other LangSmith pods, similar to backend and platform-backend. You may need to configure network policies, Kubernetes service accounts, and pod annotations to enable this access.Apply and verify
Apply the chart with chart version 0.17.1 or later. See Upgrade an installation for additional instructions.Verify the deployment is healthy. The Deployment is named
<release-fullname>-agent-gateway, which is langsmith-agent-gateway for a release named langsmith:Enable Presidio PII detection (optional)
Presidio Analyzer is a Microsoft-maintained NER service the gateway can call to detect PII in prompts before they reach upstream providers.PRESIDIO_ANALYZER_URL into the gateway pod so it discovers the analyzer in-cluster. No further app configuration is required.
Expose the gateway externally
The gateway uses the same Ingress as the LangSmith UI and API. Ifingress.enabled=true is already set in your Helm values, the gateway becomes reachable at https://<your-hostname>/gateway/ as soon as you set agentGateway.enabled=true. No separate Ingress, LoadBalancer, or DNS record is required. If you set config.basePath, the route moves to https://<your-hostname>/<basePath>/gateway/, and every gateway URL on this page needs the same prefix.
Check from any host that can reach your Ingress:
langsmith-agent-gateway, and the Service is ClusterIP by default. Exposing port 8083 directly (through a separate Ingress, service.type: LoadBalancer, or hostNetwork) is supported by the chart’s service block (agentGateway.service.type, loadBalancerIP, loadBalancerSourceRanges), but it is not the intended path. Use the frontend /gateway/ route unless you have a specific reason not to.
Roll back
Disabling the gateway removes the Deployment and Service and disables gateway features in the UI. Model calls routed to the gateway fail.Make your first call
This mirrors the SaaS quickstart with the base URL adjusted for self-hosted. Complete the steps above (gateway deployed, Ingress up) before continuing.An organization admin must add provider API keys to workspace or organization model provider secrets for the models you want to reach, then grant users a role with the
gateway:invoke and workspaces:read permissions and distribute a workspace-scoped API key. See Admin setup.Set environment variables
/openai/v1 to whatever you set if you’re using OpenAI models.Make a call
Either header works: A
Authorization: Bearer <key> or X-Api-Key: <key>. The examples below use the Authorization header. You can also test a call through the LLM Gateway home page simulator.200 confirms the gateway, API key, and provider secret are all wired correctly.View the trace
In the LangSmith UI, go to the tracing project named
gateway in the workspace tied to your API key. Every call routed through the gateway appears there with input, output, latency, and token usage, if tracing contents are enabled.Set a spend policy (optional)
Go to LLM Gateway and select Cost Controls to cap spend per workspace or per API key. Once a request exceeds the cap, the gateway returns a For the full guide, see Spend policies.
402 with a message naming the policies that blocked the request:Troubleshooting
- Gateway pod
CrashLoopBackOffimmediately after upgrade: Checkkubectl logs deploy/langsmith-agent-gateway. - Model calls fail with connection refused or timeout to
agent-gateway: Verify the gateway pod isRunningand that no NetworkPolicy in your cluster blocks port8083between pods in the LangSmith namespace.
Security notes
- The gateway makes outbound HTTP calls to provider LLM endpoints. Any custom provider URLs you configure must be validated against your egress policy; the service uses LangSmith’s SSRF-protection library for custom and configured provider URLs. Built-in providers resolve to fixed, provider-owned hostnames and aren’t a user-controlled-URL path.
- External clients should reach the gateway through the frontend’s
/gateway/path so requests inherit the same TLS termination, auth, and rate limiting as the rest of the LangSmith API. Creating a second Ingress or LoadBalancer directly to port8083bypasses those controls. AGENT_GATEWAY_URLis derived from the Helm release fullname and the chart’sagentGateway.name,agentGateway.service.port,namespace, andclusterDomainvalues. Overriding any of those on an existing install requires a rolling restart of every pod that reads the value.
Next steps
- Quickstart: the SaaS equivalent of the steps above.
- Admin setup: grant workspace users gateway access and configure provider secrets.
- Spend policies: cap spend at the organization, workspace, API key, or user level.
Connect these docs to your agent of choice via MCP for real-time answers.

