> ## Documentation Index
> Fetch the complete documentation index at: https://docs.imagine.art/llms.txt
> Use this file to discover all available pages before exploring further.

# Authentication

> Authenticate ImagineArt API requests with a Bearer key and set credit limits per key.

Every request except `GET /models` and `GET /cost` needs your key as a Bearer token.

```
Authorization: Bearer $IMAGINE_API_KEY
```

A key belongs to one organization and spends its credits. The secret is shown once, when you create it; after that only a short `preview` is visible. Only organization owners and admins can create or manage keys.

## Credit limits

Give each key a credit cap that resets on a schedule, so one integration can't drain the balance. A request past the cap fails with `402`, code `1210`.

| Field | Type | Meaning |
| - | - | - |
| `credit_limit` | integer \| null | Credits per period; null means no cap |
| `credit_limit_period` | string | monthly, quarterly or yearly |
| `credits_used` | integer | Spent in the current period |
| `credits_reset_at` | ISO 8601 | When credits\_used resets to 0 |
| `expires_at` | ISO 8601 \| null | When the key stops working; null means never |

## Manage keys

```bash theme={null}
curl -X POST https://api.imagine.art/v1/keys \
  -H "Authorization: Bearer $IMAGINE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Backend",
    "credit_limit": 50000,
    "credit_limit_period": "monthly"
  }'
```

The secret is in `data.key`. Use `GET /keys` to list, `PATCH /keys/{id}` to rename or change the limit, and `DELETE /keys/{id}` to revoke.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.