# Authentication

Send the API key in the Authorization header. Rules for active, blocked and expired keys.

Every request carries an API key.

```text
Authorization: Bearer SIVCLOUD_API_KEY
```

For `/v1/messages` and `/v1/models` the header `x-api-key: SIVCLOUD_API_KEY` is also accepted, as in the Anthropic SDK.

## Rules

- Send the key in a header only. Never put it in a URL, in browser code or in a public repository.
- One account can have many keys, up to 100 by default. Use one key per application so you can revoke it alone.
- A key that is blocked, expired or revoked is rejected with `invalid_api_key` (HTTP 401).
- A key can be limited to some models. Any other model is answered with `model_not_found` (HTTP 404).
- You can copy an active key again from the console. A blocked or expired key cannot be copied.
- Think a key leaked? Rotate it in the console. The old key stops working at once.

Key settings are described on the [API keys](https://sivcloud.com/en/docs/console/api-keys/) page.

## Check your balance from a key

`GET https://ai.sivcloud.com/v1/balance` returns the balance of the account that owns the key, without opening the console.

```bash
curl https://ai.sivcloud.com/v1/balance -H "Authorization: Bearer $SIVCLOUD_API_KEY"
```

```json
{
  "balance_rp": 125000,
  "key_limit_rp": null,
  "allowances": [
    {"plan": "Pro", "models": [], "remaining": 3400000, "resets_at": "2026-12-01T00:00:00+07:00"}
  ]
}
```

- `balance_rp`: the account's balance in rupiah.
- `key_limit_rp`: what is left of this key's credit limit in rupiah, or `null` when the key has no limit.
- `allowances`: the plan allowances in effect. `plan` is the plan name (empty when unknown), `remaining` is in tokens, an empty `models` means all models, and `resets_at` is `null` when the allowance does not expire.

Only the account that owns the key is returned.

## Example error

```json
{
  "error": {
    "message": "invalid api key",
    "type": "invalid_request_error",
    "code": "invalid_api_key"
  }
}
```

The full list is in [Error codes](https://sivcloud.com/en/docs/errors/).
