SDKs & clients

Python SDK handbook

Python 3.11+ backend SDK with sync and asyncio clients, OAuth, explicit Task input, resumable SSE and verified downloads. orbitspace-sdk==0.1.0 is published on PyPI; applications import orbitspace. Find the verified version and installation command in the SDK center.

Install a published release

Use a dedicated Python 3.11+ virtual environment:

sh
python -m venv .venv
. .venv/bin/activate
python -m pip install orbitspace-sdk==0.1.0

Source installation

The SDK-only distribution repository is orbitspace-python-sdk. Install from source when developing the SDK itself. Use a dedicated Python 3.11+ virtual environment:

sh
git clone https://github.com/orbitmesh-official/orbitspace-python-sdk.git
cd orbitspace-python-sdk
python -m venv .venv
. .venv/bin/activate
python -m pip install .

Consumers import orbitspace, without a generator, protobuf, Buf or a framework. Consumers do not need PyPI publishing credentials. SDK source tags, PyPI packages and the platform are released independently; API Tokens or OAuth credentials authenticate requests to the platform API.

Create and observe a Task

python
from orbitspace import OrbitSpaceClient, models

with OrbitSpaceClient(token=api_token_from_secret_store, tenant_id=tenant_id) as client:
    task = client.tasks.create(models.CreateTaskRequest(
        workspace_id=workspace_id,
        workspace_agent_binding_id=binding_id,
        input="Summarize the supplied document.",
        idempotency_key=durable_business_job_key,
    ))
    result = client.tasks.wait(task.id, timeout=600)
    # Inspect result.state; intervention states are not completion.

Use async with AsyncOrbitSpaceClient(...) and await resource operations in asyncio services. Streams use async for; sync streams use ordinary iteration. Close streams explicitly when stopping early and close the client. Sync clients own a dedicated I/O loop so deadlines and local cancellation share the async transport. Local cancellation never cancels a remote Task.

Authentication and input replies

Choose exactly one of token or token_provider. For OAuth, use ClientCredentials(token_url, client_id, client_secret=secret, scope=scope) with the issuer's real HTTPS token URL. The provider supports client_secret_basic, client_secret_post, and private_key_jwt through an assertion(audience) signer. Each client owns its dedicated provider; do not share across clients or loops. Token issuance is single-flight, cancelled waiters do not cancel other callers, and missing expiry is not cached long-term. invalidate() prevents stale in-flight issuance from restoring the old cache. Browser OIDC/PKCE login belongs to an established authentication library.

Use tasks.input_requests(task_id) or get_input(input_id) for the latest input. Reply explicitly:

python
client.tasks.reply_input(input_id, models.ReplyTaskInputRequestRequest(
    expected_state_version=latest_input_version,
    idempotency_key=durable_reply_key,
    response={"answer": "confirmed"},
))

Read a fresh Task snapshot before deciding whether to resume. resume, pause, retry and cancel require the exact decimal expected_state_version. Keep versions and cursors as strings. The SDK never automatically answers, approves, resumes or replays writes. Scopes do not replace project authorization. See native Tasks and interactive input.

Events and recovery

Task, Invocation and Goal helpers expose watch, observe and wait, with a required finite timeout. observe reads authoritative snapshots after events, with a minimum interval and no idle polling. wait may return waiting_input, waiting_approval, paused or a terminal state; inspect the result.

Use StreamOptions(after=initial_cursor, committed_cursor=load_committed_cursor) for durable recovery. Commit effects and cursor in the same business transaction. Reconnect uses that committed cursor, not the last observed event. Without a supplier it reuses the initial cursor; tolerate duplicates. Incomplete EOF frames are discarded. UTF-8 and frame byte limits are enforced. History gaps are explicit errors; follow the recovery contract instead of silently switching to live-only events.

Errors and artifact downloads

The default total API deadline is 30 seconds, including body reads. Only transient GET/HEAD failures have bounded retries. ApiError exposes status, code and request_id; default exception messages omit response bodies, credentials and signed URLs. Redirects, cookies and cross-origin API credential forwarding are blocked. Custom transports/providers are trusted application code.

python
result = client.artifacts.download_file(
    artifact_id, destination, max_bytes=32 << 20, timeout=120,
)

Downloads use a separate credential-free client and validate receipt expiry, exact size, byte limits and SHA-256 before atomic replacement. Failures remove private staging files and preserve the previous destination. By default only the API artifact-download prefix is allowed; S3/CDN origins need explicit Destination(origin, path_prefix) entries. See artifacts.

Complete typed API

python
from orbitspace.generated.api.task_service import task_service_get_task
resource = task_service_get_task.sync(client=client.api, id=task_id)
# Async: await task_service_get_task.asyncio(client=client.api, id=task_id)

All 330 admitted operations use the same credential boundary, including Registry and Skill management. orbitspace.models exports typed models; UNSET, explicit null, empty lists, unknown string enums and large decimal strings remain distinct. Use the API reference for parameters and responses. This is an application SDK; Runtime installation, A2A bindings and business-ledger storage use separate contracts.