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
PythonlangsmithresourcessandboxesboxesAsyncBoxesResourcecreate
Method●Since v0.16

create

Copy
create(
  self,
  *,
  access_delegation: box_create_params.AccessDelegation | Omit
View source on GitHub
=
omit
,
cpu_millicores
:
int
|
Omit
=
omit
,
delete_after_stop_seconds
:
int
|
Omit
=
omit
,
env_vars
:
Dict
[
str
,
str
]
|
Omit
=
omit
,
fs_capacity_bytes
:
int
|
Omit
=
omit
,
idle_ttl_seconds
:
int
|
Omit
=
omit
,
labels
:
Dict
[
str
,
str
]
|
Omit
=
omit
,
mem_bytes
:
int
|
Omit
=
omit
,
mount_config
:
SandboxMountConfigParam
|
Omit
=
omit
,
name
:
str
|
Omit
=
omit
,
nested_virtualization
:
bool
|
Omit
=
omit
,
persistent
:
bool
|
Omit
=
omit
,
preserve_memory_on_stop
:
bool
|
Omit
=
omit
,
proxy_config
:
ProxyConfigParam
|
Omit
=
omit
,
restore_memory
:
bool
|
Omit
=
omit
,
run_config
:
box_create_params
.
RunConfig
|
Omit
=
omit
,
snapshot
:
str
|
Omit
=
omit
,
snapshot_id
:
str
|
Omit
=
omit
,
snapshot_name
:
str
|
Omit
=
omit
,
tag_value_ids
:
SequenceNotStr
[
str
]
|
Omit
=
omit
,
vcpus
:
int
|
Omit
=
omit
,
volumes
:
Iterable
[
box_create_params
.
Volume
]
|
Omit
=
omit
,
extra_headers
:
Headers
|
None
=
None
,
extra_query
:
Query
|
None
=
None
,
extra_body
:
Body
|
None
=
None
,
timeout
:
float
|
httpx
.
Timeout
|
None
|
NotGiven
=
not_given
)
->
SandboxResponse

Parameters

NameTypeDescription
access_delegationbox_create_params.AccessDelegation | Omit
Default:omit

AccessDelegation lets code inside the sandbox call the LangSmith API as you, with at most the permissions granted here. Omit for no access.

cpu_millicoresint | Omit
Default:omit

CPUMillicores optionally requests CPU at millicore granularity (e.g. 500 = 0.5 vCPU); takes precedence over VCPUs. Fractional (sub-vCPU) values are not available for every sandbox.

fs_capacity_bytesint | Omit
Default:omit
labelsDict[str, str] | Omit
Default:omit
mem_bytesint | Omit
Default:omit
nested_virtualizationbool | Omit
Default:omit
persistentbool | Omit
Default:omit
preserve_memory_on_stopbool | Omit
Default:omit
restore_memorybool | Omit
Default:omit
run_configbox_create_params.RunConfig | Omit
Default:omit
snapshotstr | Omit
Default:omit
snapshot_namestr | Omit
Default:omit
volumesIterable[box_create_params.Volume] | Omit
Default:omit
extra_headersHeaders | None
Default:None
extra_queryQuery | None
Default:None
extra_bodyBody | None
Default:None
timeoutfloat | httpx.Timeout | None | NotGiven
Default:not_given

Create a new sandbox from a snapshot.

Provide at most one of snapshot_id or snapshot_name; if neither is provided, the server uses the default snapshot. snapshot_name accepts a Docker-style name or name:tag reference (a bare name resolves to name:latest).

Disk for the sandbox, in bytes; defaults to the snapshot's and cannot be smaller. A sandbox with persistent=false gets at most 16 GiB of disk per vCPU, so at most 256 GiB: omit CPU and it is derived from the disk, set it and a larger disk is rejected.

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

Memory for the sandbox, in bytes. Memory is tied to CPU at 4 GiB per vCPU: omit it and it follows that ratio; set it and it must stay within 50% of the ratio for the requested CPU, so a 1 vCPU sandbox accepts 2-6 GiB. Setting memory without CPU derives the CPU from the same ratio. Maximum 64 GiB.

NestedVirtualization, when true, lets the sandbox run virtual machines of its own, for example with KVM. It requires an organization with nested virtualization enabled; a create that asks for it without that is rejected. When omitted, the sandbox takes its snapshot's setting, which defaults to false.

Persistent keeps the sandbox's filesystem across stops (the default, true). Set it to false for a disposable sandbox: its writes are discarded whenever it stops, the next start boots it fresh from its snapshot, and it is never charged for storage. A sandbox that is not persistent cannot preserve memory on stop or have its filesystem captured as a snapshot (exporting a Docker image from it with docker_image still works), and some snapshots captured from other sandboxes cannot start one; such a create is rejected.

PreserveMemoryOnStop, when true, suspends the sandbox's memory on a voluntary stop (idle timeout or explicit stop) so the next start resumes from where it left off. Default false discards memory and keeps only the filesystem, so the next start is a cold boot. Restarts triggered by infrastructure maintenance always preserve memory regardless of this setting.

RestoreMemory selects how the sandbox handles a snapshot's captured memory:

nil → if-present: resume from memory when the snapshot has it, else cold-boot (default). true → always: resume from memory; rejected if the snapshot has none. false → never: always cold-boot.

Applies to this request only.

RunConfig overrides the snapshot's run config for this sandbox: user and work_dir replace the snapshot's, env_vars merge over it. The result is what the sandbox boots with, and what a snapshot captured from it carries.

Snapshot is a Docker-style name or name:tag reference to boot from. A bare name resolves to name:latest.

SnapshotName is a synonym for Snapshot, accepted for compatibility with clients that predate it. Set one or the other.

Volumes (beta) attaches existing volumes at mount paths inside the sandbox. At most 4; requires sandbox volumes to be enabled for your workspace. Attaching a volume requires being its creator or holding sandboxes:exec.

Send extra headers

Add additional query parameters to the request

Add additional JSON properties to the request

Override the client-level default timeout for this request, in seconds