LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
    • Overview
    • Caches
    • Callbacks
    • Documents
    • Document loaders
    • Embeddings
    • Exceptions
    • Language models
    • Serialization
    • Output parsers
    • Prompts
    • Rate limiters
    • Retrievers
    • Runnables
    • Utilities
    • Vector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    โŒ˜I

    Chat LangChain

    What can I help with?

    Enter to sendยทShift+Enter new line

    Menu

    OverviewCachesCallbacksDocumentsDocument loadersEmbeddingsExceptionsLanguage modelsSerializationOutput parsersPromptsRate limitersRetrieversRunnablesUtilitiesVector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    Language
    Theme
    Pythonlangchain-coreutils_gatewaylangsmith_gateway
    Functionโ—Since v1.8

    langsmith_gateway

    Copy
    langsmith_gateway(
      *,
      api_key: str | SecretStr,
      base_url: str = _LANGSMITH_GATEWAY_DEFAULT_BASE
    ) -> Iterator
    View source on GitHub
    [
    None
    ]

    Parameters

    NameTypeDescription
    api_key*str | SecretStr
    base_urlstr
    Default:_LANGSMITH_GATEWAY_DEFAULT_BASE

    Route chat models built in this context through the LangSmith gateway.

    Unlike the LANGSMITH_GATEWAY env var, which applies to the whole process, this applies only to the current context (thread or asyncio task), so a server can route some requests through the gateway and not others.

    The gateway is resolved when a model is constructed, so wrap construction (for example load() of a serialized model), not invocation.

    While the context is active, the gateway URL and key take precedence over any base URL or API key passed to the model or set in the environment. This lets a caller load an untrusted serialized model without it redirecting the gateway key to another host or bypassing the gateway.

    Key used to authenticate to the gateway.

    Gateway host. The provider's path is appended per model.