Skip to content

How should I queue several generation requests without overwhelming the API?

Queue approved tasks in your own backend and release only a small number at a time. AISwapLab currently shares active-work limits between studio and API: up to two active jobs per account and four globally. Unknown jobs can still count as active. A large balance or multiple API keys does not guarantee more simultaneous generations.

RECOVER AND DELIVER API JOBSAISwapLab team · Editorial methodUpdated 2 min read
Open API documentationExplore 67 Image SkillsPrivate keys · Explicit credit approval
Article workflow: Persist the waiting tasks; Dispatch with backpressure; Reconcile active work.
Workflow diagram: Persist the waiting tasks → Dispatch with backpressure → Reconcile active work. Read the article for evidence and limits.

Submission order and completion order differ

A queue should preserve the user's intended task and spending approval while waiting. It must not mark waiting work as already accepted by AISwapLab. Each item needs its own stable idempotency identifier, and an uncertain accepted item must remain traceable. A local claim or equivalent synchronization can prevent two application workers from dispatching the same item at once; that is your integration design, not a new AISwapLab queue endpoint.

What to do next

  1. 01

    Persist the waiting tasks

    Store payload, approval ceiling, account user and identifier before dispatch. Give waiting items a local queue state distinct from a returned provider-processing state.

  2. 02

    Dispatch with backpressure

    Start with one active worker per account and observe actual limits. Handle a concurrency 429 by leaving the item queued for a bounded later retry of the same intended task.

  3. 03

    Reconcile active work

    Poll accepted jobs centrally and release local slots when their states warrant it. Keep unknown work visible for reconciliation rather than counting only jobs with media previews.

A concrete example

Illustrative queue: ten approved image concepts wait in the application's database. The dispatcher submits one at a time, records each returned job, and pauses when the shared account is also processing a studio video.

Queue dispatch boundary

Local stateRecord or controlRemote implication
Waiting for capacityApproved immutable task plus a local dispatch claimNot yet accepted by AISwapLab
Creation sent or uncertainOriginal identifier and send-attempt recordMay already occupy shared active work
Accepted existing jobOne central reconciler and durable job IDFollow that job; do not release a slot merely because no preview exists

Before you call it ready

  • Waiting and accepted tasks are distinct.
  • Each item has a stable request identifier.
  • Studio activity is considered in shared capacity.

When to stop or choose another method

If throughput requirements exceed these current limits, do not promise instant batch output. Communicate queue behavior and obtain the appropriate supported capacity before selling the workflow.

Sources

One task. A recoverable workflow.

Check the contract, approve the quote and retain the job.

Open API documentation