Skip to content

How do I distinguish insufficient credits, a key cap and max_credits errors?

Inspect the status and safe message: 402 indicates insufficient shared account credits, 403 can indicate model permission or a monthly key cap, and 409 can indicate an approved max_credits ceiling or idempotency conflict. These are different checks. Adding funds, changing permissions and raising a request ceiling are not interchangeable remedies.

UNDERSTAND API CREDITS AND COSTSAISwapLab team · Editorial methodPublished 2 min read
Open API documentationExplore 67 Image SkillsPrivate keys · Explicit credit approval
Article workflow: Read the exact error; Compare the relevant values; Correct only the approved condition.
Workflow diagram: Read the exact error → Compare the relevant values → Correct only the approved condition. Read the article for evidence and limits.

One request must pass several independent gates

A valid key can have enough allowance but no funded balance, or a funded account can have a tightly scoped key. The per-request ceiling protects the specific approval, while a monthly cap limits broader use. A quote can also change if the actual source, duration or size changed since the earlier approval.

What to do next

  1. 01

    Read the exact error

    Record code, route and message without credentials. For 409, distinguish a changed-payload idempotency conflict from a quote exceeding max_credits before taking any action.

  2. 02

    Compare the relevant values

    Use /usage for balance and key allowance, /models for scope-related context, and a fresh /quotes result for the actual intended payload. Do not infer every rejection from one displayed balance number.

  3. 03

    Correct only the approved condition

    If the task changed, obtain a deliberate new approval. If balance is insufficient while purchases remain closed, explain that state rather than showing an unofficial payment path.

A concrete example

Illustrative diagnosis: an account has ample credits, but the key's remaining monthly allowance is smaller than the quote. Increasing max_credits would not resolve the cap and could weaken the user's per-request approval unnecessarily.

Identify the gate before changing anything

ResponseLikely gateCheck
401AuthenticationFull valid key and correct Bearer header
402Shared wallet balanceCurrent account credits
403Scope or monthly key capExact message and key settings
409Payload conflict or approval ceilingSaved body and current quote
429Rate, concurrency or daily controlMessage, Retry-After and active work
503Readiness or private deliveryCatalog reason and existing job

Before you call it ready

  • The exact error cause is identified.
  • Permission, wallet and request ceilings remain separate.
  • No limit is raised automatically.

When to stop or choose another method

If the application cannot determine which gate failed, preserve the task and investigate. Do not cycle through larger limits and repeated submissions until one happens to pass.

Sources

One task. A recoverable workflow.

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

Open API documentation