Skip to main content
Most TokenKit operations are asynchronous. When you make a request to an endpoint, the API immediately returns a job ID and processes your request in the background.

Why async?

AI model processing can take anywhere from a few seconds to several minutes depending on:
  • Model complexity and the specific endpoint
  • Request parameters and input size
  • Current system load
  • Processing requirements
Rather than keeping your HTTP connection open, TokenKit follows an async pattern that lets you:
  • Submit multiple jobs in parallel
  • Check status at your own pace
  • Stream real-time progress updates
  • Build responsive UIs that don’t block

Job lifecycle

Every job moves through a series of states:

Checking job status

Polling with GET /jobs/:id

The simplest approach is to poll the job endpoint until it reaches a terminal state:
Response example:
When succeeded:
Polling best practices:
  • Start with 2-3 second intervals
  • Use exponential backoff (double the interval after each check)
  • Max out at 30-60 second intervals for long jobs
  • Stop polling once status is succeeded or failed

Streaming with GET /jobs/:id/stream

For real-time updates, use Server-Sent Events (SSE) streaming:
The stream emits events as the job progresses:
Event types:
Streaming is ideal for:
  • Incremental result delivery for batch operations
  • Real-time log displays