API keys

An API key lets code that runs outside a Neural Studio runtime act as you: the Python SDK on your laptop or a cluster, ns runs sync, and the ns command that relays SSH. Inside a runtime you do not need one; the kernel and terminal carry a narrower session key of their own.

Creating a key

Account settings → API Keys → Create key. Give it a name of 1 to 64 characters, an access level (Full access, Data read and write or Data read only, see below) and an expiration: No expiration, 30 days, 60 days, 90 days or 1 year. The key is shown exactly once, on creation; the list afterwards shows only its name, its first characters, its access, its status and when it was created. Copy it straight into the place the SDK reads it from:

export NEURAL_STUDIO_API_KEY=ns_...
# or, persistently:
mkdir -p ~/.config/neural-studio
printf 'api_key = "ns_..."\n' > ~/.config/neural-studio/config.toml

Keys start with ns_ followed by about 32 URL-safe characters. The platform stores only a hash and the first 12 characters, so a lost key cannot be recovered, only replaced. An account holds at most 10 active keys; revoke one from the same page to make room. Revoke takes effect at once, and an expired key is refused the same way.

What a key can reach

A key you create has one of three access levels. Pick the narrowest one the code needs: a key for a training cluster that only moves data does not need to open SSH.

Access (scope)What it reaches
Full access (full_access)Everything in the "Works with a key" column below
Data read and write (data:write)Buckets and the workspace's own files only: list, download, upload, move, copy and delete objects, create and delete buckets, read-only credentials; list, download, upload, move and delete files and folders (ns://workspace/)
Data read only (data:read)Buckets and the workspace's files, read only: list objects, download, read-only credentials; list and download files and folders. It cannot change anything
A runtime's session key (sdk:session)Creating and feeding runs (and the project a new run names), and the buckets, of its own workspace only (its files are the runtime's local ~/workspace folder, not the Files API); see below

"Full access" is full access to the surfaces that accept keys, not to everything a signed-in browser can do:

Works with a full-access keySign-in only
Creating runs and streaming metrics, logs, artifacts and media (ns.init, ns runs sync)Launching, stopping or restarting a runtime
Reading runs, metrics, logs, artifacts and mediaNotebooks, and sharing files or making public links
The compute catalog and your account's launch limitsEnvironments and builds
SSH tickets and the ssh-config block (ns ssh)Workspaces, members, sharing
Buckets and workspace files: everything a data key can doSecrets, SSH keys, API keys themselves, billing, account settings
The buckets your account owns, and where each is visible

A data key used anywhere else (runs, SSH, the compute catalog, sharing) is refused with 403 authz.scope_insufficient, and so is a data:read key on a call that changes a bucket or a file. Within the surfaces it reaches, any key sees exactly what you see: your workspaces, your role in each, and the buckets visible there. A viewer's key can read a bucket or the workspace's files but not change them, and a data key works in every workspace you belong to; you choose the workspace per command (--workspace).

The session key a runtime holds is narrower still: it can create and feed runs in its own workspace, use the buckets visible in its own workspace (read and write, with your role there, so ns cp works in a runtime with no setup), and fetch the session's own secrets. Any other workspace's buckets answer as if they did not exist. It does not reach the Files API: in a runtime, ns://workspace/ is the local ~/workspace folder. It cannot read runs, open SSH, or manage anything, and it is revoked within a minute of the runtime stopping.

Sending a key

curl -H "Authorization: Bearer ns_..." https://api.neuralstudio.co/api/compute/options
curl -H "X-API-Key: ns_..."            https://api.neuralstudio.co/api/compute/options

Either header works; the SDK uses X-API-Key. A key in a URL query string or a request body is refused with 400 and never evaluated. Requests are limited to 200 a minute per identity, and each key is its own identity: a key's requests count apart from your browser session and from your other keys. Over that the API answers 429 with a Retry-After header. Each IP address is also limited at the edge to 2,000 requests in any 5 minutes, whatever key or browser sends them; over that the edge answers the same 429 (ratelimit.exceeded) with Retry-After: 60. The SDK's bucket, workspace-file and run-logging calls, and ns cp / ns sync, wait and retry on their own; your own HTTP calls should wait out Retry-After the same way.

Runtime port hosts (https://<port>-<runtime-id>.run.neuralstudio.co) do not accept API keys; see Web apps on runtime ports for the sign-in they use.

Keeping it safe

  • A key is a password. Keep it in NEURAL_STUDIO_API_KEY or the config file, never in a notebook cell, a repository or an environment spec. On the platform, a token your code needs belongs in Workspace Secrets.
  • Give keys an expiry and a name that says where they live, so revoking the right one is easy.
  • Use a data key for code that only moves data, and a read-only one for code that only reads it.
  • Your keys are deleted with your account.