Credits API

Endpoints for checking credit balance and validating credit availability.

Get Credit Balance

Retrieve the current credit balance for the authenticated user.

Request
Response
curl -H "X-API-Key: sk-your-key-here" \
     https://your-api-domain.com/image-forge-api/v1/credits/balance

Method: GETPath: /v1/credits/balanceAuthentication: Required

Response Fields

FieldTypeDescription
balancenumberCurrent available credit balance
planNamestringName of the user's subscription plan
userIdstringThe authenticated user's ID

Check Credit Availability

Check whether the user has enough credits for a specific operation. Optionally deduct credits in the same call.

Request
Success Response
Insufficient Response (402)
curl -X POST \
     -H "X-API-Key: sk-your-key-here" \
     -H "Content-Type: application/json" \
     -d '{
       "action": "export",
       "imageCount": 5,
       "deduct": true
     }' \
     https://your-api-domain.com/image-forge-api/v1/credits/check

Method: POSTPath: /v1/credits/checkAuthentication: Required

Request Body

FieldTypeRequiredDescription
actionstringYesOperation type: analyze, export, or sample
imageCountnumberYesNumber of images to process
deductbooleanNoIf true, deduct credits on success. Default: false

Credit Costs by Action

ActionCost per Image
analyze1 credit
export1 credit
sample0 credits (free)

Response Fields

FieldTypeDescription
sufficientbooleanWhether the user has enough credits
balancenumberCurrent balance before deduction
costnumberTotal credits required
remainingnumberBalance after deduction (only if deduct: true)

Error Codes

StatusMeaning
200Sufficient credits (and deducted if requested)
401Invalid or missing API key
402Insufficient credits