LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • Client
  • AsyncClient
  • Run Helpers
  • Run Trees
  • Evaluation
  • Schemas
  • Utilities
  • Wrappers
  • Anonymizer
  • Testing
  • Expect API
  • Middleware
  • Pytest Plugin
  • Deployment SDK
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

OverviewClientAsyncClientRun HelpersRun TreesEvaluationSchemasUtilitiesWrappersAnonymizerTestingExpect APIMiddlewarePytest PluginDeployment SDK
Language
Theme
Pythonlangsmithsandbox_async_clientAsyncSandboxClientservice
Method●Since v0.7

service

Copy
service(
  self,
  name: str,
  port: int,
  *,
  expires_in_seconds: int 
View source on GitHub
=
600
,
access
:
Optional
[
ServiceAccess
]
=
None
,
headers
:
RequestHeaders
=
None
)
->
Union
[
AsyncServiceURL
,
ServiceLoginURL
]

Parameters

NameTypeDescription
name*str

Sandbox name.

port*int

Port the service is listening on inside the sandbox.

expires_in_secondsint
Default:600

Token TTL in seconds (1--86400, default 600).

accessOptional[ServiceAccess]
Default:None
headersRequestHeaders
Default:None

Get an authenticated URL for a service running inside a sandbox.

Returns an :class:AsyncServiceURL whose async accessors auto-refresh the token transparently before it expires. The object also provides async HTTP helper methods (.get, .post, etc.) that inject the authentication header automatically.

Gate the URL behind LangSmith login instead of a token, returning a :class:ServiceLoginURL. "restricted" admits anyone with sandboxes:read on the sandbox, "workspace" any member of the owning workspace. Neither carries a token or expires, so expires_in_seconds does not apply. Omit for token mode; a login grant is durable, so token mode is refused with 409 while one is in place.

Optional per-request header overrides.