Get started

Authentication

API keys, scopes and keeping keys safe.

Every request to /v1 needs an API key in the Authorization header.

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.

ScopeAllows
models:readRead the model catalog and capabilities
quotes:createPrice a job before running it
quotes:readRead earlier quotes
jobs:createRun generation jobs (spends wallet funds)
jobs:readRead job status and results
jobs:cancelCancel running jobs
wallet:readRead the wallet balance and ledger
files:writeUpload input files for jobs

account:read can be granted but no API endpoint uses it yet.

Some common sets:

UseScopes
Run models from a backendmodels:read jobs:create jobs:read
Also cancel and preview pricesquotes:create jobs:cancel
Send your own input filesfiles:write
An AI agent over MCP or the CLImodels:read quotes:create jobs:create jobs:read jobs:cancel wallet:read
A read-only dashboardmodels:read jobs:read wallet:read

Rotating a key

To replace a key without downtime:

  1. Create a new key with the same scopes.
  2. Deploy your app with the new key.
  3. 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.