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_modelsServiceURL
Class●Since v0.7

ServiceURL

Authenticated URL for accessing an HTTP service running in a sandbox.

Properties auto-refresh the token transparently when it nears expiry. HTTP helper methods (.get, .post, etc.) inject the auth header automatically.

When constructed by :meth:SandboxClient.service or :meth:Sandbox.service, the object holds an internal refresher that re-calls the API to obtain a fresh token before the current one expires.

Example::

svc = sb.service(port=3000)

resp = svc.get("/api/data")  # token injected + auto-refreshed
print(svc.browser_url)  # always-fresh URL
Copy
ServiceURL(
  self,
  browser_url: str,
  service_url: str,
  token: str,
  expires_at: str,
  *,
  _refresher: Optional[Callable[[], ServiceURL]] = None
)

Constructors

constructor
__init__
NameType
browser_urlstr
service_urlstr
tokenstr
expires_atstr
_refresherOptional[Callable[[], ServiceURL]]

Attributes

attribute
token: str

Return the raw JWT, refreshing if near expiry.

attribute
service_url: str

Return the base URL, refreshing if near expiry.

attribute
browser_url: str

Return the browser auth URL, refreshing if near expiry.

attribute
expires_at: str

Return the ISO 8601 expiration, refreshing if near expiry.

Methods

method
request

Make an HTTP request to the service, injecting the auth header.

method
get

HTTP GET to the service.

method
post

HTTP POST to the service.

method
put

HTTP PUT to the service.

method
patch

HTTP PATCH to the service.

method
delete

HTTP DELETE to the service.

method
from_dict

Create a ServiceURL from API response dict.

View source on GitHub