Skip to content
Socaity Docs

REST API

Low-level HTTP API reference. For most use cases, the Python or JS SDK is recommended.

Base URL & Authentication

All requests must include a Authorization: Bearer <key> header.

terminal
curl -X POST https://api.socaity.ai/v1/{model}/generate \
  -H "Authorization: Bearer $SOCAITY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"prompt": "hello world"}'

Endpoint Types

SYNC
Synchronous

Returns the result directly in the response body. Best for fast operations (< 5s). Blocks until complete.

ASYNC
Asynchronous

Returns a job_id immediately. The client polls GET /v1/jobs/{id} until FINISHED. Best for GPU-heavy tasks.

Job Lifecycle

Async endpoints return a job_id immediately. Poll the job status endpoint until status is FINISHED.

PENDING — submitted, waiting for a worker
QUEUED — in the provider queue
PROCESSING — running on a worker
STREAMING — producing output incrementally over SSE
FINISHED — complete, result available
FAILED — check error field
TIMEOUT — server-side timeout exceeded
CANCELLED — cancelled by client
UNKNOWN — fallback when status did not map
terminal
# Submit async job
POST /v1/{model}/generate
→ 202  { "job_id": "job_abc123", "status": "PENDING" }

# Poll for result
GET /v1/jobs/job_abc123
→ 200  { "status": "PROCESSING", "progress": 0.45 }
→ 200  { "status": "FINISHED", "result": "..." }

# Cancel a job
DELETE /v1/jobs/job_abc123
→ 200  { "status": "CANCELLED" }

Job Response Schema

FieldTypeDescription
job_idstringUnique identifier for the remote job.
statusAPIJobStatusPENDING | QUEUED | PROCESSING | STREAMING | FINISHED | FAILED | TIMEOUT | CANCELLED | UNKNOWN
progressfloat | nullCompletion 0.0→1.0. Null if not reported.
resultany | nullInference output when status is FINISHED.
errorstring | nullError message when status is FAILED.
refresh_job_urlstring | nullPoll URL for the latest job status.
cancel_job_urlstring | nullURL to request cancellation.

Error Codes

HTTP StatusMeaningAction
401
UnauthorizedCheck API key and Authorization header.
403
ForbiddenKey lacks required permission.
422
Validation ErrorCheck request body against the model schema.
429
Rate LimitedBack off and retry with exponential delay.
500
Server ErrorRetry once. If persists, contact support.
503
Service UnavailableCold start or capacity issue — retry in 30s.