synth_ai.sdk.containers
Hosted Containers SDK — create, inspect, wait for, and delete containers.
Access this API through SynthClient().containers. The client reads
SYNTH_API_KEY when api_key is omitted and uses the environment-selected
backend when backend_base is omitted. An unconfigured development shell
defaults to http://localhost:8000.
Availability:
This is a compatibility client for deployments that expose
/v1/containers. The SDK’s bundled OpenAPI file describes those routes,
but the current production backend and its live OpenAPI contract route
hosted workloads through /v1/pools. Use SynthClient().pools for the
portable production workflow, and use this client only when your target
deployment exposes the compatibility routes.
Contract:
Container names are organization-scoped. definition and
environment_config are backend-owned JSON contracts for the selected
task_type; use the corresponding container guide rather than guessing
fields.
Errors:
HTTP failures raise httpx.HTTPStatusError. A missing API key fails
before the first request with a ValueError that names
SYNTH_API_KEY. Invalid response data raises
pydantic.ValidationError instead of returning a partial model.
Classes
ContainerType
Supported hosted container types.
ContainerSpec
Validated request for creating one hosted container.
Attributes:
name: Organization-scoped container name. This field is required.task_type: Required provisioning substrate selected fromContainerType.definition: Backend-owned definition fortask_type; defaults to an empty object.environment_config: Optional overrides; defaults toNoneand is omitted when unset.internal_url: Optional existing runtime URL. Defaults toNone; the service supplies a placeholder when omitted.
Container
Validated hosted-container response.
Attributes:
id: Stable container identifier used byget,delete, andwait_ready.name: Organization-scoped container name.task_type: Provisioning substrate reported by the service.status: Current lifecycle state.internal_url: Runtime URL when one is available.created_at: Service creation timestamp when supplied.updated_at: Service update timestamp when supplied.
ContainersClient
Create and manage hosted environment containers.
Args:
api_key: Synth API key. Defaults toSYNTH_API_KEY.backend_base: API base URL. Defaults to the environment-selected backend; an unconfigured development shell uses localhost.timeout_seconds: Default HTTP timeout in seconds. Defaults to30.
ValueError: The API key is missing.httpx.HTTPStatusError: The service rejects an operation.pydantic.ValidationError: A service response does not matchContainer.
create
spec: Validated container definition.timeout_seconds: Per-request timeout override. Defaults to the client timeout.
- The created
Container; provisioning may still be in progress.
httpx.HTTPStatusError: Authentication, authorization, validation, conflict, quota, or service errors.pydantic.ValidationError: The response is not a validContainer.
get
container_id: Stable ID returned bycreateorlist.timeout_seconds: Per-request timeout override. Defaults to the client timeout.
- The current
Containerrecord.
httpx.HTTPStatusError: The container is unavailable or the request is rejected.pydantic.ValidationError: The response is not a validContainer.
list
timeout_seconds: Per-request timeout override. Defaults to the client timeout.
- Validated
Containerrecords; an empty organization returns[].
httpx.HTTPStatusError: The request is rejected.pydantic.ValidationError: Any returned item is not a validContainer.
delete
container_id: Stable ID returned bycreateorlist.timeout_seconds: Per-request timeout override. Defaults to the client timeout.
Noneafter the service accepts the deletion.
httpx.HTTPStatusError: The container is unavailable or the request is rejected.
wait_ready
ready, failed, or stopped.
Args:
container_id: Stable ID returned bycreateorlist.timeout_seconds: Best-effort polling window. Defaults to300; an in-flight read or sleep can finish after the nominal window.poll_interval_seconds: Delay between reads. Defaults to2.timeout: Deprecated alias fortimeout_seconds.poll_interval: Deprecated alias forpoll_interval_seconds.
- The first terminal
Container; checkstatus == "ready"before use.
TimeoutError: No terminal state is observed during the polling window.httpx.HTTPStatusError: A polling request is rejected.pydantic.ValidationError: A polling response is invalid.
AsyncContainersClient
Async adapter over ContainersClient (thread-offloaded).