Skip to main content

Administration: models and engines

Model routes and decision engines. Administrators only.

OperationMethod and path
List model routesGET /api/v1/admin/routes
Export the routes as models.tomlGET /api/v1/admin/routes/export
Create or replace a model routePUT /api/v1/admin/routes/{name}
Delete a model routeDELETE /api/v1/admin/routes/{name}
Test a model routePOST /api/v1/admin/routes/{name}/probe
List decision enginesGET /api/v1/admin/decision/engines
Create or replace a decision enginePUT /api/v1/admin/decision/engines/{name}
Delete a decision engineDELETE /api/v1/admin/decision/engines/{name}
List a model route's upstream modelsGET /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

StatusMeaningBody
200The routesAdminRoutes
401Authentication requiredError
403Not an administratorError
503Database unavailable or gateway restartingError

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

StatusMeaningBody
200models.tomlstring (application/toml)
401Authentication requiredError
403Not an administratorError
503Database unavailable or gateway restartingError

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

NameInRequiredTypeDescription
namepathyesstringThe 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-KeyheaderstringA retried write with the same key replays the stored response before the version check.

Request body

application/json: AdminRouteWrite

Responses

StatusMeaningBody
200ReplacedAdminRoute
201CreatedAdminRoute
400Invalid name, route field, display name, version or body (see details)Error
401Authentication requiredError
403Not an administratorError
409conflict (stale, missing or unexpected version)Error
422The Idempotency-Key was used with another requestError
503Database unavailable or gateway restartingError

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

NameInRequiredTypeDescription
namepathyesstringThe 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.
versionqueryyesinteger 1 or more
Idempotency-KeyheaderstringA retried write with the same key replays the stored response before the version check.

Responses

StatusMeaningBody
204Deleted
400Invalid name, version or parameter (see details)Error
401Authentication requiredError
403Not an administratorError
404No such routeError
409conflict (stale or missing version) or route_is_fallback (another route lists it as a fallback)Error
422The Idempotency-Key was used with another requestError
503Database unavailable or gateway restartingError

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

NameInRequiredTypeDescription
namepathyesstringThe route name.
Idempotency-KeyheaderyesstringRequired. A retry with the same key returns the stored result and does not probe again.

Responses

StatusMeaningBody
200The probe ran; its observation, passing or notRouteProbeResult
400A missing or malformed Idempotency-KeyError
401Authentication requiredError
403Not an administratorError
404No such routeError
409key_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
422The Idempotency-Key was used with another requestError
429rate_limited: a probe of this route in the last 30 seconds, or 10 by this administrator in the last minuteError
503Database unavailable or gateway restartingError
504The probe exceeded its 60-second boundError

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

StatusMeaningBody
200The enginesAdminDecisionEngines
401Authentication requiredError
403Not an administratorError
503Database unavailable or gateway restartingError

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

NameInRequiredTypeDescription
namepathyesstringThe engine name: a lower-case letter, then lower-case letters, digits, - or _; it names the relay path and the usage key decision:<name>.
Idempotency-KeyheaderstringA retried write with the same key replays the stored response before the version check.

Request body

application/json: AdminDecisionEngineWrite

Responses

StatusMeaningBody
200ReplacedAdminDecisionEngine
201CreatedAdminDecisionEngine
400Invalid name, engine field, version or body (see details)Error
401Authentication requiredError
403Not an administratorError
409conflict (stale, missing or unexpected version), decision_engine_limit, or the secret does not allow the engineError
422The Idempotency-Key was used with another requestError
503Database unavailable or gateway restartingError

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

NameInRequiredTypeDescription
namepathyesstringThe engine name: a lower-case letter, then lower-case letters, digits, - or _; it names the relay path and the usage key decision:<name>.
versionqueryyesinteger 1 or more
Idempotency-KeyheaderstringA retried write with the same key replays the stored response before the version check.

Responses

StatusMeaningBody
204Deleted
400Invalid name, version or parameter (see details)Error
401Authentication requiredError
403Not an administratorError
404No such engineError
409conflict (stale version) or decision_engine_in_use (see in_use)Error
422The Idempotency-Key was used with another requestError
503Database unavailable or gateway restartingError

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

NameInRequiredTypeDescription
namepathyesstringThe route name.

Responses

StatusMeaningBody
200The listing ran; the models, or the endpoint's refusal in failureRouteModels
401Authentication requiredError
403Not an administratorError
404No such routeError
409key_missing (the route's secret has no value) or models_running (a listing of this route is in flight)Error
429rate_limited: a listing of this route in the last 30 seconds, or 10 by this administrator in the last minuteError
503Database unavailable or gateway restartingError
504The probe exceeded its 60-second boundError