SegmindSegmind / Docs

Account and Billing APIs

Check your Segmind credit balance programmatically with the get-user-credits endpoint, authenticated by your API key.

Account endpoints live on the same gateway as the model APIs, https://api.segmind.com/v1, and take the same API key.

Authentication

Send your key in the x-api-key header. You can create and revoke keys in the console under Developer → API Keys — see Account and Developer Settings.

-H 'x-api-key: YOUR_API_KEY'

This is the same key you use for model requests, so a key that works for inference works here.

Get your credit balance

curl 'https://api.segmind.com/v1/get-user-credits' \
  -H 'x-api-key: YOUR_API_KEY'
{
  "credits": 0.0,
  "free-credits": 0.0184921035
}
FieldMeaning
creditsYour spendable balance. This is the figure to read for "how much do I have left" and the one that matches the Credits Balance shown on the console dashboard.
free-creditsAlso returned, and reported separately from credits.

Both are returned as numbers, not strings, and at full precision rather than rounded to cents — expect several decimal places, since a single request can cost a fraction of one.

Responses

StatusWhenBody
200Success{"credits": …, "free-credits": …}
401No key sent at all{"error": "Missing Authorization or x-api-key in header"}
401Key sent but invalid or expired{"error": "Unauthorized. API key is invalid or may have expired…"}
404Authenticated, but no balance record exists for the account{"error": "No credits found for the user"}

The two 401s are worth telling apart: the first means your header never arrived — usually a client that drops unknown headers on redirect — while the second means the key itself was rejected. Only the second is worth regenerating a key over.

The invalid-key message ends by suggesting where to check your keys, and the address it gives is an older console one. The current page is Developer → API Keys at platform.segmind.com/api-keys.

Reading your balance without a second call

You rarely need this endpoint in a loop, because a synchronous model request already tells you what it cost and what you have left. A v1 response carries the accounting in its headers:

HeaderHolds
x-costwhat this request was charged
x-remaining-creditsyour balance after it
x-request-idthe request id, the same one Generations lists
x-generation-timehow long the model itself took, in seconds
x-seed-valuethe seed used, where the model reports one — see Random seed
x-rate-limit-reset-at-utcwhen your current rate-limit window resets

Headers are how v1 reports this because the response body is the output itself — an image, not JSON. On v2 the same figures arrive in the metrics object instead, as cost and remaining_credits.

So for metering, read x-cost and x-remaining-credits off the request you already made, and keep this endpoint for the times you want a balance without running anything.

Checking your balance does not cost credits, and it reads the same balance the gateway checks before running a model. A model request is refused when that balance is below the cost of the model you are calling — not only when it reaches zero — and comes back as 406 with an Insufficient credits error naming both your balance and what the call needed.

  • Pricing and billing — how credits are priced and consumed.
  • Teams — balances are per workspace, so switching teams changes which balance you are reading.

On this page