Queued async code runs are available through the Python SDK and CLI when the machine’s runtime host is reachable by the control plane.

Create A Queued Run

ctx = machine.code_interpreter.create_code_context(cwd="/workspace")
run = machine.code_interpreter.create_run(
    "import time\nfor i in range(5): time.sleep(1)\nprint('done')",
    context=ctx,
    timeout=60,
)
print(run.id, run.status)

Wait or cancel

current = machine.code_interpreter.get_run(run.id)
print(current.status)

finished = machine.code_interpreter.wait_for_run(run.id, timeout_secs=120)
print(finished.status)

# machine.code_interpreter.cancel_run(run.id)

List runs

page = machine.code_interpreter.list_runs(status="succeeded", limit=20)
for item in page["items"]:
    print(item.id, item.status)
nullspace machine code run-job list mch_123 --status succeeded --limit 20
curl "${NULLSPACE_API_URL}/v1/machines/mch_123/code/runs?status=succeeded&limit=20" \
  -H "Authorization: Bearer ${NULLSPACE_API_KEY}"

Artifacts

artifacts = machine.code_interpreter.list_artifacts(limit=20)
for item in artifacts["items"]:
    print(item["id"], item.get("kind"))

artifact = machine.code_interpreter.get_artifact("artifact_...")
content = machine.code_interpreter.download_artifact(artifact.id)
preview = machine.code_interpreter.preview_artifact(artifact.id)
machine.code_interpreter.delete_artifact(artifact.id)
nullspace machine code artifact list mch_123 --limit 20
nullspace machine code artifact get mch_123 <artifact-id>
nullspace machine code artifact download mch_123 <artifact-id> -o ./artifact.bin
nullspace machine code artifact preview mch_123 <artifact-id> -o ./preview.bin
nullspace machine code artifact delete mch_123 <artifact-id>
curl "${NULLSPACE_API_URL}/v1/machines/mch_123/code/artifacts?limit=20" \
  -H "Authorization: Bearer ${NULLSPACE_API_KEY}"
curl "${NULLSPACE_API_URL}/v1/machines/mch_123/code/artifacts/<artifact-id>" \
  -H "Authorization: Bearer ${NULLSPACE_API_KEY}"
curl "${NULLSPACE_API_URL}/v1/machines/mch_123/code/artifacts/<artifact-id>/download" \
  -H "Authorization: Bearer ${NULLSPACE_API_KEY}" -o ./artifact.bin
curl "${NULLSPACE_API_URL}/v1/machines/mch_123/code/artifacts/<artifact-id>/preview" \
  -H "Authorization: Bearer ${NULLSPACE_API_KEY}" -o ./preview.bin
curl -X DELETE "${NULLSPACE_API_URL}/v1/machines/mch_123/code/artifacts/<artifact-id>" \
  -H "Authorization: Bearer ${NULLSPACE_API_KEY}"
list_artifacts() returns paginated raw artifact dictionaries. Use get_artifact() for a typed CodeArtifact, and use download_artifact() or preview_artifact() for bytes.