The LLM Gateway is in beta.
Compare API formats
On LangSmith Cloud in the US region, each format uses the following base URL and endpoint. For other regions, BYOC data planes, and self-hosted installations, see Check availability.Understand translation behavior
The endpoint determines the format your application sends and receives. The model ID determines the upstream provider.- When the provider supports the selected format natively, the gateway preserves that format.
- Otherwise, the gateway translates the request into a format supported by the provider and translates the response back, including streaming responses.
- Translation can reject fields that cannot be represented in the target provider format. Use direct model access when provider-native behavior is required.
Use prompt caching
How you request prompt caching depends on the format you send and the model you call:- OpenAI models: OpenAI caches prompts automatically. To control cache lifetime or breakpoints, use OpenAI’s caching fields, such as
prompt_cache_optionsorprompt_cache_retention. Which fields and values each model accepts is set by OpenAI. For details, see the OpenAI prompt caching guide. - Anthropic models in Messages format: Use Anthropic’s
cache_controlfield. For details, see the Anthropic prompt caching guide. - Anthropic models in Chat Completions or Responses format: Set any of
prompt_cache_options,prompt_cache_retention, orprompt_cache_key. The gateway turns on Anthropic prompt caching with Anthropic’s default five-minute cache lifetime. It does not carry over a requested lifetime, retention, or breakpoint mode. - OpenAI models in Messages format: The gateway drops
cache_controlfields. OpenAI’s automatic caching still applies.
Send a request
Each format has its own request shape. For example, Chat Completions takesmessages, Responses takes input, and Messages requires max_tokens. Replace <MODEL_ID> with a model ID:
Choose a model ID
The model ID selects the provider and the credential that pays for the call. Model IDs work the same way in every format:- Your own provider key:
<provider>/<model>, such asopenai/gpt-5.4-miniorazure/<deployment-name>. The gateway calls the provider with the provider key stored in your workspace. - Gateway Credits: a hosted model slug, such as
moonshotai/kimi-k3. Gateway Credits bill LangChain-hosted models to your LangSmith account, with no provider key required. - Saved model configuration:
custom/<name>. The gateway uses the provider, model, and credentials from the saved model configuration.
List models
CallGET /v1/models to list the model IDs your workspace can call. The gateway returns a single OpenAI-compatible list:
Read response metadata
The gateway adds anX-LangSmith-Gateway-Metadata header to its responses. The header is a JSON object that describes how the gateway handled the request, such as the provider and model it called and whether a policy blocked the request. It contains no credentials or prompt and response content.
To tell a gateway decision from a provider error, read two fields: outcome says how the request ended, such as success, blocked, or upstream_error, and error_source says whether a failure came from the caller (request), the provider (upstream), or the gateway (internal). When a fallback chain runs, the header also lists each attempt.
LangChain chat models in Python (langchain-openai>=1.6.7 or langchain-anthropic>=1.7.5) attach the header to the model’s run, so with tracing on, the same details appear in the run’s Gateway section.
Fix request errors
To tell whether the gateway or the provider returned an error, read the
outcome and error_source fields in the response metadata.
See also
- Send your first LLM Gateway request: make your first request and view its trace.
- How the gateway works: what happens to each request, and which hostname to use in each region and on BYOC.
- Direct model access: bypass format translation and use provider-native APIs.
- Model fallbacks: retry requests against backup models.
Connect these docs to your agent of choice via MCP for real-time answers.

