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

Chat LangChain

What can I help with?

Enter to send·Shift+Enter new line

Menu

OverviewClientAsyncClientRun HelpersRun TreesEvaluationSchemasUtilitiesWrappersAnonymizerTestingExpect APIMiddlewarePytest PluginDeployment SDK
Language
Theme
Pythonlangsmithsandbox_async_clientAsyncSandboxClientcreate_sandbox
Method●Since v0.14

create_sandbox

Copy
create_sandbox(
  self,
  snapshot_id: Optional[str] = None,
  *
View source on GitHub
,
snapshot
:
Optional
[
str
]
=
None
,
snapshot_name
:
Optional
[
str
]
=
None
,
name
:
Optional
[
str
]
=
None
,
timeout
:
int
=
30
,
wait_for_ready
:
bool
=
True
,
idle_ttl_seconds
:
Optional
[
int
]
=
None
,
delete_after_stop_seconds
:
Optional
[
int
]
=
None
,
persistent
:
Optional
[
bool
]
=
None
,
preserve_memory_on_stop
:
Optional
[
bool
]
=
None
,
restore_memory
:
Optional
[
bool
]
=
None
,
vcpus
:
Optional
[
int
]
=
None
,
mem_bytes
:
Optional
[
int
]
=
None
,
fs_capacity_bytes
:
Optional
[
int
]
=
None
,
labels
:
Optional
[
dict
[
str
,
str
]
]
=
None
,
mount_config
:
Optional
[
SandboxMountConfig
]
=
None
,
proxy_config
:
Optional
[
SandboxProxyConfig
]
=
None
,
run_config
:
Optional
[
Union
[
RunConfig
,
dict
[
str
,
Any
]
]
]
=
None
,
access_delegation
:
Optional
[
AccessDelegation
]
=
None
,
headers
:
RequestHeaders
=
None
)
->
AsyncSandbox

Parameters

NameTypeDescription
snapshot_idOptional[str]
Default:None

Optional snapshot ID to boot from. Mutually exclusive with snapshot and snapshot_name.

snapshotOptional[str]
Default:None

Snapshot to boot from, as a UUID, name:tag, or a bare name (which means name:latest). Prefer this over snapshot_id and snapshot_name: it covers all three forms.

snapshot_nameOptional[str]
Default:None
nameOptional[str]
Default:None
timeoutint
Default:30
wait_for_readybool
Default:True
idle_ttl_secondsOptional[int]
Default:None
delete_after_stop_secondsOptional[int]
Default:None
persistentOptional[bool]
Default:None
preserve_memory_on_stopOptional[bool]
Default:None
restore_memoryOptional[bool]
Default:None
vcpusOptional[int]
Default:None
mem_bytesOptional[int]
Default:None
fs_capacity_bytesOptional[int]
Default:None
labelsOptional[dict[str, str]]
Default:None
mount_configOptional[SandboxMountConfig]
Default:None
proxy_configOptional[SandboxProxyConfig]
Default:None
access_delegationOptional[AccessDelegation]
Default:None

Create a new Sandbox.

The sandbox is NOT automatically deleted. Use delete_sandbox() for cleanup, or use sandbox() for automatic cleanup with a context manager.

Deprecated synonym for snapshot, kept for callers that predate it.

Optional sandbox name (auto-generated if not provided).

Timeout in seconds when waiting for ready (only used when wait_for_ready=True).

If True (default), block until sandbox is ready. If False, return immediately with status "provisioning". Use get_sandbox_status() or wait_for_sandbox() to poll for readiness.

Idle timeout in seconds. The launcher automatically stops the sandbox after this duration of inactivity. Must be a multiple of 60. 0 explicitly disables the idle stop. When omitted (None), the server applies a default of 600 seconds (10 minutes).

Seconds after the sandbox enters the stopped state before it (and its filesystem clone) are permanently deleted. Must be a multiple of 60. 0 disables stop-anchored deletion (manual cleanup required). When omitted (None), the server applies its configured default.

Whether filesystem writes survive stops; false discards them on stop. Omit to use the server default.

If True, a voluntary stop (idle timeout or stop_sandbox()) suspends the sandbox's memory, so the next start resumes running processes instead of cold-booting. Requires a persistent sandbox. Omit to use the server default (off).

How to handle memory captured in the snapshot, for this create only. True always resumes from it (rejected if the snapshot has none), False always cold-boots. Omit to resume when the snapshot has memory and cold-boot otherwise.

Number of vCPUs.

Memory in bytes.

Root filesystem capacity in bytes.

Free-form key/value metadata stored with the sandbox and returned on reads. Labels from the source snapshot are inherited unless overridden here.

Mount configuration forwarded to the server as mount_config. The backend expands mount auth into runtime proxy rules. Explicit AWS/GCP proxy rules in proxy_config conflict with mount auth for the same provider.

Per-sandbox proxy configuration forwarded to the server as-is. Shape matches the backend proxy_config field: {"rules": [...], "access_control": {"allow_list": [...]}} or {"access_control": {"deny_list": [...]}}. Use access_control.allow_list to restrict outbound HTTPS to a set of host patterns (exact domains, globs like *.example.com, IPs, CIDRs, or ~regex). Use proxy_config with provider rule helpers such as aws_auth to let the proxy sign supported AWS HTTPS requests on the sandbox's behalf.

Optional grant letting code inside the sandbox call the LangSmith API as you, with no API key of its own. {"mode": "EXPLICIT", "permissions": [...]} grants the permissions listed, each of which you must already hold. The grant belongs to the sandbox, so anyone who can exec into it can make calls under it. Omit for no access.