Reference for the REST endpoints that manage keys, providers, chains, guardrails, and usage.
All endpoints below live on the same server as the gateway (default http://localhost:8080) and power the dashboard UI. Great for automation and integrations.
For the inference endpoints, see the Gateway API section.
The dashboard sends its searches, filters and pages to the server; nothing is filtered in the browser. Every parameter is optional, and total in the metadata counts the rows that match before paging. search is case-insensitive.
search (name, key preview or plan), status (active, disabled), sort (newest, oldest, name). The metadata adds total_all, total_active and total_disabled.
GET /v1/chains
search (name, fallback model or a step's provider/model), strategy, enabled (true, false), provider (a step or the fallback uses it), health_window (attaches each chain's health), health (healthy, degraded, down, unknown). Paged only when limit is sent.
GET /v1/aliases
search (name or group), status (active, inactive)
GET /v1/plans
Paged only when limit is sent. The metadata adds keys_assigned, hard_cutoff and unused over every plan.
GET /v1/budgets/status
Ordered closest to the limit first; each row carries scope_name. Paged only when limit is sent. The metadata adds past_alert, exhausted and blocking over every budget.
GET /v1/quota
range, search (provider or account name), provider, status (active, paused, attention), quota_state, sort (attention, name, requests, cost)
range, search (model, key name, client, row id or provider), status (failed). The metadata adds total_all and total_failed.
GET /v1/provider-health
tab (providers, models, chains, probes) returns only that table, status (healthy, degraded, down), offset, limit. counts covers every row and total the rows that match.
GET /v1/providers
search (name or slug), capability, empty (true keeps connected custom providers with no account), offset, limit (page the connected list)
GET /v1/media
capability, search (name or slug). The answer also splits the matches into connected and available.
GET /v1/portal/:token
offset, limit page the request log (recent); recent_total counts the window.
Issue a fresh TOTP secret to enroll (nothing stored yet)
POST
/v1/auth/totp/enable
Turn on two-factor auth; needs password + a code from that secret
POST
/v1/auth/totp/disable
Turn it off; needs password + a current code
GET
/v1/auth/sessions
Active sign-in sessions; current marks the caller's
DELETE
/v1/auth/sessions/:id
Revoke one session; its tokens stop working at once
GET
/v1/auth/passkeys
Your passkeys
POST
/v1/auth/passkeys/register/begin
Start adding a passkey; needs password (+ TOTP)
POST
/v1/auth/passkeys/register/finish
Verify and store the browser's new credential
DELETE
/v1/auth/passkeys/:id
Remove a passkey
POST
/v1/auth/passkey/begin
Public: start a passkey sign-in
POST
/v1/auth/passkey/finish
Public: verify the passkey, receive tokens
Passkey calls read the Origin header: the passkey's RP ID is that origin's host, so the dashboard must be on https or http://localhost, under a host name (not an IP), and a passkey works only on the host it was added on. Each begin returns ceremony_id and options (WebAuthn JSON for PublicKeyCredential.parseCreationOptionsFromJSON / parseRequestOptionsFromJSON); send finish the same ceremony_id and credential (the browser's credential.toJSON()) within 5 minutes. A passkey sign-in skips the password and TOTP code.
The playground authenticates with the dashboard JWT, not an API key. Its usage is metered and budgeted like any other traffic but attributed to no key. Responses carry X-TeraRouter-Provider and X-TeraRouter-Model, naming the target the request landed on.
Delete {"ids": [...]}; providers that still have an account are skipped
GET / PATCH
/v1/custom-providers/:id/models
Stored model catalog (search, state, offset, limit) / toggle models active or disabled
POST
/v1/custom-providers/:id/models/sync
Fetch the catalog from the provider's upstream model list
POST
/v1/custom-providers/:id/models/test
Send one test chat to a model
GET / PATCH
/v1/providers/:id/models
Same catalog view for catalog providers (:id is the slug)
POST
/v1/providers/:id/models/sync
Refresh a catalog provider's models
POST
/v1/providers/:id/models/test
Send one test chat to a model
GET / POST
/v1/accounts
List / add accounts
POST
/v1/accounts/bulk
Add one API-key account per entry of api_keys; keys already stored are returned as skipped
GET / PATCH / DELETE
/v1/accounts/:id
Manage account
POST
/v1/accounts/:id/test
Test account connection
POST
/v1/accounts/test
Test a key before saving it; nothing is stored
GET
/v1/accounts/:id/quota
Account quota
GET / PUT
/v1/providers/:id/routing
Account strategy (:id is the provider slug)
POST
/v1/providers/:id/accounts/export
Download the provider's accounts as a file encrypted with passphrase (:id is the slug)
POST
/v1/providers/:id/accounts/import
Add the accounts of an export file ({"passphrase", "backup"}); duplicates are skipped
POST
/v1/oauth/:provider/authorize
Start a PKCE sign-in (anthropic, codex); returns the URL to open
POST
/v1/oauth/:provider/exchange
Exchange the returned code and save it as an OAuth account
The model test endpoints take {"model", "messages", "stream"}. With "stream": true the answer is server-sent events: {"type": "delta", "text": …} per text fragment, then one {"type": "done", "result": …} carrying the same result the non-streaming call returns. A streamed test is capped at 2 minutes.
Batch import {"pools": [...]}, all or nothing (max 500)
POST
/v1/proxy-pools/bulk-delete
Delete {"ids": [...]}, skipping ones already gone
POST
/v1/proxy-pools/relay-script
Generate a relay script ({"kind": "cloudflare"} or "local")
POST
/v1/proxy-pools/health-check
Check all pools
PATCH / DELETE
/v1/proxy-pools/:id
Edit / delete pool
POST
/v1/proxy-pools/:id/test
Test one pool
A pool URL is normally an HTTP/HTTPS/SOCKS forward proxy. A URL of the form relay+https://:<secret>@host is a fetch relay instead: the gateway sends each upstream call to the relay with the real target in X-Tera-Relay-Target and the secret in X-Tera-Relay-Secret. The relay-script endpoint returns a ready-to-deploy Cloudflare Worker or Node script with a fresh secret, plus the pool URL to register (replace RELAY_HOST).
Body: enabled, start_date / end_date (YYYY-MM-DD, inclusive), start_time / end_time (HH:MM, repeats daily, may wrap past midnight), timezone (IANA, empty means UTC) and allowed_ips (addresses or CIDR ranges). Empty dates or times leave that side open. While the period is running, every path except /health answers 403 forbidden to addresses off the list; loopback always passes. Enabling it without your own address on the list is refused.
Restore a config backup; each table in it replaces the live one
GET
/v1/backup/database
Live database file info
POST
/v1/backup/database/download
SQLite snapshot; needs password (+ TOTP)
POST
/v1/backup/database/restore
Replace the database with an uploaded SQLite file (multipart field file); needs password (+ TOTP)
POST
/v1/import/:source
Import a 9router or omniroute JSON backup
Both restores write a safety copy of the current database first. A restored database must pass an integrity check and carry a schema no newer than the server's; an older schema is migrated up. The database restore re-authenticates like the download: send the multipart fields password and, once the server answers { "totp_required": true }, otp next to file. It refuses a file with no user accounts, with broken references, or whose credentials were sealed with a different APP_SECRET. Imports are additive: rows that already exist are kept and the backup's copy is skipped, so re-running an import is safe.
Totals, action categories, writes and lost writes since start
POST
/v1/audit/verify
Walk the hash chain and report the first row that does not match
GET
/v1/audit/export
Whole trail as JSON Lines (application/x-ndjson)
GET / DELETE
/v1/console
Ring buffer log (1,000 entries; ?after=<id> returns only newer lines, with metadata.first and metadata.session) / clear
GET
/v1/system/stats
Host & process metrics
GET
/v1/system/status
Gateway status card: status, version, process uptime, listen address, database
GET
/v1/media
Catalog providers grouped by non-chat capability
GET
/v1/endpoints
Base URL and route reference for the Endpoints page
GET
/v1/cli-tools/:id
One tool's install status and a preview of its config files. Query: base_url, model (the key is a placeholder)
POST
/v1/cli-tools/:id/apply
Write the gateway URL, a key and the model into the tool's config files on the host. Body: base_url, model, and key_name (create a dedicated key) or api_key (paste an active key)
GET
/health
Server health (no auth)
GET
/skills/:slug/SKILL.md
Public skill document an agent fetches by URL (no auth)
The key reveal and rotate, both backup downloads, the accounts export, and a PATCH /v1/accounts/:id that changes metadata.base_url re-authenticate: send "password", and when two-factor auth is on the server answers { "totp_required": true } until you resend with "otp". Wrong passwords or codes return 422 and count toward the IP block, like failed sign-ins.