SDK configuration and async usage
Configure SDK timeouts and retries, use the async Python client, handle error responses, page through results, and poll self-hosted compute work.
Use the authenticated client setup from Quickstart. The examples below read an existing run: set SIKARU_PROJECT_ID and SIKARU_RUN_ID to its identifiers.
Make async requests in Python
Use AsyncSikaruApi in an async application. Supply an async HTTP client when you need explicit connection cleanup or transport configuration.
The synchronous SikaruApi accepts the same timeout and retry options, with httpx.Client for its transport. Python timeouts are in seconds. Per-request timeout and max_retries override client defaults.
A request timeout limits one HTTP call. It does not set an overall observation deadline, and it does not cancel a hosted run.
Handle errors and raw responses
Here client is a synchronous client and run_id is an existing run ID. Raw responses also expose headers. Handle network and timeout errors from the HTTP transport separately. Log only the response fields you need for diagnosis: bodies and headers can contain customer data.
Error responses have the body {"detail": ..., "code": ...}. 422 validation errors list invalid fields in detail instead.
codeis specific where one applies, such asidempotency_conflict. Otherwise it is a status default such asnot_found.- In Python, read
error.body.codeanderror.headers["retry-after"]. - A
429or503refusal with acodeincludesRetry-Afterin seconds. - A failed run is not an error response. Read
error.codeanderror.recoverableon the run itself. See Runs and tool requests.
Only GET and HEAD requests retry automatically. Setting retry options does not enable automatic mutation replay. Keep idempotency keys stable for identical submissions when the endpoint supports them.
Set TypeScript request options
Keep the key in server-side code. Use your language client’s reference for error types and request-option names. They are not identical across languages.
Page through results and events
Pagination is endpoint-specific:
Read each response envelope and pass its continuation cursor to the same endpoint, keeping the same filters. Do not assume these clients automatically read every page.
For run events, persist the cursor and pass it as after on the next JSON page. Deduplicate by event identity if a page arrives again. runs.events returns a JSON page. For the dedicated SSE iterator, use runs.stream_events in Python or runs.streamEvents in TypeScript. See Runs and tool requests.
Poll self-hosted compute with JSON
Each role uses ordinary generated HTTP methods, without requiring SSE support:
An executor can inspect its scoped work page:
The native executor owns readiness, monotonic lease deadlines, process supervision, fsynced intents, and immutable receipt submission. Use sikaru compute serve in your sandbox unless you implement that entire executor contract. Never pass a controller credential to the sandbox.
See Local compute for bootstrap fields, approvals, file boundaries, and recovery.
