Documentation Index
Fetch the complete documentation index at: https://docs.langchain.com/llms.txt
Use this file to discover all available pages before exploring further.
Private beta: The LLM Gateway is in private beta. Sign up for the waitlist to get access.
Prerequisites
Before you start, confirm that:- Your Organization admin has enabled the LLM Gateway and added provider API keys to workspace secrets. To set this up, refer to Admin setup.
- You have a workspace-scoped LangSmith API key attached to a role with
gateway:invokeandworkspaces:readpermissions. Ask your org admin if you’re unsure.
1. Set environment variables
Set the following in your terminal (or add them to your~/.zshrc to persist across sessions):
2. Make a call
200 response with a chat completion confirms the gateway, your API key, and your role permissions are all working.
3. View your trace
Open the LangSmith UI and navigate to the tracing project namedgateway or gateway-<short_api_key>-<api_key_id> in the workspace associated with your API key. You should see a new trace for the call you just made.
4. Set a spend policy (optional)
Go to Settings → Gateway → LLM Gateway in LangSmith to create a spend policy. For example, you can set a daily $10 cap on your API key. When the cap is reached, the gateway returns a402 response with the message: "Request blocked by gateway policies: R&D Spend Cap".
See Spend policies for the full guide on policy dimensions, time windows, and conflict resolution.
How the gateway handles requests
Here’s what the gateway did when you made a call:- Authenticated your request using the LangSmith API key.
- Resolved the actual provider API key (for example,
OPENAI_API_KEY) from your workspace’s Provider Secrets. - Evaluated any active policies (spend limits, PII redaction, secrets redaction).
- Proxied the request to the upstream provider (OpenAI, Anthropic, or Gemini).
- Traced the call to LangSmith, including token counts, cost, and any policy events.
Next steps
- Set up coding agents: route Claude Code, Codex, or Gemini CLI through the gateway.
- Spend policies: configure cost limits across your organization.
- PII and secrets redaction: prevent sensitive data from reaching providers.
Connect these docs to Claude, VSCode, and more via MCP for real-time answers.

