Credits API
Endpoints for checking credit balance and validating credit availability.
Get Credit Balance
Retrieve the current credit balance for the authenticated user.
Method: GETPath: /v1/credits/balanceAuthentication: Required
Response Fields
| Field | Type | Description |
|---|---|---|
balance | number | Current available credit balance |
planName | string | Name of the user's subscription plan |
userId | string | The 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.
Method: POSTPath: /v1/credits/checkAuthentication: Required
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
action | string | Yes | Operation type: analyze, export, or sample |
imageCount | number | Yes | Number of images to process |
deduct | boolean | No | If true, deduct credits on success. Default: false |
Credit Costs by Action
| Action | Cost per Image |
|---|---|
analyze | 1 credit |
export | 1 credit |
sample | 0 credits (free) |
Response Fields
| Field | Type | Description |
|---|---|---|
sufficient | boolean | Whether the user has enough credits |
balance | number | Current balance before deduction |
cost | number | Total credits required |
remaining | number | Balance after deduction (only if deduct: true) |
Error Codes
| Status | Meaning |
|---|---|
200 | Sufficient credits (and deducted if requested) |
401 | Invalid or missing API key |
402 | Insufficient credits |
