Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Models API

Canonical reference: docs/api-reference.md (generated endpoint directory) — this page is a task-oriented summary.

Model listing and provider health endpoints. ZERG aggregates models from local llama.cpp instances and all configured providers, then serves a unified catalog.

Overview

The models API provides read access to the model catalog (provider, context window, capabilities, pricing). There is no provider CRUD — providers are configured declaratively (in sys.config or priv/providers/*.json) and reloaded with the reload endpoint. Provider health is exposed read-only.

Authentication

All endpoints require Authorization: Bearer <token>. The reload endpoint requires admin role.

Endpoints

List Models

GET /api/v1/models

Returns all available models (local + provider), paginated. Local models carry slug/family/quant/size/status/source: "local" plus model_slug/lane/engine for lane rows. Provider models carry id/source: "provider"/canonical_model/provider_model/dispatchable/alias?/provider/context_window/capabilities/pricing/modalities?.

{
  "items": [
    {
      "id": "claude-sonnet-4-20250514",
      "source": "provider",
      "canonical_model": "claude-sonnet-4-20250514",
      "provider_model": "claude-sonnet-4-20250514",
      "dispatchable": true,
      "provider": "anthropic",
      "context_window": 200000,
      "capabilities": { },
      "pricing": { },
      "modalities": ["text", "image"]
    }
  ],
  "total": 1,
  "limit": 50,
  "offset": 0,
  "page": 1,
  "total_pages": 1,
  "has_more": false
}

Get Model Details

GET /api/v1/models/:name

Returns detailed information for a single local model. The response is an explicit projection: non-admin callers get the public field set id (the registry slug), family, quant, size, status and context_window (each only when known) — never paths, config, port or runtime refs. Admin callers get the operator record (sol_registry:show/1 with atom values rendered), including paths, config, port and inference_ref. Unknown names answer 404; store-down is 503 (remote 502), never a blanket 500. Provider-sourced models are listed via the catalog endpoint above.

Provider Health

GET /api/v1/providers/health

Probes every provider transport identity (provider/key/endpoint) concurrently (each probe has a 5s timeout, collective 10s deadline) and returns the cached status (cached for 60 seconds). Models/aliases sharing an identity collapse into one row with a models list; a row with no endpoint is unconfigured and is never probed. SSRF-guarded — endpoints resolving to private/loopback/link-local IPs are rejected. Paginated (items plus the providers mirror).

{
  "items": [
    {"name": "anthropic", "models": ["claude-sonnet-4-20250514"], "endpoint": "https://api.anthropic.com", "path": "/v1/messages", "key_id": "anthropic", "wire": "anthropic", "status": "available", "checked_at_ms": 1760000000000}
  ],
  "total": 1,
  "limit": 50,
  "offset": 0,
  "page": 1,
  "total_pages": 1,
  "has_more": false,
  "providers": [
    {"name": "anthropic", "models": ["claude-sonnet-4-20250514"], "endpoint": "https://api.anthropic.com", "path": "/v1/messages", "key_id": "anthropic", "wire": "anthropic", "status": "available", "checked_at_ms": 1760000000000}
  ]
}

Status values: available (2xx/3xx/404/405/429 — reachable), available_unauthorized (401/403 — reachable, credential problem), degraded (5xx), unavailable (transport/timeout), ssrf_rejected, unconfigured (no endpoint).

Single Provider Health

GET /api/v1/providers/health/:name

Returns the health status for one provider.

{
  "name": "anthropic",
  "models": ["claude-sonnet-4-20250514"],
  "endpoint": "https://api.anthropic.com",
  "path": "/v1/messages",
  "key_id": "anthropic",
  "wire": "anthropic",
  "status": "available",
  "checked_at_ms": 1760000000000
}

404 with the Zerg envelope {"ok":false,"error":{"code":"provider_not_found","message":"<name>"}} if the provider is not registered.

Reload Providers

POST /api/v1/providers/reload

Admin only. Re-reads the declarative provider JSON files (priv/providers/*.json) and re-registers their models without a restart.

Error Codes:

CodeDescription
401Authentication required
403Admin role required for reload
404Model or provider not found
503Provider health cache not ready

Examples:

curl http://127.0.0.1:21434/api/v1/models \
  -H "Authorization: Bearer $TOKEN"

curl http://127.0.0.1:21434/api/v1/providers/health/anthropic \
  -H "Authorization: Bearer $TOKEN"

curl -X POST http://127.0.0.1:21434/api/v1/providers/reload \
  -H "Authorization: Bearer $TOKEN"