Genace

Video generation API 402 errors: resolve insufficient credits before retrying

Video generation API 402 errors mean your request could not pass the credit check. In the current Genace implementation, the response uses error.type insufficient_credits and error.code NOT_ENOUGH_CREDITS. This condition requires a balance or request-budget decision. Waiting a few seconds and replaying the same request does not make an unchanged balance sufficient.

The submission service validates the model and parameters, calculates the job’s credits, and deducts them before inserting the job and submitting upstream. For the explicit insufficient-credit path, no job row is inserted. Keep that case distinct from an ambiguous network failure after sending a POST.

Present an actionable outcome

ObservationApplication response
Explicit NOT_ENOUGH_CREDITSStop automatic submission retries
User adds creditsRecheck the approved request budget before submitting
User approves shorter or lower-resolution workCreate a new explicit request specification
Existing job is still activeKeep collecting it; do not assume its credits are free
Failed job reports zero actual creditsReconcile the terminal snapshot with credit history

The current error message includes the observed balance and the credits required by the request. Treat that text as useful human context, not a durable numeric API. Route logic on the stable code rather than extracting numbers from an English sentence.

Estimate the approved request

This example mirrors the current Seedance adapter formula for planning. It is not a price-lock endpoint and does not submit work. Validate all parameter limits before applying the estimate.

function estimateSeedanceCredits(durationSec, resolution) {
  if (!Number.isInteger(durationSec) || durationSec < 3 || durationSec > 15) {
    throw new Error('Choose an integer duration from 3 through 15');
  }
  if (!['720p', '1080p'].includes(resolution)) {
    throw new Error('Unsupported resolution');
  }
  return Math.ceil(durationSec * 5 * (resolution === '720p' ? 0.5 : 1));
}
console.log(estimateSeedanceCredits(5, '720p'));

Five seconds at 720p evaluates to thirteen credits under this formula; five seconds at 1080p evaluates to twenty-five. Recheck the live pricing and repository configuration before using either figure in a commercial budget. Other models have different formulas and supported duration choices.

Account for overlapping jobs

Two individually affordable requests can exceed the balance when they overlap. Your application should reserve its own approved budget before dispatch and keep accepted jobs attached to that reservation until reconciliation. Avoid silently reducing video duration after a 402, because that changes the product the user requested.

Failure and cancellation handling in the job service invokes the refund path and records zero actual credits. Do not promise an immediate balance update based only on a client timeout or a locally hidden progress dialog. Those events do not establish a remote terminal state.

Verification checklist

Mock a 402 response and confirm that it produces a budget action rather than exponential retries. Test a rejected request, a user-approved parameter change, and an accepted job awaiting reconciliation. Verify that the UI distinguishes insufficient balance from a model failure.

Continue with cost budgets, job states, and cancel requests.

Continue with costs and billing

Models covered on this page

Where these facts come from

  • codebase: src/ai/api/credits.ts
  • codebase: src/ai/jobs/service.ts
  • codebase: src/ai/providers/seedance.ts
  • Editorial keyword hypothesis; search volume not measured