Python SDK (preview)
meadow-python is a Python SDK for Meadow’s own API: sandboxes, images, projects, keys, provider keys, usage, budgets and the audit log. It is a preview. Version 0.1.0 is not published on PyPI yet, so install it from source as below. The import name is meadow.
Model calls do not need it. Keep the official openai and anthropic packages and set their base URL to Meadow, as Use your existing tools shows.
This SDK is separate from the Python client on Clients, which also imports as meadow. Install one of the two in an environment, not both.
Install from source
Needs Python 3.11 or newer, git, and read access to the Meadow source repository, which is private during the beta. Ask your Meadow contact for access.
Check the install:
Quickstart
Set your key. The client reads MEADOW_API_KEY, and MEADOW_BASE_URL when set (the default is https://api.usemeadow.ai). Store a sandbox vendor key first, as Provider keys shows.
Leaving the inner with block deletes the sandbox, also when the code inside raises. timeout_seconds ends it after ten minutes if your program dies first. AsyncMeadow has the same groups and methods as coroutines, and async with works the same way.
What it does for you
- Retries: at most 3 sends. A 429 is retried for every call. A 5xx, a timeout or a lost connection is retried only for calls that are safe to repeat: creating a project or an image, a project update that rotates the webhook secret, minting or rotating a key, running a command and writing stdin are sent once. The rules are the ones in Errors.
- Idempotency: sandbox, image, project and key creates and background commands carry one
Idempotency-Keyacross their retries. - Timeouts: 60 seconds per call by default, covering the whole answer. A command waits its
timeout_secondsplus 30 seconds. A stream has no read timeout. - Pagination: iterating over
client.sandboxes.list()yields every sandbox and fetches the next pages. - Errors: the OpenAI SDK’s classes (
meadow.NotFoundError,meadow.ConflictError,meadow.RateLimitError, …) withstatus_code,type,code,messageandrequest_idfrom Meadow’s error body. Those fields are cut, have keys replaced by[redacted]and have control characters escaped;err.bodyholds the raw body. - Your key: the base URL must be
https(orhttpto a loopback host), redirects are never followed, andrepr()of the client and of models hides keys, secrets, SSH and port access, environment maps and command output. A custom HTTPS base URL receives your key: set it only to a host you trust. - Ids are checked before they go into a URL, an answer is capped at 32 MiB (2 GiB for a file, with
download_file_toto stream one), and a streamed command stops at a line over 1 MiB, an event over 4 MiB or an exit event without an integerexit_code.
The README in sdks/python lists every method.
Operations used on this page: createSandbox, execInSandbox, uploadFile, downloadFile, deleteSandbox.