Python SDK reference
The public entrypoint is from envloop import Client. Methods synchronously return dictionaries; use keyword arguments as documented below. The server remains responsible for validation and execution. See Python SDK guide for installation and usage.
The public envloop-cli package provides shared configuration and the config= parameter. Omitted or None values use the precedence chain; empty strings are errors. Saved Keys and workspaces are bound to canonical API URLs. Initial persistence supports POSIX only; use explicit or environment values with config=False on Windows.
Every installation includes all client feature code; extras select dependencies only. ANS operations require the public dependency installed by envloop-cli[asset]. See installation groups. Command paths and public API authorization remain unchanged.
Client
| Method | Behavior |
|---|---|
Client.remote(api_url=None, *, timeout=30, api_key=None, workspace_id=None, project_id=None, config=True) | Create an HTTP client; explicit values > system environment > shared user files; config=False disables file loading; no cwd dotenv |
client.close() | Release client-owned local context; does not stop remote tasks or resources |
Context managers are supported. Remote timeout is the deadline for each HTTP request; trials/jobs wait timeout is the client's total waiting deadline. Use Client.remote() for platform access; Client.local() / init_repository are legacy development-test helpers. See client compatibility.
Trials
client.trials is the public Trial client. Agent-only fields such as task_id and reward are absent from Train summaries. Type-specific reads and stopping are authorized by the platform.
Task definitions are executed by submitting Jobs. client.trials only inspects or controls existing Trials; it has no submit method. Use client.jobs.submit(source=PATH_OR_FILES) for an inline Task, or client.jobs.submit(DATASET, task_id=TASK_ID) for one Dataset Task. Both return a Job receipt. Wait for dispatch before selecting a Trial; list it with client.trials.list(job_id=job["job_id"]).
| Method | Return / behavior |
|---|---|
trials.list(**kwargs) | Paginate Agent, Sandbox, Train and Inference Trials with type, job_id, limit, cursor; reuse the same filters on continuation |
trials.status(trial_id) | Status details, including terminal state, exit code, or error fields |
trials.wait(trial_id, *, timeout=30, poll_interval=0.05) | Return final status; terminal states succeeded / failed / cancelled |
trials.result(trial_id) | Public status, reward, structured result, outputs and collection; no universal stdout/stderr fields; does not wait |
trials.detail(trial_id) | Type-specific detail; read common identity with trials.status |
trials.training(trial_id) | Train configuration and recorded observations |
trials.metrics(trial_id, **kwargs) | Actual metrics for this Trial |
trials.checkpoints(trial_id, **kwargs) | Checkpoints belonging to this Trial |
trials.snapshot(trial_id) | Frozen input snapshot |
trials.stop(trial_id) | Stop-request response; support depends on the execution backend |
wait requires a finite nonnegative timeout and a finite positive poll_interval. A timeout raises TimeoutError without cancelling the run; execution failure returns failed status. Directory-read and platform validation errors propagate separately.
Jobs
client.jobs.submit_spec({"request_id": "YOUR_REQUEST_ID", "spec": {"schema": "envloop.job/v2", "type": "sandbox", "profile": "examples/shell@1"}}) sends canonical JobSpecs for all four types. Optional overrides wins over the Profile; Inference needs spec.name. Existing type-specific submission methods remain available.
client.jobs.submit(
dataset=None,
*,
source=None,
task_ref=None,
task_id=None,
request_id=None,
attempts=1,
namespace=None,
config=None,
split=None,
revision=None,
runner=None,
profile_id=None,
job_id=None,
tag=None,
queue_id="default",
priority=0,
command=None,
source_job_id=None,
source_trial_id=None,
type="bench",
image=None,
**options,
)
For Bench Jobs, choose one of dataset, source or task_ref. A named Profile can also supply omitted Dataset/Runner defaults. For Sandbox Jobs, use type="sandbox" and a registered runner without Dataset input; image selects its Docker image (default python:3.11). For either type, resources={"cpus": 1, "memory_mb": 2048} overrides the Runner and Profile shape of each Trial for that Job; it takes cpus, memory_mb, storage_mb and gpus, and Runner Jobs only. Training uses client.training_jobs.submit, and inference uses client.jobs.submit_inference or client.endpoints.create. source accepts a two-file directory or file-content Mapping; task_ref is a fixed Task reference. task_id selects one Dataset member. Inline Jobs have dataset_ref=null; missing Dataset metadata is unknown, not a fabricated version or score. Submission returns job_id and members / attempts, with default attempts=1.
dataset is a name, name@version, or fixed dataset_ref Mapping. With a runner, it also accepts a Dataset selector Mapping without kind. Selection options cannot be combined with a fixed dataset_ref. runner is an optional explicit name@revision override (commit, tag or branch); omitting it uses the Dataset's pinned RunnerRef. Runner has no version, default, release or implicit HEAD; profile_id, job_id, and tag are optional submission fields, queue_id defaults to default, and priority defaults to 0, with higher values dispatching waiting tasks sooner. options passes business fields such as profile_name, profile_version, seed, and execution={"timeout_seconds": 600, "delete_delay_seconds": 300}. Bench and Sandbox submissions may pass a top-level provider option, validated against the enabled providers for that Job type. Train and Inference use platform selection. Profiles and nested execution fields cannot override the provider. Legacy Client.local() remains a platform development helper. Arbitrary fields are not supported. submit returns a dictionary containing job_id. All selections are sent through /v1/jobs for platform resolution; the client does not freeze the catalog.
For an evaluation Bench Job, source_job_id retains its training source; optionally add source_trial_id to identify one Train Trial. A Trial source requires its Job ID. The platform resolves legacy Job aliases and checks training read permission, project scope and Trial membership. These fields record provenance; they do not choose a model or create an evaluation engine.
command overrides the default Runner script for every member, with the same validation as Task. By default, Runner execution.command is used; if absent, the entrypoint determines bash main.sh or python main.py. Source directories contain runner.toml by default; legacy task.toml is supported, but both configurations together are rejected.
| Method | Return / behavior |
|---|---|
jobs.status(job_id) | Status details |
jobs.wait(job_id, *, timeout=600, poll_interval=0.1) | Return final status, completed / failed / cancelled |
jobs.result(job_id) | Job aggregate results; wait does not replace this method |
jobs.list(**kwargs) | Paginated results; common options limit and cursor, HTTP default limit 25 |
jobs.stop(job_id) | Cancellation-request response |
Job wait has the same numeric constraints as Task wait; timeout does not automatically cancel.
Runners
client.runners.list(limit=25, cursor=None) calls GET /v1/runners and returns the complete page (items, next_cursor). Each item preserves full commit, URI and package/index SHA-256 plus safe metadata. Pass the returned cursor for subsequent pages; discovery does not execute or download a Runner.
Profiles
client.profiles uses the same version projection as client.assets: list(job_type=..., name=..., limit=..., cursor=...), get(REF), create(spec, version=...), update(REF, version=NEW, spec=... | patch=...), delete(REF, dry_run=True), set_visibility(REF, visibility=..., expected_acl_revision=...), fork(REF, name=..., version=...), set_default(REF, expected_version=...) and export(REF).
A REF is an exact ID or name@version; read does not silently choose a default. Complete spec and patch are mutually exclusive. Omitted patch values and write-only Secret placeholders are preserved. Export returns redacted UTF-8 bytes. Public creation and visibility withdrawal require a platform administrator at the owner service. Default selection is a separate CAS operation and never follows update automatically. See Profiles.
Errors and result interpretation
SDK wait returns failed terminal states as data and raises TimeoutError for a timeout. API errors use sanitized codes. Successful status, commands and verifier reward=1 are separate conclusions. Training uses Train Jobs only; see the quickstart.
Train Jobs
client.training_jobs is the Train Job management interface. Prepare a supported request with the SFT quickstart, submit it once and keep the returned Job ID. Discover recipes through GET /v1/training-models in the HTTP API; use the returned schema to choose inputs.
| Method | Behavior |
|---|---|
training_jobs.list(*, status=None, cursor=None, limit=25) | One page of Train Jobs |
training_jobs.logs(job_id, *, source="all", cursor=None, tail=None, limit=200) | Retained training log page, cursor and capture completeness; select System or Runtime with source |
training_jobs.status(job_id) | Public training record |
training_jobs.result(job_id) | Recorded result |
training_jobs.stop(job_id) | Request cancellation; check the later state |
training_jobs.wait(job_id, *, timeout=600) | Wait for completed, failed or cancelled (historical upper-case states are also accepted); failure remains returned data |
training_jobs.submit(request) | Submit a JSON object to the Train Job contract; requires configured training execution |
training_jobs.checkpoints(*, job_id=None, trial_id=None, cursor=None, limit=25) | Registered checkpoint page |
training_jobs.delete_checkpoint(checkpoint_id) | Delete by checkpoint resource ID; returns a cleanup Operation |
Training uses Train Jobs only; see removal and migration.
Checkpoint files
| Method | Behavior |
|---|---|
checkpoints.list(**filters) | Uses the Train Job checkpoint filters above |
checkpoints.download(path, directory, *, job_id=None, trial_id=None) | Resolve one registered checkpoint and download files, verifying declared sizes and SHA-256 hashes |
path can identify a returned full checkpoint URI or checkpoint name; a full URI plus session filter avoids ambiguity. Missing/ambiguous entries, unavailable file metadata, unsafe paths and failed integrity checks are errors. This method performs real downloads; it is distinct from a metadata list. See Checkpoints.
Inference Jobs
Use client.jobs.submit_spec(request) with an envloop.job/v2 request that pins a Bash Runner and Recipe. The Recipe owns the model and parameters; pass a Checkpoint through its declared inputs.checkpoint, and select GPU type/count independently in resources. Call the returned inference.model without an adapter suffix. See Inference for the full request and lifecycle.
Clients do not select a provider/executor or supply resolved_runner or runtime. Reuse request_id only for identical intent.
Chat
Install envloop-cli[chat] and use the same Client.remote() connection, permissions and project. jobs.chat reads the Job model automatically and requires a READY Inference Job. It returns a complete response by default, or a closable iterator of chunk dictionaries with stream=True.
from contextlib import closing
from envloop import Client
with Client.remote() as client:
messages = [{"role": "user", "content": "Hello"}]
response = client.jobs.chat("JOB_ID", messages=messages)
print(response["choices"][0]["message"]["content"])
with closing(client.jobs.chat("JOB_ID", messages=messages, stream=True)) as chunks:
for chunk in chunks:
for choice in chunk["choices"]:
print(choice["delta"].get("content") or "", end="", flush=True)
Pass request fields such as temperature, max_tokens and chat_template_kwargs as keyword arguments. timeout_seconds=120 is the default connection/read timeout. Requests are not automatically retried; stream errors and missing completion markers raise errors. Close the iterator on early exit; this closes the HTTP request and does not stop the Job.
Historical adapters and endpoints
Existing adapters/endpoints remain readable and cleanable. New adapter registration, native endpoint creation and historical wake/resume return INFERENCE_RECIPE_REQUIRED; use a current Recipe for new inference.
| Method | Behavior |
|---|---|
adapters.list() / adapters.get(adapter_id) | Inspect historical adapters |
adapters.delete(adapter_id) | Delete an unreferenced historical adapter through a cleanup Operation |
endpoints.list() / endpoints.get(endpoint_id) | Inspect endpoints |
endpoints.pause(endpoint_id) / endpoints.delete(endpoint_id) | Stop or clean up a historical endpoint |
endpoints.wait(endpoint_id, *, timeout=1800, poll_interval=5) | Wait for readiness without waking; a timeout does not delete resources |
endpoints.generate(model, prompt, *, job_id, **options) | Call the Job’s fixed model; protocol support depends on its Recipe |
Use the Job lifecycle to stop a new service and confirm inference.cleanup_confirmed before claiming release. Historical records and content identities remain unchanged.
Cleanup Operations and temporary scopes
| Method | Behavior |
|---|---|
operations.get(operation_id) | Read persisted cleanup state |
operations.wait(operation_id, *, timeout=600, poll_interval=2) | Return clean SUCCEEDED, otherwise raise on failed/blocked/cancelled terminal state or timeout |
operations.retry(operation_id) | Explicitly retry a failed cleanup after inspecting its cause |
operations.cleanup(resources, *, request_id=None) | Clean an explicit list of {kind, id} project resources |
client.temporary_resources(*, ttl_seconds=1800, request_id=None, cleanup_timeout=600, poll_interval=2) | Create a context-managed, server-registered temporary scope |
CleanupError is available from envloop.resources; its operation attribute preserves the failed receipt. wait also rejects a SUCCEEDED receipt containing errors. Cleanup must be confirmed from the Operation, not inferred from a request's HTTP success.
Read the receipt by field. compute_released lists resources whose GPU compute stopped. resources_deleted lists resources whose cleanup step finished. A training Job listed there keeps its status, logs and usage history; only its compute and cleanup are complete. artifacts_deleted lists checkpoint files that were removed. retained lists only resources you kept with run.retain(...) or the scope retain route; they stay usable and are not cleaned. A resource never appears in both resources_deleted and retained. Receipts written before this change listed a cleaned training Job in both; it is now shown only in resources_deleted.
Enter the scope before using it. Inside with client.temporary_resources(...) as run, use run.adapters and run.endpoints to enroll new resources. run.retain(resources) removes selected resources from temporary cleanup. run.get() reads scope state; run.cleanup() requests cleanup and waits. run.scope_id and run.cleanup_result expose recovery information.
TTL must be an integer from 60 to 86400 seconds. The scope can be entered once. On context exit, cleanup runs even after an exception, and an incomplete cleanup remains observable. The server TTL also releases resources when the client disconnects. Existing IDs are not automatically enrolled. See the complete workflow.
Dataset, project and usage inspection
| Interface | Methods and scope |
|---|---|
client.datasets | list(limit=25, cursor=None), get(name), revisions(name, limit=25, cursor=None), revision(name, revision), tasks(name, revision, limit=25, cursor=None); optional pagination arguments are keyword-only |
client.dashboard.get() | Current project and first pages of Agent and Train Jobs; follow list cursors for more |
client.project | Project settings/limits/membership wrappers remain subject to the server's human-session and role gates |
client.project.model_access() / grant_model_access(runner, protocols, *, revision=None) / revoke_model_access(grant_id) | Read, add or revoke model access grants; writes need the project Admin role and send If-Match |
client.runners.create(directory, *, revision="main", name=None, executables=None, dry_run=False) | Publish a local Runner package directory as an immutable Revision; returns {asset, runner} |
Runner revision accepts a full commit or a local branch/tag. A branch/tag resolves once to its full commit and requires the package directory to match that commit. Catalog list and detail responses expose revision, author (Git author name) and message (commit subject). Unknown historical metadata is null; the author is separate from the account publishing the Runner.
API Key authorization is not a browser session. Do not use project management wrappers to bypass human-only settings, member or limits gates; use the signed-in console where required. Preserve response units, source and completeness.
Trial artifact downloads
client.trials also supports these methods:
| Method | Behavior |
|---|---|
trials.artifacts(trial_id, **kwargs) | One artifact page, with cursor / limit |
trials.download_artifact(trial_id, artifact, dest) | Download an artifact ID or listing item under the destination, checking declared size/hash |
trials.download_artifacts(trial_id, dest) | Download all uploaded artifacts by following pagination |
A result's outputs metadata and collection state are distinct from locally verified files. Execution logs are available in the console's Logs view; do not assume trials.result() contains stdout/stderr. See Python SDK guide.
Assets
client.assets is read-only: list(type=..., name=..., query=..., limit=..., cursor=...) and get(REF, type=...) aggregate Dataset, Checkpoint, Recipe and Profile versions. The same record is returned by the corresponding typed SDK. Each list row is an exact version, and get returns {asset, operation}. Files and domain evidence live under asset.details.
Use client.datasets, client.checkpoints, client.recipes and client.profiles for their typed create/update/delete, files and downloads. Content publication returns its operation by default; pass wait=True to wait. Resume the established operation through the same typed service's get_upload, complete_upload and abort_upload; do not create a replacement operation after a timeout. Preserve opaque asset_id values, including historical data_… values.
Runner is a system execution capability managed by client.runners; Trial Artifact belongs to client.artifacts and the existing client.trials download helpers. Neither appears in client.assets. Read resource commands for exact refs, permissions, immutable versions, ACL scope and dependency-protected retirement.
Loop metadata updates
Use el loop update LOOP_ID --spec FILE, SDK client.loops.update(loop_id, spec), or PATCH /v1/rsi/loops/{loop_id} with an envloop.loop/v1 spec. Supplied name and description fields replace current values; omitted fields stay unchanged. See Loop metadata for the format, permissions and examples.