Skip to content

Threads model

CaptchaAI phase-1 bills active threads, not per-solve. A "thread" is one in-flight task: from createTask accepted → terminal state (ready or failed). Your thread limit sets an upper bound on how many can be in flight at once. There is no plan/credit/balance model — billing is purely the concurrent thread count.

Admission

When you call createTask:

  1. Atomic Lua script checks ZCARD client:{id}:active_tasks vs your limit. Expired leases (default 300 s) are purged first.
  2. If under the limit → task is admitted, lease is set, RabbitMQ message is published. You get taskId.
  3. If at the limit → ERROR_NO_SLOT_AVAILABLE (errorId 1) with the current active/limit for visibility.

Holding and releasing a thread

Your thread is held for the whole solve. The lease is sized to cover the maximum solve time, so nothing has to be refreshed client-side. The thread is released when the task reaches a terminal state (ready or failed). The task hash itself lingers for 5 min so getTaskResult can still return the answer.

Monitoring

  • Dashboard: Overview → Threads in use tile.
  • API: every getBalance response includes activeThreads, threadLimit, mode, and available.
  • Webhook on threshold_reached: planned for phase 2.

CaptchaAI · phase 1 docs