Get started
Authentication
API keys, scopes and keeping keys safe.
Every request to /v1 needs an API key in the Authorization header.
Authorization: Bearer ast_gw_...Keys start with ast_gw_. A request without a valid key gets 401 unauthorized.
Creating a key
Create keys in the console under API keys. You choose a name, the scopes the key gets, and when it expires. The full key is shown once, when you create it. We store only a hash, so if you lose it, revoke the key and make a new one.
- You can have up to 5 active keys at a time.
- In the console, a key expires after 30 or 90 days; you pick which when you create it (90 by default).
- All keys on an account share the same wallet, limits and job queue.
Scopes
A scope allows one kind of request. Give each key only what it needs. A request outside the key's scopes gets 403 scope_denied.
| Scope | Allows |
|---|---|
models:read | Read the model catalog and capabilities |
quotes:create | Price a job before running it |
quotes:read | Read earlier quotes |
jobs:create | Run generation jobs (spends wallet funds) |
jobs:read | Read job status and results |
jobs:cancel | Cancel running jobs |
wallet:read | Read the wallet balance and ledger |
files:write | Upload input files for jobs |
account:read can be granted but no API endpoint uses it yet.
Some common sets:
| Use | Scopes |
|---|---|
| Run models from a backend | models:read jobs:create jobs:read |
| Also cancel and preview prices | quotes:create jobs:cancel |
| Send your own input files | files:write |
| An AI agent over MCP or the CLI | models:read quotes:create jobs:create jobs:read jobs:cancel wallet:read |
| A read-only dashboard | models:read jobs:read wallet:read |
Rotating a key
To replace a key without downtime:
- Create a new key with the same scopes.
- Deploy your app with the new key.
- Revoke the old key in the console.
Revoking a key stops new requests with it. Jobs it already started keep running and are billed as usual.
Keeping keys safe
- Load the key from an environment variable or a secret manager, not from source code.
- Never call the API from a browser. Put it behind your own backend.
- Use a separate key per app or environment, so you can revoke one without touching the rest.
- If a key leaks, revoke it in the console straight away and check your wallet ledger.