Administration: models and engines
Model routes and decision engines. Administrators only.
| Operation | Method and path |
|---|---|
| List model routes | GET /api/v1/admin/routes |
| Export the routes as models.toml | GET /api/v1/admin/routes/export |
| Create or replace a model route | PUT /api/v1/admin/routes/{name} |
| Delete a model route | DELETE /api/v1/admin/routes/{name} |
| Test a model route | POST /api/v1/admin/routes/{name}/probe |
| List decision engines | GET /api/v1/admin/decision/engines |
| Create or replace a decision engine | PUT /api/v1/admin/decision/engines/{name} |
| Delete a decision engine | DELETE /api/v1/admin/decision/engines/{name} |
| List a model route's upstream models | GET /api/v1/admin/routes/{name}/models |
List model routes
GET /api/v1/admin/routes
Every stored route, sorted by name, with its full record and metadata. No credential appears; key_missing says whether key_ref has a value. Administrators only; a session or a personal token.
Sign-in: A signed-in session or an API token.
Responses
| Status | Meaning | Body |
|---|---|---|
| 200 | The routes | AdminRoutes |
| 401 | Authentication required | Error |
| 403 | Not an administrator | Error |
| 503 | Database unavailable or gateway restarting | Error |
Export the routes as models.toml
GET /api/v1/admin/routes/export
The live routes in the models.toml format, which is also the seed and import format. Display names are not part of it. Administrators only; a session or a personal token.
Sign-in: A signed-in session or an API token.
Responses
| Status | Meaning | Body |
|---|---|---|
| 200 | models.toml | string (application/toml) |
| 401 | Authentication required | Error |
| 403 | Not an administrator | Error |
| 503 | Database unavailable or gateway restarting | Error |
Create or replace a model route
PUT /api/v1/admin/routes/{name}
Creates without a version (201) or replaces the version read (200). The whole resulting registry passes the same validator as models.toml, so the file and the API refuse a route for the same reason. A key_ref whose name looks like a key is refused 400 name_key_shaped (the file's is only warned about). Applies from the next request; runs keep their route name. Administrators only; a session or a personal token. Audited without values.
Sign-in: A signed-in session or an API token.
Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
name | path | yes | string | The route name: immutable, because conversations store it; no control characters. new is reserved (the web's Add route page lives at that address): a write naming it is refused with name_reserved on name, and models.toml may not name it either. |
Idempotency-Key | header | string | A retried write with the same key replays the stored response before the version check. |
Request body
application/json: AdminRouteWrite
Responses
| Status | Meaning | Body |
|---|---|---|
| 200 | Replaced | AdminRoute |
| 201 | Created | AdminRoute |
| 400 | Invalid name, route field, display name, version or body (see details) | Error |
| 401 | Authentication required | Error |
| 403 | Not an administrator | Error |
| 409 | conflict (stale, missing or unexpected version) | Error |
| 422 | The Idempotency-Key was used with another request | Error |
| 503 | Database unavailable or gateway restarting | Error |
Delete a model route
DELETE /api/v1/admin/routes/{name}
Deletes the version read. Conversations keep the name, and their next model request fails plainly. A seeded route returns at a later start only if its models.toml entry changes. Administrators only; a session or a personal token. Audited.
Sign-in: A signed-in session or an API token.
Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
name | path | yes | string | The route name: immutable, because conversations store it; no control characters. new is reserved (the web's Add route page lives at that address): a write naming it is refused with name_reserved on name, and models.toml may not name it either. |
version | query | yes | integer 1 or more | |
Idempotency-Key | header | string | A retried write with the same key replays the stored response before the version check. |
Responses
| Status | Meaning | Body |
|---|---|---|
| 204 | Deleted | |
| 400 | Invalid name, version or parameter (see details) | Error |
| 401 | Authentication required | Error |
| 403 | Not an administrator | Error |
| 404 | No such route | Error |
| 409 | conflict (stale or missing version) or route_is_fallback (another route lists it as a fallback) | Error |
| 422 | The Idempotency-Key was used with another request | Error |
| 503 | Database unavailable or gateway restarting | Error |
Test a model route
POST /api/v1/admin/routes/{name}/probe
Tests the stored route the way a runtime will use it, through the relay's own shaping, credential, limiter and decoder: a streamed request with one tool, the tool call, and the round trip with its result, reading usage and reasoning on the way. The request waits for the result: at most 60 seconds, or [relay] local_check_timeout (120 seconds by default) for a local route (no key, or a loopback, localhost or container-host address); running out of time is the probe's timeout result. A failed probe is still a 200: the failure is the observation. The latest result per route is stored; a probe never changes the route or its version. Administrators only; a session or a personal token. Audited (action probe). At most one probe of a route at a time and per 30 seconds, and 10 per administrator per minute.
Sign-in: A signed-in session or an API token.
Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
name | path | yes | string | The route name. |
Idempotency-Key | header | yes | string | Required. A retry with the same key returns the stored result and does not probe again. |
Responses
| Status | Meaning | Body |
|---|---|---|
| 200 | The probe ran; its observation, passing or not | RouteProbeResult |
| 400 | A missing or malformed Idempotency-Key | Error |
| 401 | Authentication required | Error |
| 403 | Not an administrator | Error |
| 404 | No such route | Error |
| 409 | key_missing (the route's secret has no value), probe_running (a probe of this route is in flight) or idempotency_route (the key was used on another path) | Error |
| 422 | The Idempotency-Key was used with another request | Error |
| 429 | rate_limited: a probe of this route in the last 30 seconds, or 10 by this administrator in the last minute | Error |
| 503 | Database unavailable or gateway restarting | Error |
| 504 | The probe exceeded its 60-second bound | Error |
List decision engines
GET /api/v1/admin/decision/engines
Every stored decision engine (ADR-0013 point 6), sorted by name, with its record and metadata. No credential appears: key_ref names a secret, and key_missing says whether it has a value. Administrators only; a session or a personal token.
Sign-in: A signed-in session or an API token.
Responses
| Status | Meaning | Body |
|---|---|---|
| 200 | The engines | AdminDecisionEngines |
| 401 | Authentication required | Error |
| 403 | Not an administrator | Error |
| 503 | Database unavailable or gateway restarting | Error |
Create or replace a decision engine
PUT /api/v1/admin/decision/engines/{name}
Creates without a version (201) or replaces the version read (200). The same validator checks the [[decision_engines]] seed, except that insecure_http and ca_file are file-only (400 file_only). key_ref must name a shared secret that allows the engine, and a key_ref whose name looks like a key is refused 400 name_key_shaped. At most 16 engines (409 decision_engine_limit). Applies from the next request; a live session keeps the exposure it started with, so a narrowed engine's consultations fall back to the model until the conversation's next session. Administrators only; a session or a personal token. Audited without values; a change of exposure is its own audit action (exposure, old->new).
Sign-in: A signed-in session or an API token.
Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
name | path | yes | string | The engine name: a lower-case letter, then lower-case letters, digits, - or _; it names the relay path and the usage key decision:<name>. |
Idempotency-Key | header | string | A retried write with the same key replays the stored response before the version check. |
Request body
application/json: AdminDecisionEngineWrite
Responses
| Status | Meaning | Body |
|---|---|---|
| 200 | Replaced | AdminDecisionEngine |
| 201 | Created | AdminDecisionEngine |
| 400 | Invalid name, engine field, version or body (see details) | Error |
| 401 | Authentication required | Error |
| 403 | Not an administrator | Error |
| 409 | conflict (stale, missing or unexpected version), decision_engine_limit, or the secret does not allow the engine | Error |
| 422 | The Idempotency-Key was used with another request | Error |
| 503 | Database unavailable or gateway restarting | Error |
Delete a decision engine
DELETE /api/v1/admin/decision/engines/{name}
Deletes the version read, unless a profile or an active conversation names the engine (409 decision_engine_in_use, see in_use; disable it instead). A seeded engine returns at a later start only if its [[decision_engines]] entry changes. Its secret binding goes with it. Administrators only; a session or a personal token. Audited.
Sign-in: A signed-in session or an API token.
Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
name | path | yes | string | The engine name: a lower-case letter, then lower-case letters, digits, - or _; it names the relay path and the usage key decision:<name>. |
version | query | yes | integer 1 or more | |
Idempotency-Key | header | string | A retried write with the same key replays the stored response before the version check. |
Responses
| Status | Meaning | Body |
|---|---|---|
| 204 | Deleted | |
| 400 | Invalid name, version or parameter (see details) | Error |
| 401 | Authentication required | Error |
| 403 | Not an administrator | Error |
| 404 | No such engine | Error |
| 409 | conflict (stale version) or decision_engine_in_use (see in_use) | Error |
| 422 | The Idempotency-Key was used with another request | Error |
| 503 | Database unavailable or gateway restarting | Error |
List a model route's upstream models
GET /api/v1/admin/routes/{name}/models
Lists the models the route's endpoint offers, with the route's stored credential, which never leaves the gateway: GET {base_url}/models with the route's authentication and headers (a Messages endpoint's pages are followed), no redirects. Only ids and display names are kept, at most 500. A refusal by the endpoint is still a 200: failure names it as the route probe does, with a redacted excerpt. Nothing is stored and the route never changes. Administrators only; a session or a personal token. Audited (action list_models). At most one listing of a route at a time and per 30 seconds, and 10 per administrator per minute.
Sign-in: A signed-in session or an API token.
Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
name | path | yes | string | The route name. |
Responses
| Status | Meaning | Body |
|---|---|---|
| 200 | The listing ran; the models, or the endpoint's refusal in failure | RouteModels |
| 401 | Authentication required | Error |
| 403 | Not an administrator | Error |
| 404 | No such route | Error |
| 409 | key_missing (the route's secret has no value) or models_running (a listing of this route is in flight) | Error |
| 429 | rate_limited: a listing of this route in the last 30 seconds, or 10 by this administrator in the last minute | Error |
| 503 | Database unavailable or gateway restarting | Error |
| 504 | The probe exceeded its 60-second bound | Error |