The LLM Gateway is in beta.
Before you begin
You need:- Membership in a LangSmith organization on a paid plan. On the Developer plan, the Simulator offers only LangChain-hosted models, which bill Gateway Credits instead of using a provider key.
- An API key for a model provider, unless your workspace already has one. The Simulator shows which providers are already set up.
Run a request in the Simulator
The Simulator sends a sample request through the gateway from your browser, so you can confirm your keys and model work before you change any code. The gateway uses two keys:- Your provider key stays in LangSmith as a workspace secret. The gateway uses it to call the provider.
- Your gateway key is a LangSmith API key, starting with
lsv2_, that your code sends to the gateway.
- In LangSmith, go to LLM Gateway and select the Simulator tab.
- Under Model routing, select a model. Needs key on a model tile means your workspace has no key for that provider yet.
- Click Run request. If a key is missing, the Simulator prompts you for it before it sends the request.
Send a request from your code
Compared with calling a provider directly, a gateway request changes two things:- The base URL points at the gateway instead of the provider’s API.
- The API key is your LangSmith API key instead of the provider’s key.
-
Set your LangSmith API key and the gateway’s base URL in your environment:
This is the US gateway. For another region, replace the hostname with your regional gateway. On BYOC, use your data plane URL followed by
/gateway/v1. On self-hosted LangSmith, use your LangSmith URL followed by/gateway/v1. -
List the models you can call:
Each
idin the response is a model ID. The list reflects your workspace’s provider keys and model access policies. -
Send a request. Replace
<MODEL_ID>with a chat model ID from the list, such as the model you tested in the Simulator:A successful request returns a JSON response that contains a one-sentence answer. If it fails instead, see Fix authentication errors.
LANGSMITH_GATEWAY to true alongside LANGSMITH_API_KEY, and every supported chat model in the process calls the gateway in its provider’s native API format. For details, see Direct model access.
View the trace
In the Simulator, click View trace next to the response. Requests from your code appear in the same Traces tab of LLM Gateway. By default, a trace records metadata such as token counts and cost. For more information, see View LLM Gateway traces.Troubleshoot
For401 and 403 errors, see Fix authentication errors. For 424 errors, see Fix provider credential errors.
The Simulator signals missing permissions without an error code:
Next steps
Now that you can send requests through the gateway, explore its other capabilities:- Set a spend limit: cap spend by organization, workspace, API key, or user.
- Add model fallbacks: retry failed requests on backup models, and test the chain in the Simulator.
- API formats: send Chat Completions, Messages, or Responses requests.
- Set up coding agents: route Claude Code, Codex, Gemini CLI, or Deep Agents Code through the gateway.
- Gateway Credits: call LangChain-hosted models without a provider key.
Connect these docs to your agent of choice via MCP for real-time answers.

