Skip to main content

Python SDK

envloop.Client is a synchronous client. API mode uses the Python module provided by the public envloop-cli package; no platform checkout or Git repository binding is needed. See Quickstart for installation.

Connect to the platform​

from envloop import Client

with Client.remote() as client:
print(client.jobs.list(limit=10))

The SDK reads explicit arguments, then ENVLOOP_BASE_URL, ENVLOOP_API_KEY and optional ENVLOOP_WORKSPACE_ID / ENVLOOP_PROJECT_ID, then shared user files saved by el auth config. It does not automatically read .env.local. You can also pass the address and workspace explicitly while keeping the Key in the environment:

with Client.remote("https://api.envloop.ai", timeout=30) as client:
print(client.jobs.list(limit=10))

Here, timeout is the HTTP request deadline, not the task execution deadline or total wait deadline. Use Client.remote() for the current platform connection; bare Client() does not automatically connect.

CI / service processes can disable user file loading; use this mode on Windows until private ACL support is verified:

import os

with Client.remote(
"https://api.envloop.ai",
api_key=os.environ["ENVLOOP_API_KEY"],
config=False,
) as client:
print(client.jobs.list(limit=10))

config=False retains explicit and system environment values without accessing ENVLOOP_HOME or user files. See Configuration for precedence and URL binding.

Connect to a local platform API​

After an administrator starts the local platform, connect using the startup UI origin plus /api/ and an API Key issued by that same local platform. The default address is http://127.0.0.1:5173/api/. The client does not create execution directories or initialize repositories.

import os
from envloop import Client

with Client.remote(
"http://127.0.0.1:5173/api/",
api_key=os.environ["ENVLOOP_API_KEY"],
config=False,
) as client:
print(client.jobs.list(limit=10))

Use this API connection for local-platform work too. See Configuration for connection and compatibility details.

Wait and inspect failures​

from envloop import Client

with Client.remote() as client:
job = client.jobs.submit(source="./my-task")
try:
final = client.jobs.wait(job["job_id"], timeout=60)
except TimeoutError:
print(client.jobs.status(job["job_id"]))
else:
print(final["status"])
for trial in client.trials.list(job_id=job["job_id"])["items"]:
print(trial["trial_id"], client.trials.result(trial["trial_id"]))

Prepare ./my-task using Task format. jobs.wait returns completed, failed or cancelled; inspect that status, then read the dispatched Trials. A timeout leaves the Job running. Directory reads, input validation, HTTP, and permission errors may raise exceptions; do not log raw requests, keys, or arbitrary server error bodies.

Choose the right client surface​

GoalSDK entrypointGuide
Submit an Agent task or datasetclient.jobsJobs
Inspect a Trial and download artifactsclient.trialsTrials
Discover data and runnersclient.datasets, client.runnersDatasets
Manage reusable execution settingsclient.profilesProfiles
Read training recordsclient.training_jobsTraining monitoring
Submit Train Jobclient.training_jobs.submit(request)SFT quickstart
List or verify checkpoint filesclient.checkpointsCheckpoints
Call an Inference Jobclient.jobs, client.endpoints.generateInference
Bound experiment resource lifetimeclient.temporary_resources()Train and deploy

Install the public envloop-cli package as described in Installation. The resource-management client returns dictionaries. Train Jobs use the same resource response style.

Paginate and keep the scope explicit​

Paginated list methods return one page. Follow the returned cursor until it is absent:

from envloop import Client

with Client.remote() as client:
cursor = None
while True:
page = client.jobs.list(limit=25, cursor=cursor)
for item in page["items"]:
print(item["job_id"], item["status"])
cursor = page.get("next_cursor")
if cursor is None:
break

Use a project-bound Key or explicitly select the authorized workspace and project. Do not change scope mid-run while continuing to reuse resource IDs from the old project. Keep Keys out of source, URLs and run records.

Download results as actual files​

trials.result() returns public result metadata such as status, reward, structured result, outputs and collection information. It does not expose a universal stdout / stderr field. Use the console's Logs view for execution logs, and artifact downloads for files:

with Client.remote() as client:
trial_id = "YOUR_TRIAL_ID"
result = client.trials.result(trial_id)
print(result["status"], result.get("reward"))
files = client.trials.download_artifacts(trial_id, "./trial-artifacts")
print(files)

The downloader verifies size and hash when supplied in artifact metadata. Read the download receipt and destination directory for the verified files. See Trials for scoring versus execution status.

Training and inference use the same connection​

Training uses Train Jobs: discover recipes with GET /v1/training-models and submit with client.training_jobs.submit(request). For an older interactive script, follow migration.

For an existing Inference Job, use its exact returned model with the same client:

with Client.remote() as client:
job_id = "YOUR_INFERENCE_JOB_ID"
job = client.jobs.status(job_id)
model = job["inference"]["model"]
print(job["status"], model)
response = client.endpoints.generate(
model, "Say hello.", job_id=job_id, max_tokens=64)
print(response["choices"][0]["message"]["content"])

Replace the placeholder with the intended Inference Job and use its returned model unchanged. Compare separate base and fine-tuned Jobs through the inference guide.

Calling a scaled-to-zero endpoint can start a replica and initially return a cold-start response. Inspect status and follow the documented retry interval. Creating a client or reading endpoint details does not itself allocate a GPU.

Handle cleanup as an operation​

For deletion, keep the returned Operation ID and wait for completion:

with Client.remote() as client:
operation = client.endpoints.delete("YOUR_ENDPOINT_ID")
final = client.operations.wait(operation["operation_id"], timeout=600)
print(final["status"])

This example removes the specified endpoint; use only an ID you intend to delete. Its adapter and checkpoint remain separate resources. A wait timeout does not roll back the request. CleanupError preserves the failed Operation in its operation attribute; inspect the failure before explicitly retrying.

Temporary scopes add a server TTL and context-exit cleanup for resources created through that scope. See Train and deploy for safe retention of successful artifacts. client.close() closes the client only; finish training and delete cloud resources separately.

See Python SDK reference for signatures and response boundaries.