Documentation

API Overview

API Overview
View .mdOpenAPI

Authentication

A program authenticates with an API key, sent as a bearer token: the recommended credential, and the one every example in this reference uses. A key belongs to one workspace and holds the scopes you gave it; it does not end when a browser session ends. Three other credentials exist beside it, each for its own kind of caller.

Status. Written on 2026-11-14 from the token calls as they run on this service; the credential table and the read rule for self-inspection were corrected on 2026-11-16.

Credentials

CredentialForHow it is sentWhat it may do
API key, weights_…Programs, scripts and agentsAuthorization: Bearer $WEIGHTS_API_KEYThe key's own scopes, in its one workspace. A key issued by a person with the member role acts with read and submit at most.
OIDC bearer tokenA service that signs in through this deployment's identity issuer, where one is configuredAuthorization: Bearer <token>What the issuer's token maps to here. Without a configured issuer, a bearer that is not an API key answers 401 invalid_token.
Browser sessionA person signed in to the panelThe session cookie; every call that changes something also needs X-CSRF-Token, else 403 csrf_requiredThe person's role in the selected workspace: owners and admins every scope, members read and submit.
Worker credentialsA computer you enrolled to serve your own model (Bring your own model)A single-use wjt_ join token once, then the worker's own key and short-lived certificateEnroll, renew its certificate and serve calls. They open none of the calls in this reference, and an API key cannot stand in for them.

Bearer tokens

text
Authorization: Bearer $WEIGHTS_API_KEY

Make a key on your panel under API tokens, or from code with a manage key (POST /v1/tokens). The key is shown once, in that answer only; lists show its prefix. A call without a working credential is refused:

StatusCodeMeaning
401unauthorizedNo Authorization header; the answer carries WWW-Authenticate: Bearer.
401invalid_tokenThe header holds no key of this service.
401token_revoked, token_expiredThe key was revoked, or its expires_at has passed.
403scope_requiredThe key lacks the call's scope; required and granted say which.
403workspace_role_requiredThe call also needs a role in the workspace that the key's issuer does not hold, as the owner for POST /v1/credit/topups.
403account_suspendedThe account is suspended.

Scopes

Each call needs one scope, named on its reference page and as x-required-scope in /openapi.json. A few calls check the issuer's role in the workspace as well; their pages say so.

ScopeLets the key
readRead models, quotes, jobs, results, logs, usage, exports, datasets, plans and endpoints, and check itself with GET /v1/tokens/self.
submitSend work: classify, batches, datasets, training jobs, compute plans and packs, LLM endpoints and chat; cancel a job; make the model ready.
manageMake, list and revoke keys; trace destinations and content logging; register a workspace; rename an endpoint; open a prepaid payment page (the workspace owner's keys only).

A new key gets submit and read unless you ask for other scopes, and a key can only make keys with scopes it holds itself (403 scope_escalation). Give each program the narrowest key it needs: a batch runner needs submit and read, a dashboard read alone.

Workspaces

A key belongs to the workspace it was made in, and everything it reads or makes is that workspace's: its jobs, datasets, endpoints, usage and credit. An id of another workspace answers 404, so a key cannot learn what other workspaces hold. Switching workspace in the browser does not move a key. Removing a person from a workspace, or changing their role, revokes the keys they issued there and the keys made from those keys. GET /v1/workspaces answers the key's own workspace.

Check a key

A key that holds read can read itself: its scopes, expiry, spend cap, request rate and workspace. A key with only submit or manage answers 403 scope_required here, so give a program that must identify itself the read scope.

sh
curl -s https://weights.fyi/run/v1/tokens/self -H "Authorization: Bearer $WEIGHTS_API_KEY"
json
{
  "token": {
    "id": 2,
    "name": "batch runner",
    "scopes": ["submit", "read"],
    "expires_at": null,
    "revoked_at": null,
    "daily_cap_usd_micros": 25000000,
    "rate_limit": {"requests_per_second": 1.3125, "burst": 28}
  },
  "account": {"id": 7}
}

Rotate a key

  1. Make the new key with the same scopes, expiry and spend cap (POST /v1/tokens), or on your panel.
  2. Put it where your program reads WEIGHTS_API_KEY, and restart or reload the program.
  3. Confirm the program uses it: the old key's last_used_at on GET /v1/tokens stops moving.
  4. Revoke the old key (DELETE /v1/tokens/{token_id}). Revoking is final: the key answers 401 token_revoked from then on.
sh
curl -s https://weights.fyi/run/v1/tokens \
  -H "Authorization: Bearer $WEIGHTS_API_KEY" -H "Content-Type: application/json" \
  -d '{"name": "batch runner 2026-11", "scopes": ["submit", "read"], "daily_cap_usd": "25"}'
curl -s -X DELETE https://weights.fyi/run/v1/tokens/OLD_TOKEN_ID -H "Authorization: Bearer $WEIGHTS_API_KEY"

Making a key takes no Idempotency-Key: a retry after a lost answer makes a second key, so revoke the one you do not keep.

Keep keys out of code

Load the key from the environment or your secret store, never from source code, a URL or a log line:

sh
export WEIGHTS_API_KEY="$(cat ~/.config/weights/api-key)"   # or read it from your secret store
python
import os

key = os.environ["WEIGHTS_API_KEY"]   # a KeyError when it is missing, not a call without a key
js
const key = process.env.WEIGHTS_API_KEY;
if (!key) throw new Error("WEIGHTS_API_KEY is not set");

Keep .env files out of version control. If a key leaks, revoke it at once and make a new one.