LogoLogoAPI Docs
LogoLogoAPI Docs
Homepage
OverviewAuthentication and idempotencyImage generationsImage editsImage conversionsChart generationsJobs and bounded waitingCreditsErrorsRate limits and concurrencyAPI changelog
API Docs

Credits

Read balance and understand reservations

Read the balance

GET /api/v1/credits requires credits:read and returns only the available integer balance.

curl https://sci-draw.com/api/v1/credits \
  -H 'Authorization: Bearer sd_YOUR_KEY'
{ "success": true, "data": { "balance": 125 } }

Reservation lifecycle

Credits are reserved atomically when a job is first accepted. This prevents two concurrent requests from spending the same balance. A repeated idempotent request reuses the original reservation.

  • Successful jobs settle the exact reserved amount once.
  • Terminal failures release the exact original credit allocations.
  • Retried internal work does not create a new reservation.
  • credits_reserved and credits_consumed are visible on every job.

If the available balance is too low at job creation, the API returns HTTP 402 with INSUFFICIENT_CREDITS; no job or reservation is created.

Jobs and bounded waiting

Poll asynchronous work and read sanitized results

Errors

Stable error envelopes, codes, and HTTP statuses

Table of Contents

Read the balance
Reservation lifecycle