mesa-rest client, resolves the default organization for you, and exposes a native virtual filesystem for repo I/O and shell execution.
Python 3.10 or newer is required.
Installation
Create a client
Client options
str | None
Ed25519 private key. The SDK reads
MESA_PRIVATE_KEY when no explicit private key is supplied.str
REST API base URL. Defaults to
https://api.mesa.dev/v1. http and https are accepted. Trailing slashes are stripped.str | None
Appended to the SDK user agent. The default user agent starts with
mesa-sdk-python.Client lifecycle
Create oneMesa client for your process or application and reuse it across request handlers. If your framework has a lifespan hook and you want explicit cleanup, wrap the client in async with Mesa(...) at application lifespan, not inside each handler.
Organization resolution
The client reads its organization from the private key. Resource methods always use that organization and do not accept anorg value.
await mesa.org.get() when you need organization metadata from the API.
Resource APIs
Response objects
The high-level SDK returns model instances generated bymesa-rest. Use attribute access, not dictionary access.
Common types
Import common dataclasses and native result types frommesa_sdk.
Upstream configuration types live in
mesa_sdk.types:
mesa.repos.update(...), UpstreamConfig.auth is tri-state: omit to preserve existing credentials, pass None to clear credentials, or pass TokenAuth / UsernamePasswordAuth to set credentials.
Error model
REST API operations raiseMesaError subclasses.
SDK setup errors include
MissingCredentialError, InvalidApiUrlError, OrgResolutionError, and InvalidOptionsError.
Classified native filesystem failures raise one of three public exceptions. All inherit from MesaFileSystemError, so except MesaFileSystemError catches every category.
Each exception preserves the message, the original exception in
__cause__, and its errno when available (None otherwise). Its error_class attribute holds the classification. Copying and pickling preserve the exception’s category, cause, and errno.
These exceptions no longer inherit from built-in types such as ValueError, FileNotFoundError, or OSError. Update handlers for native filesystem failures to catch a category above or MesaFileSystemError. Inspect __cause__ when you need the original built-in error. Bash failures and Python-side argument validation continue to use their existing exceptions.
The TypeScript SDK exposes the same three exception classes. These categories also drive the mesa CLI’s exit codes.
Raw generated client
mesa.raw exposes the authenticated generated mesa-rest client. Use it when the high-level SDK does not expose a generated REST operation or option yet.
Response[T] wrapper with status_code, parsed, and headers. High-level SDK methods unwrap successful responses and raise typed errors for non-2xx responses.

