Installation
Environment variables
The SDK reads connection settings from environment variables by default.ConnectionConfig
ConnectionConfig holds the credentials and endpoint used by every API call. You rarely need to instantiate it directly — Sandbox.create() accepts api_key and domain parameters that build it for you. Use it directly when you need to share connection settings across multiple calls or customise the request timeout.
str
default:"$DECLAW_API_KEY"
API key sent as the
X-API-Key header on every request. Defaults to the
DECLAW_API_KEY environment variable.str
default:"$DECLAW_DOMAIN or api.declaw.ai"
Hostname of the Declaw API server. Supports
host:port format. Port is
parsed from the string and defaults to 443.int
default:"443"
Explicit port override. Ignored when
domain already contains a port.str | None
default:"None"
Full URL override (e.g.
http://localhost:8080). When set, domain and
port are not used to construct the URL.float | None
default:"None"
Default per-request timeout in seconds applied to all HTTP calls made with
this config. Individual methods accept a
request_timeout parameter that
overrides this value.Sync vs async
The SDK ships two sandbox classes.AsyncSandbox exposes commands and files as
awaitable methods on the sandbox (run_command, read_file, write_file, …)
rather than the commands and files namespaces; see
AsyncSandbox for the full list. Directory watching
(files.watch_dir()) and commands.run_stream() are sync-only. To stream a
command’s output from async code, use stdio:
proc = await sbx.stdio.start(cmd), then await proc.close_stdin() so a command
that reads stdin gets end-of-input instead of waiting for it, then
async for stream_type, data in proc.
Use
AsyncSandbox whenever you need to manage multiple sandboxes in parallel or you are running inside an async framework such as FastAPI, LangGraph, or asyncio event loops.
Quick example
- Synchronous
- Async
What’s exported
The top-leveldeclaw package re-exports every public class, exception, model, and enum: