HTTP API
Authentication, idempotency, errors, and asynchronous operation conventions.
Base URL
The current control-plane origin is:
https://oiy-ai-server.xsun.workers.devFor the examples, set OIY_API_URL to that origin and provide OIY_API_KEY through a local environment or secret store.
Read the public catalog
curl "$OIY_API_URL/api/catalog"The catalog includes regions, built-in templates, GPU profile definitions, currency, and deployment-dependent browser/payment capability flags. No account key is needed for this endpoint.
Authenticate account requests
curl "$OIY_API_URL/api/account" \
-H "Authorization: Bearer $OIY_API_KEY"See authentication. New compute allocation requires a verified account; API keys cannot grant administration.
Idempotency
Lifecycle, storage, and template mutations require Idempotency-Key. Use a unique key of 8–128 characters for each logical operation. A UUID is suitable. Retry the identical operation with the same key after inspecting state. Do not change a body while reusing a key.
Not every POST is a replay-safe mutation: command execution and activity tracking have their own semantics. Never automatically retry an uncertain command.
Asynchronous responses
A successful create/action response acknowledges processing. Poll the service or volume until the desired state is confirmed. A 201 response does not mean your application is ready.
Error format
{
"error": {
"code": "INVALID_INPUT",
"message": "A description of the invalid field"
}
}Use the HTTP status and error.code together. The message explains the failure; do not use its exact wording as an application contract.
| Status | What to check | Next action |
|---|---|---|
400 | Request fields or JSON syntax (INVALID_INPUT, INVALID_JSON) | Correct the request before resubmitting. |
401 | Missing, invalid, expired or revoked credentials | Check the intended origin and credential; sign in again when needed. |
402 | Account credit (INSUFFICIENT_BALANCE) | Check balance and the allocation you are requesting. Repeating the same request cannot add credit. |
403 | Ownership, email verification or credential permissions | Check eligibility. A personal key cannot perform interactive-only operations. |
404 | Resource identity and account | Verify the ID and ownership before creating a replacement. |
409 | Resource revision, state, quota or idempotency conflict | Reread current state and inspect the specific error code; see below. |
413 | Request exceeds 64 KiB (BODY_TOO_LARGE) | Reduce the JSON body; use workload storage for datasets. |
429 | Request rate (RATE_LIMITED) | Control-plane rate limiting returns Retry-After: 60; wait before another attempt. |
5xx | Control-plane/runtime failure or startup delay | Inspect resource state before retrying a mutation. A failed response does not prove that nothing happened. |
These are common recovery paths, not a complete list of business error codes. Service proxy and browser-launch responses are separate from the control-plane API. For example, a waking service can return 503 with Retry-After; see HTTP access.
Resolve a conflict
REVISION_CONFLICT: fetch the latest resource, compare changes, and apply your intended edit to that version. A modified request is a new logical operation and needs a new idempotency key.IDEMPOTENCY_CONFLICT: the key was already used for a different request. Check the original operation and its result. Reuse the key only for the identical original request; do not generate a new key simply to bypass an uncertain result.- Other
409codes: check the named constraint, such as a template quota or lifecycle state. Updating a revision alone does not resolve every conflict.
Service renaming uses expectedName for its concurrency check rather than changing the lifecycle revision. Follow the rename contract.
Recover after a lost response
A timeout, closed connection or unreadable response leaves the outcome uncertain. For a mutation:
- Keep the original method, path, request body and
Idempotency-Keytogether in your application's operation record. Protect any secret values in that record. - Inspect the account or resource with a GET request. For a known service, check its state and events. Do not call its application endpoint just to check sleep; doing so can wake it.
- If retrying is appropriate, resend the identical operation with its original key. A changed body, revision or intent requires a new operation after reviewing the original outcome.
- Poll until the intended lifecycle state is confirmed. An accepted response is not proof that compute is ready or released.
Command execution is not covered by this replay rule. Inspect command output and workload state before deciding whether to run it again.
The source-preview Python SDK reports sanitized transport codes such as HTTP_409 through OiyError.code; it does not expose the response's business code as that field. Its request_id is the mutation's idempotency key, not a server trace ID. See SDK recovery.
Request bodies under /api/* are limited to 64 KiB. Do not use control-plane JSON requests to upload datasets or model weights.
Machine-readable reference
Download the OpenAPI 3.1 description or read its scope and conventions.
Reference
Services · Storage · Templates · Image access · Account and keys · Billing