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.
API key sent as the
X-API-Key header on every request. Defaults to the
DECLAW_API_KEY environment variable.Hostname of the Declaw API server. Supports
host:port format. Port is
parsed from the string and defaults to 443.Explicit port override. Ignored when
domain already contains a port.Full URL override (e.g.
http://localhost:8080). When set, domain and
port are not used to construct the URL.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 with identical surface areas:Sandbox | AsyncSandbox | |
|---|---|---|
| Import | from declaw import Sandbox | from declaw import AsyncSandbox |
| Create | Sandbox.create(...) | await AsyncSandbox.create(...) |
| Context manager | with Sandbox.create(...) as sbx: | async with await AsyncSandbox.create(...) as sbx: |
| Best for | Scripts, CLI tools, simple agents | Concurrent workloads, multiple sandboxes, FastAPI/async frameworks |
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: