# Authentication

> The API takes an API key on every request; the console takes a sign-in. Keep keys safe.

Source: https://docs.strokes.ink/get-started/authentication

There are two kinds of access, kept apart:

| | What it's for | How |
| --- | --- | --- |
| **API key** | Your code calling `api.strokes.ink` | The `x-api-key` header on every request |
| **Console sign-in** | You, in the browser at [platform.strokes.ink](https://platform.strokes.ink) | Google or an email code |

Signing in never authenticates an API request, and an API key never opens the console.

## Send the key

Put your key in the `x-api-key` header:

```bash
curl https://api.strokes.ink/v1/models \
  -H "x-api-key: $STROKES_API_KEY"
```

`Authorization: Bearer <key>` works too, for clients that only know that form.

A request with no key, a wrong key or a deleted key gets a `401`:

```json
{
  "type": "error",
  "error": { "type": "authentication_error", "message": "Invalid API key." },
  "request_id": "req_…"
}
```

A [disabled](/console/api-keys#disable-or-delete-a-key) key gets a `401` too, with the message `This API key is disabled. Enable it on the API keys page.`

## Keys

- Keys start with `swi_live_` and are 49 characters long.
- A key belongs to an [organization](/console/organizations), not to a person: anyone in the organization can use, disable and delete it, and it keeps working when the person who made it leaves. Its requests are paid from the organization's [credits](/console/billing).
- Strokes keeps only a hash of each key. If you lose one, create a new one — it can't be shown again.

Create, disable and delete keys, and cap what each can spend, on the console's [API keys](/console/api-keys) page.

## Keep keys on your server

Call the API from your backend, never from a browser or a mobile app: anything shipped to a user's device can be read. The API sends no CORS headers, so browsers block calls from web pages anyway.

- Store keys in environment variables or a secrets manager, not in your repository.
- Use one key per service or environment, so you can disable or delete one without touching the others, and give each its own spend limit.
- If a key leaks, delete it at once on the **API keys** page. Requests with it fail from that moment.

## Sign in to the console

Open [platform.strokes.ink](https://platform.strokes.ink) and sign in one of these ways:

- **Continue with Google** — sign in with your Google account.
- **Email** — enter your address, click **Continue**, and enter the 6-digit verification code sent to your inbox.

Only a verified email address signs in. Your account is your email address, whichever way you sign in — a code to `you@example.com` and a Google account for `you@example.com` open the same account, with the same organizations.

The first time you sign in, you get an organization of your own. See [Organizations and members](/console/organizations).
