Todos os artigos

API keys and billing

Two accounts of money sit behind one Sunra login, and they do not meet: the credits your plan gives you, and the API balance your code spends. Buying credits will not make an API request run, and an empty API balance will not stop you working in the app. Everything below is about the second one.

Create a key

Go to Developer mode → API keys and click Create API key. Name it after where it will run — Production, staging, my-laptop — because the name is how you will know which key to revoke later.

The key is shown once, on the screen right after you create it. Save it then; you cannot read it again.

The usual place to put it is the SUNRA_KEY environment variable: both official clients read it from there, and the docs' cURL examples expect it. If you save it in a file, make it a .env that is in your .gitignore — and remember that saving the file doesn't load it; your run command has to.

Nota
If your account isn't on the new Developer console yet, the API keys page links out to platform.sunra.ai, where the same keys live. Create and revoke them there; everything below still applies.

One key, both APIs

A single key authenticates both Sunra APIs:

  • Authorization: Key … for generation requests on api.sunra.ai
  • Bearer … for the LLM endpoint on api-llm.sunra.ai

A key grants access to your account balance, so treat it like a password: keep it out of client-side code, git and logs. If you need one for a second place, make a second key rather than copying one around — then you can retire either without breaking the other.

Creative Sunra MCP needs no API key: it signs in with your Sunra account and spends Creative credits. For production automation and software integrations, including internal tools, use API credentials and billing as described in Sunra API. The separate API-key MCP server uses an API key and follows the API rules.

Rename, revoke and audit a key

The keys table shows one row per key with its name, a masked key, its status, its spend over the last 30 days, when it was last used, and when it was created. That answers two questions at a glance: which key is costing you money, and which key nothing is using any more.

Each row's actions menu offers:

  • Rename — names have to be unique among your keys, so you are never guessing between two called Production.
  • Revoke — apps using that key stop working right away, and it can't be undone.

If a key may have leaked, create the replacement first, deploy it, then revoke the old one. A revoked key cannot authenticate, so the order matters.

Aviso
Revoking is immediate and permanent. Anything still sending that key — a server, a scheduled job, a teammate's machine — starts failing the moment you confirm.

The balance is prepaid, in US dollars

API usage draws down a prepaid dollar balance. There is no subscription and no bill at the end of the month: you add funds, your requests spend them, you add more.

Add funds from Developer mode → Billing → Add funds. The dialog shows the amounts you can choose, the minimum, and the service fee added at checkout; it also saves your card for future top-ups. Very large top-ups go beyond what a card payment allows — Contact sales for those.

Auto top-up refills the balance from your saved card when it falls below a level you set. Set both numbers in Billing: the level that triggers it, and how much to add. Two notes:

  • It needs a saved card; with no card to charge it pauses rather than failing silently, and the page says so.
  • If a charge can't be made at all, auto top-up is turned off. Add a working card and turn it back on — it doesn't resume by itself.

Where usage and invoices are shown

Usage is the detailed view: spend, generations and requests, filtered by API key and by model, over a range and granularity you choose, downloadable as CSV. A revoked key keeps its history, so last month's spend doesn't disappear when you rotate a key.

The Dashboard gives the short version for a recent period, and Generations and Completions list individual calls with what each one cost.

Invoices live under Billing → Invoices, where each row is typed: an API top-up, an auto top-up, a bonus or an adjustment, alongside plan and credit-pack payments. Each one can be downloaded. Plan invoices are kept in the billing portal; API invoices belong to your Sunra API account.

What happens when the balance runs out

Nothing goes negative. At submit, Sunra holds the most the request could cost against the balance, then settles the actual cost. So:

  • If the balance can't cover the hold, the request is refused at submit rather than failing halfway.
  • If a request costs less than the hold, the difference is released — you are charged what it actually cost.
  • Requests that were already accepted finish normally.

The fix is the same either way: add funds, or turn auto top-up on so a low balance refills itself before it stops your code. Your credits and plan are untouched by all of it.

Artigos relacionados