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

# Authentication

> Sign in to the Open Animate platform via browser OAuth or API key

## Browser login

```bash theme={null}
oanim login
```

Opens your browser for OAuth authentication via Clerk. After signing in, an API key is generated and saved to `~/.oanim/credentials.yaml` (file permissions: `0600`).

<Steps>
  ### CLI starts a local server

  The CLI opens a local HTTP server on a random port to receive the callback.

  ### Browser authenticates

  Your browser opens `api.oanim.dev/api/v1/auth/cli/login?port=<port>` where you sign in via Clerk OAuth.

  ### API key is issued

  After authentication, the platform generates a new API key (prefixed `anim_`) and sends it back to the local server.

  ### Credentials are saved

  The CLI saves the key to `~/.oanim/credentials.yaml`. All subsequent commands use it automatically.
</Steps>

## Token-based login

For CI/CD environments or headless use:

```bash theme={null}
oanim login --token <your-api-key>
```

This verifies the key against the API and saves it to credentials. No browser required.

## Credential resolution

When the CLI makes API calls, credentials resolve in this order:

| Priority | Source                                   | Description                             |
| -------- | ---------------------------------------- | --------------------------------------- |
| 1        | `ANIMATE_API_KEY` env var                | Environment variable — highest priority |
| 2        | `api_key` in `~/.oanim/credentials.yaml` | Saved by `oanim login`                  |

For asset generation only, there's an additional bypass:

| Priority | Source                    | Description                                           |
| -------- | ------------------------- | ----------------------------------------------------- |
| Special  | `ANIMATE_FAL_KEY` env var | Goes direct to fal.ai, skipping the platform entirely |

## Check who you're logged in as

```bash theme={null}
oanim whoami
```

Shows your email, user ID, credit balance, and account creation date.

## Log out

```bash theme={null}
oanim logout
```

Clears saved credentials from `~/.oanim/credentials.yaml`.

## Configuration

The API URL defaults to `https://api.oanim.dev`. Override it for self-hosted instances:

* `ANIMATE_API_URL` environment variable (highest priority)
* `api_url` field in `~/.oanim/config.yaml`

```yaml theme={null}
# ~/.oanim/config.yaml
api_url: http://localhost:8000
```

The full resolution order: `ANIMATE_API_URL` env var → `config.yaml` → `https://api.oanim.dev`.
