Skip to main content
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

Two samples of real model output from the public Sleep-EDF recording SC4001: 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; the attribution field gives the required notice and citations. Details: Samples.

2. Get an instant key with one request

No email is needed. "accept_terms": true accepts the API terms; 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). 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). 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):
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. GET /v1/models (no key) lists every limit, for routing a file before uploading it.

Machine-readable entry points

Trial key by email

A trial key directly, without an instant key first:
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:
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 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.

Command line

--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:
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. 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.

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. 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) 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.

Tested recipe

Similarity search is a complete script that was run as printed, with its results. Sleep staging gives the commands for a whole night, run against the live API, with the output. The sleep staging benchmark gives its accuracy on held-out data from ten public test sets.