|
6 | 6 |
|
7 | 7 | The Qoder Cloud Agents Python SDK provides access to the Qoder Cloud Agents API from Python 3.10+. It ships synchronous and natively asynchronous clients, typed request parameters and response models, automatic pagination, SSE streaming, and file transfer. |
8 | 8 |
|
9 | | -The API is exposed in two modes, and each has its own client, resources, and types. Forward is multi-tenant: sessions are created from an Identity and a Template, and it adds Schedule, Batch, and Channel. Managed is single-tenant: sessions are created from an Agent and an Environment, and it adds Deployment, Dream, and the Work API for self-hosted environments. |
| 9 | +The API is exposed in two modes, and each has its own client, resources, and types. Forward is multi-tenant: sessions are created from an Identity and a Template, and it adds Schedule, Batch, Channel, and Usage. Managed is single-tenant: sessions are created from an Agent and an Environment, and it adds Deployment, Dream, and the Work API for self-hosted environments. |
10 | 10 |
|
11 | 11 | ## Installation |
12 | 12 |
|
@@ -104,6 +104,41 @@ asyncio.run(main()) |
104 | 104 |
|
105 | 105 | Every method shown in this document has an async counterpart with the same name and signature. Async streams are opened with `async with await client.sessions.events.stream(...)`. |
106 | 106 |
|
| 107 | +## Usage and cancellation |
| 108 | + |
| 109 | +Forward Usage requires PAT or Admin SAT. |
| 110 | + |
| 111 | +```python |
| 112 | +with Forward() as client: |
| 113 | + for row in client.usage.list_identities( |
| 114 | + start_at="2026-09-14T09:00:00", end_at="2026-09-14T12:00:00", |
| 115 | + identity_ids=["idn_one", "idn_two"], |
| 116 | + ): |
| 117 | + print(row.identity_id, row.active_seconds, row.credits) |
| 118 | + |
| 119 | +with Managed() as client: |
| 120 | + acknowledgement = client.sessions.cancel("sess_one") |
| 121 | + for run in client.deployments.runs.list("dep_one", limit=20): |
| 122 | + print(run.id) |
| 123 | + run = client.deployments.runs.retrieve("drun_one", deployment_id="dep_one") |
| 124 | +``` |
| 125 | + |
| 126 | +`usage.list_templates` accepts the same filters. Bounds are whole hours in |
| 127 | +Asia/Shanghai for CN and Global, with an inclusive start, exclusive end, and a |
| 128 | +maximum 744-hour span. Multi-ID filters accept lists or comma-separated strings. |
| 129 | +`active_seconds` preserves fractions. Legacy timestamp parameters and |
| 130 | +`duration_seconds` are not exposed. |
| 131 | + |
| 132 | +`client.vaults.credentials.update("cred_one", vault_id="vault_one", auth={...})` |
| 133 | +rotates write-only secrets; only auth and metadata are patched, and omitted fields |
| 134 | +are preserved. `metadata=None` clears metadata; `metadata={"key": None}` deletes a |
| 135 | +key. This operation never retries automatically, even if client retries are enabled. |
| 136 | + |
| 137 | +Session cancellation returns the lightweight `canceling` acknowledgement for |
| 138 | +active (HTTP 202) and idle (HTTP 200) sessions. The global `deployment_runs` resource |
| 139 | +remains available. All new methods also exist on `AsyncForward` / `AsyncManaged`; |
| 140 | +await requests or iterate pages with `async for`. |
| 141 | + |
107 | 142 | ## Sessions |
108 | 143 |
|
109 | 144 | A session is the unit of agent execution. Forward materializes one from an Identity and a Template: |
|
0 commit comments