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

> ## Agent Instructions
> Neuroencoder is a hosted EEG embeddings API (https://api.neuroencoder.com/v1). The model runs only on its servers. Python package `neuroencoder` on PyPI: client and command line tool; it does not contain the model. Precomputed real outputs need no key: GET https://api.neuroencoder.com/v1/samples lists two samples from the public Sleep-EDF data (ODC-By 1.0, attribution required): a full night's embeddings with scored sleep stages, and a 10-minute EDF with its embeddings. An instant key needs no email: POST /v1/signup with {"instant": true, "accept_terms": true} accepts the API terms (https://docs.neuroencoder.com/terms) and returns a provisional key at once (2 h of EEG, 20 requests/min, at most 120 windows per request or job, 7 days) and a claim_url that a person can open to turn the same key into a trial key. GET /v1/models also needs no key. From nothing to your own file in five commands: https://docs.neuroencoder.com/quickstart. A trial key also comes from `neuroencoder login --email <address>` or the HTTP device flow (POST /v1/signup with "device": true, then POST /v1/signup/token); a person ticks the terms boxes and approves the emailed link once. Data use (https://docs.neuroencoder.com/data-use): a response with "data_use": "contribute" stored a de-identified copy of the signal that may train our models; a response without data_use, or with "zero_retention", kept no copy (jobs keep their upload until they end and their result for 7 days). Terms: https://docs.neuroencoder.com/terms. Privacy: https://docs.neuroencoder.com/privacy. Security and vulnerability reports (security@neuroencoder.com): https://docs.neuroencoder.com/security. Main endpoint: POST /v1/embeddings with an EDF, BDF, FIF or NPY file or a JSON array; any montage, any sampling rate; one 768-dimensional vector per window. Errors are JSON with a `fix` field. Versions (https://docs.neuroencoder.com/versioning): `neuroencoder-eeg` is an alias, `neuroencoder-eeg-2026-11` a dated snapshot that never changes; pin with `model` or the Neuroencoder-Model header; responses carry model, model_snapshot and pipeline_version; deprecations get at least 6 months' notice. Support: support@neuroencoder.com (best effort, reply within 3 business days); status: https://neuroencoder.com/status. Reference: https://docs.neuroencoder.com/api. Getting started without signing up: https://docs.neuroencoder.com/instant-keys. OpenAPI: https://api.neuroencoder.com/v1/openapi.json. Sleep staging: a whole-night PSG (.edf/.bdf, at least 2 h, at least one EEG channel with a 10-20 label at 100 Hz or more; EOG used when present) as a job with "task": "sleep_staging" (POST /v1/files, PUT, POST /v1/jobs, poll, download) returns W/N1/N2/N3/REM per 30 s epoch with probabilities, a low-confidence flag, summary metrics (TST, sleep efficiency, latencies, WASO) and a CSV; it counts nights per week (trial 3, instant 1), weeks start Monday 00:00 UTC. Model neuroencoder-sleep-2026-11, trained on 1,629 nights from eight public datasets licensed for commercial use. On nights it never trained on, Cohen's kappa with EOG is 0.755 on 44 Sleep-EDF telemetry nights and 0.687 on 128 BOAS nights (YASA's pretrained classifier on the same nights: 0.732 and 0.659), and 0.672 to 0.807 across eight leave-one-site-out folds. It is behind that reference on CAP and ANPHY, and slightly below on DOD (within the confidence intervals). Guide: https://docs.neuroencoder.com/sleep-staging. Benchmark: https://docs.neuroencoder.com/sleep-benchmark.

# Instant keys

> Start with the Neuroencoder EEG embeddings API without signing up: samples without a key, an instant key from one request, scripting, OpenAPI, error contract

You can go from nothing to your own result in three commands: look at real output without a key, get an instant key with one request, then embed a file.

## 1. Look at a sample, no key needed

```bash theme={null}
curl -s https://api.neuroencoder.com/v1/samples
curl -sO https://api.neuroencoder.com/v1/samples/sleep-edf-sc4001-10min/sleep-edf-sc4001-10min.edf
curl -sO https://api.neuroencoder.com/v1/samples/sleep-edf-sc4001-10min/sleep-edf-sc4001-10min.npz
```

Two samples of real model output from the public [Sleep-EDF](https://physionet.org/content/sleep-edfx/1.0.0/) recording SC4001:

| Sample | Contents |
| - | - |
| `sleep-edf-sc4001` | Embeddings of the whole recording (2,650 windows, 22 h including the daytime wake around the night) with the human-scored sleep stage of each window: `.npz`, 7.6 MB |
| `sleep-edf-sc4001-10min` | A 10-minute EDF cut from that recording (wake, N1, N2, N3) and the 20 embeddings the API returns for it |

`GET /v1/samples/{name}` returns the README, licence, attribution, `channels_used` and the embeddings in the same format as a `POST /v1/embeddings` response, with a `stage` per window (the first 2 windows for the long sample, all of them in its `.npz`). Each `.npz` holds `embeddings` (float32 `[windows, 768]`), `t_start`, `stage` (AASM), `stage_rk` (original R\&K label) and `channels`. The data are under the [ODC Attribution License 1.0](https://physionet.org/content/sleep-edfx/view-license/1.0.0/); the `attribution` field gives the required notice and citations. Details: [Samples](https://docs.neuroencoder.com/api.md#samples).

## 2. Get an instant key with one request

```bash theme={null}
(umask 077; curl -s -X POST https://api.neuroencoder.com/v1/signup -H "content-type: application/json" -d '{"instant": true, "accept_terms": true}' > neuroencoder_key.json)
export NEUROENCODER_API_KEY=$(python3 -c "import json; print(json.load(open('neuroencoder_key.json'))['key'])")
```

No email is needed. `"accept_terms": true` accepts the [API terms](https://docs.neuroencoder.com/terms.md); it is required (without it the answer is 400 `terms_not_accepted`). Uploads with a key that contributes are stored de-identified and may train our models, so send only recordings you are allowed to share; every response's `data_use` says what was kept ([Data use](https://docs.neuroencoder.com/data-use.md)). The response holds the key (shown once; the file above is readable only by you), its `tier` (`instant`), `expires_at`, a `message` with the limits, and a `claim_url` (also shown only once; it stays in `neuroencoder_key.json`). An instant key has 2 h of EEG, 20 requests per minute, at most 120 windows (1 h at the default stride) per request or job, 1 request in flight, and is valid 7 days. At most 3 instant keys are issued per network (IPv4 /24 or IPv6 /64) per day.

To keep the key and raise its limits, open `claim_url`, enter your email address, tick the terms boxes if the page shows them, and confirm the link mailed to you (valid 30 minutes); the same key then becomes a trial key (100 h of EEG per month, 30 days) and this month's usage carries over. The key itself does not change, so scripts that use it keep working. A claimed key can ask for more keys of its account, for example for a teammate ([Keys for your team](https://docs.neuroencoder.com/quickstart.md#keys-for-your-team)). Adding `"email": "you@lab.org"` to the signup mails the claim link to that address at once. If the address already has an account, the link adds the key to that account instead (its tier and limits; the page asks you to confirm only a key you created), and the answer is the same either way.

To save the key for the Python package and CLI: `python3 -c "import json; print(json.load(open('neuroencoder_key.json'))['key'])" | neuroencoder login --key -`.

## 3. Embed a file

Send the sample EDF and compare with the published embeddings (the check needs `numpy`):

```bash theme={null}
curl -s https://api.neuroencoder.com/v1/embeddings -H "Authorization: Bearer $NEUROENCODER_API_KEY" -F file=@sleep-edf-sc4001-10min.edf > mine.json
python3 -c "
import json, numpy as np
mine = np.array([d['embedding'] for d in json.load(open('mine.json'))['data']], dtype=np.float32)
ref = np.load('sleep-edf-sc4001-10min.npz')['embeddings']
print(mine.shape, (mine * ref).sum(1).min())"
```

This prints `(20, 768)` and a minimum cosine of 0.9999 or higher (vectors are unit length; 0.99995 in our test); it bills 10 minutes of EEG. The same call works for your own EDF, BDF, FIF or NPY file, up to 1 h per request with an instant key; with a trial key a whole night of up to 24 h is one [job](https://docs.neuroencoder.com/api.md#jobs-for-long-recordings). `GET /v1/models` (no key) lists every limit, for routing a file before uploading it.

## Machine-readable entry points

| What | Where |
| - | - |
| Index of these docs | [`/llms.txt`](https://docs.neuroencoder.com/llms.txt) |
| All docs in one file | [`/llms-full.txt`](https://docs.neuroencoder.com/llms-full.txt) |
| Skill file (usage, limits, retries in one page) | [`/skill.md`](https://docs.neuroencoder.com/skill.md) |
| Any page as Markdown | append `.md`, e.g. [`/api.md`](https://docs.neuroencoder.com/api.md) |
| API summary as plain text | [`https://api.neuroencoder.com/llms.txt`](https://api.neuroencoder.com/llms.txt) |
| OpenAPI | [`https://api.neuroencoder.com/v1/openapi.json`](https://api.neuroencoder.com/v1/openapi.json), interactive at [`/v1/docs`](https://api.neuroencoder.com/v1/docs) |

## Trial key by email

A trial key directly, without an instant key first:

```bash theme={null}
pip install neuroencoder
neuroencoder login --email you@lab.org
```

The command prints a short code and emails a link to that address. Open the link and approve only if the page shows the same code; the command then receives the key and saves it to `~/.config/neuroencoder/api_key` (mode 600, `$XDG_CONFIG_HOME` respected). The mail does not contain the code; compare the code on the page with the one in your terminal. Never approve a code someone else gave you. In Python: `neuroencoder.login("you@lab.org")`.

The same device flow over HTTP:

```bash theme={null}
curl -X POST https://api.neuroencoder.com/v1/signup -H "content-type: application/json" -d '{"email": "you@lab.org", "device": true}'
# -> device_code (keep it secret), user_code (the emailed page shows the same code), interval 5, expires_in 1800
curl -X POST https://api.neuroencoder.com/v1/signup/token -H "content-type: application/json" -d '{"device_code": "<device_code>"}'
# every 5 s: {"status": "pending"} until the link is approved, then the key exactly once
```

A script that reads your mailbox can approve a signup you started by posting the token from the link, `POST /v1/verify` with `{"t": "<token>", "accept_terms": true}` (this accepts the [API terms](https://docs.neuroencoder.com/terms.md) for you): for a device signup this approves it and the key still goes to `/v1/signup/token`; for a signup without `"device": true` the response is the key itself.

A trial key is valid 30 days with 100 h of EEG per month, 30 requests per minute, 2,000 windows per minute, 2 requests in flight and 1 job at a time. Signing up again while the address has a live trial key replaces it: the new key keeps the same limits, expiry and this month's usage, and the old key is revoked when the new one is issued. The key is looked up as the `api_key` argument, then `NEUROENCODER_API_KEY`, then the saved file; keep it out of logs and URLs (send it only in the `Authorization: Bearer` header). A key you already have can be saved with `echo "$KEY" | neuroencoder login --key -`. If the email does not arrive, email [contact@neuroencoder.com](mailto:contact@neuroencoder.com).

## Command line

```bash theme={null}
neuroencoder whoami                             # tier, limits, usage this month, expiry
neuroencoder inspect night.edf                  # free, no upload: channels -> regions, duration, windows and seconds embed would bill
neuroencoder embed night.edf -o night.npz       # bills; [--stride 30] [--no-filter] [--force]
neuroencoder --json embed night.edf -o night.npz
neuroencoder logout                             # delete the saved key file
```

`--json` prints exactly one JSON object on stdout; a failure prints `{"error": {"code", "message", "fix"}}` and exits 1 (2 for usage errors). `embed` writes `embeddings` (float32 `[n, 768]`), `t_start` (`[n]`, seconds) and `meta` (a JSON string with model, source, sfreq, stride, channels used and usage) to one `.npz`, and does not overwrite without `--force`. `.npy` input needs `--sfreq` and, unless it has the 8 regional rows, `--channels Fp1,C3,...`.

## Error contract

Every API error is JSON with the same shape; `param` names the offending field and `fix` says what to change:

```json theme={null}
{"error": {"message": "Invalid or missing API key.", "type": "authentication_error", "code": "invalid_api_key",
           "param": null, "fix": "Send 'Authorization: Bearer ne_live_...' (56 characters). No key? POST https://api.neuroencoder.com/v1/signup {\"instant\": true, \"accept_terms\": true} (accepts https://docs.neuroencoder.com/terms) returns an instant key at once (no email; 2 h of EEG, 7 days). A trial key: `pip install neuroencoder && neuroencoder login --email you@lab.org`, or POST /v1/signup {\"email\": ..., \"device\": true}; docs https://docs.neuroencoder.com/quickstart"}}
```

Branch on `code`, apply `fix`, and quote the `x-request-id` response header when reporting a problem. The full list of codes is in the [API reference](https://docs.neuroencoder.com/api.md#errors). The Python client raises the same fields as `.status`, `.code`, `.param` and `.fix`.

## Retries and idempotency

Send `Idempotency-Key: <uuid4>` with every `POST /v1/embeddings` and reuse it when retrying the same request: a repeated request is never billed twice, and the same key with a different request is a 409 `idempotency_key_reused`. Retry 503 `overloaded` and 429 `rate_limit_exceeded`, `concurrency_limit_exceeded` and `windows_rate_limit_exceeded` after `Retry-After`. A 429 without a JSON `code` comes from the gateway or firewall: back off exponentially with jitter. Do not retry `quota_exceeded` or `too_many_queued_jobs`. The Python client and the CLI (2.2.0) retry 503 and `rate_limit_exceeded` themselves; other 429s raise an error. Details: [Retries and idempotency](https://docs.neuroencoder.com/api.md#retries-and-idempotency).

## Limits

1,024 windows per request (8.5 h at the default 30 s stride), `sfreq` 50 to 20,000 Hz, 256 channels, 512 MB per upload, 120 s per request including the upload. The Python client and CLI split longer recordings into several requests (EDF, BDF and FIF files over 32 MiB need `pip install mne` for that). Billing is per window, 30 s of EEG each, so a smaller `stride_seconds` bills more. An instant key takes at most 120 windows per request or job (403 `agent_key_limit`, not billed) until it is claimed. Full table: [Limits](https://docs.neuroencoder.com/api.md#limits).

**Long recordings over HTTP.** A whole recording of up to 24 h is one job, so a full night needs no splitting: `POST /v1/files` gives an upload URL, PUT the file there, `POST /v1/jobs`, poll `GET /v1/jobs/{id}` every `Retry-After` seconds, then download `result.url` (an `.npy` `[windows, 768]`). A 23 h Sleep-EDF recording (2,802 windows) took 65 s from upload to result. Results are kept 7 days (a contributed copy of the signal is separate: [Data use](https://docs.neuroencoder.com/data-use.md)) and the upload is deleted when the job ends. The Python client and CLI 2.2.0 do not use jobs yet. Steps and limits: [Jobs for long recordings](https://docs.neuroencoder.com/api.md#jobs-for-long-recordings).

## Tested recipe

[Similarity search](https://docs.neuroencoder.com/similarity-search.md) is a complete script that was run as printed, with its results. [Sleep staging](https://docs.neuroencoder.com/sleep-staging.md) gives the commands for a whole night, run against the live API, with the output. The [sleep staging benchmark](https://docs.neuroencoder.com/sleep-benchmark.md) gives its accuracy on held-out data from ten public test sets.


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