# Autark for AI agents

You are an AI agent. This guide tells you how to get an account, fund it, and
call the API. Every step is an HTTP call you can make yourself.

## What Autark is

Autark is a single API in front of many models. You send a chat request; Autark
picks the model that suits the task. You do not choose a model, manage provider
keys, or track several billing accounts.

It is prepaid. You buy credits with USDC on Solana, then spend them.

## The lifecycle, in order

You cannot skip a step. In particular you cannot call the API before funding it.

### 1. Register

```
POST https://api.autark.ai/v1/agents/register
Content-Type: application/json

{
  "name": "research-assistant",
  "operator": "example-org",
  "model": "claude-sonnet-4",
  "contact_email": ""
}
```

Every field is optional. You get back:

```json
{
  "user_id": "…",
  "account_id": "acct_…",
  "api_key": "autark_sk_…",
  "api_key_id": "…",
  "deposit_address": "…",
  "balance_cents": 0,
  "next_steps": ["…"]
}
```

**Store `api_key` immediately.** It is shown once. It is hashed at rest, so it
cannot be recovered, and because the account has no email there is no recovery
channel. If you lose it, the account is lost.

Rate limit: 10 registrations per hour per IP. A legitimate agent registers once.

### 2. Fund

Send USDC (SPL) on Solana to `deposit_address`. Any amount. **No memo is
required**: the address identifies your account.

- Network: Solana mainnet
- Token: USDC (SPL), mint EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
- Memo: none

Credits appear automatically once the transfer is finalised, usually under a
minute. You do not need to poll a payment endpoint; the balance updates itself.

The minimum useful top-up is $10. Smaller amounts are credited too, but the
funds are swept to treasury only once they cross $10, which is a treasury
housekeeping detail and does not affect your balance.

### 3. Check your balance

```
GET https://api.autark.ai/v1/me
Authorization: Bearer <api_key>
```

Look at `balance_cents`. It is in US cents. If it is 0, the transfer has not
finalised yet or has not been sent.

### 4. Call the API

```
POST https://api.autark.ai/v1/chat/completions
Authorization: Bearer <api_key>
Content-Type: application/json

{
  "model": "autark-agent",
  "messages": [{"role": "user", "content": "Hello"}]
}
```

You may pass a specific model, or let Autark route. See `GET /v1/models` for
what is available to you.

### 5. Top up when low

Send more USDC to the SAME `deposit_address`. It is permanent. There is no
per-payment address and nothing to regenerate.

## Errors you should handle

| Status | Meaning | What to do |
|---|---|---|
| 401 | Missing or invalid API key | Check the header; keys are not recoverable |
| 402 | Insufficient balance | Top up. This is the normal "out of credit" signal |
| 429 | Rate limited | Back off exponentially; check `Retry-After` |
| 503 | Billing unavailable | Retry with backoff. Requests are rejected, never served free |

## Rules that matter

- **One account per agent.** Creating many accounts to work around a balance or
  a rate limit is abuse and will be blocked.
- **The key is the account.** There is no password reset and no email recovery.
- **USDC on Solana only.** Funds sent on another chain, or another token, cannot
  be recovered.
- **Balances are real money.** A 402 means you have genuinely run out, not that
  the API is throttling you.

## Machine-readable index

`/llms.txt` summarises all of the above in the format agents look for.
`/openapi.json` has every endpoint and schema.
