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

Inference API

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

Sol manages LLM inference instances through a provider adapter system. It supports local llama.cpp inference and 14 provider adapters with a unified API surface.

Start Inference

POST /api/v1/start

Start a new inference instance with the specified model. Admin only. The body carries the model name plus optional template and overrides.

curl -X POST https://sol.example.com/api/v1/start \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "glm-5.1",
    "template": "default",
    "overrides": {
      "gpu_layers": 99,
      "ctx_size": 4096,
      "threads": 4
    }
  }'

Response:

{
  "status": "ok",
  "port": 8080,
  "ref": "inference_ref"
}

409 with {"status": "already_running", "port": 8080} if the model is already loaded; 404 if the model is not found. A model still mid-prepare (or never prepared) answers 409 (prepare in progress / model not prepared — call prepare first) — start is synchronous-only against the prepared state; see POST /api/v1/prepare/:name in the canonical reference for the async prepare flow (POST-only; GET answers 405).

Stop Inference

POST /api/v1/stop

Stop a running inference instance. Admin only. Reads a model name (not an instance id).

curl -X POST https://sol.example.com/api/v1/stop \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"model": "glm-5.1"}'

Stop All Instances

POST /api/v1/stop-all

Stop all running inference instances.

List Models

GET /api/v1/models

List all registered models (local llama.cpp + provider), paginated. Local models carry slug/family/quant/size/status/source: "local"; provider models carry id/source: "provider"/provider/ context_window/capabilities/pricing:

curl -H "Authorization: Bearer $TOKEN" \
  https://sol.example.com/api/v1/models

Response:

{
  "items": [
    {
      "id": "glm-5.1",
      "source": "provider",
      "provider": "sol_provider_zai",
      "context_window": 128000,
      "capabilities": {},
      "pricing": {}
    }
  ],
  "total": 1,
  "limit": 50,
  "offset": 0,
  "page": 1,
  "total_pages": 1,
  "has_more": false
}

Model Discovery

POST /api/v1/discover

Scan for available models and register them. Requires admin permissions.

curl -X POST https://sol.example.com/api/v1/discover \
  -H "Authorization: Bearer $TOKEN"

Response:

{
  "discovered": 5
}

Provider Adapters

Sol uses a behaviour-based provider system with 12 adapters (8 of which have circuit breakers registered at boot). Each adapter implements a common interface for listing models, creating completions, and streaming tokens.

Supported Providers

ProviderAdapterCapabilities
Anthropicsol_provider_anthropicMessages API, streaming, vision
OpenAIsol_provider_openaiChat Completions, streaming, function calling
z.aisol_provider_zaiGLM-5.1, streaming, vision
Ollamasol_provider_ollamaLocal models, streaming
Geminisol_provider_geminiGoogle AI, streaming
DeepSeeksol_provider_deepseekChat Completions, streaming
Alibabasol_provider_alibabaQwen models, streaming
Bedrocksol_provider_bedrockAWS Bedrock, streaming
Xiaomisol_provider_xiaomiMiMo models (OpenAI-compatible), streaming
Declarativesol_provider_declarativeConfig-driven adapter for custom endpoints (e.g. MiniMax via priv/providers/01-minimax.json)

The retired OpenAI Responses wire (sol_provider_responses) is a documented refusal since then: declarative configs declaring format: "responses" fail validation and no responses-adapter models are registered. Use the openai or anthropic wire.

See the Provider Setup reference for full configuration details.

Provider Configuration

Providers are configured in sys.config:

{providers, [
  {anthropic, #{api_key => "sk-ant-..."}},
  {openai, #{api_key => "sk-..."}},
  {zai, #{api_key => "..."}},
  {ollama, #{base_url => "http://localhost:11434"}}
]}

Cross-Provider Message Transformation

Sol provides bidirectional message transformation between Anthropic and OpenAI formats:

Anthropic Messages API (/v1/messages) OpenAI Chat Completions API (/v1/chat/completions)

This enables mid-conversation provider switching without format conversion on the client side.

Streaming (SSE)

All inference endpoints support Server-Sent Events streaming:

curl -N https://sol.example.com/v1/chat/completions \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "glm-5.1",
    "messages": [{"role": "user", "content": "Hello"}],
    "stream": true
  }'

SSE event format:

data: {"id":"chatcmpl-123","choices":[{"delta":{"content":"Hello"},"index":0}]}

data: [DONE]

Streaming features:

Heartbeat messages to prevent connection timeouts Token-by-token delivery for real-time display Graceful connection termination on completion or error

Inference Lifecycle

Inference instances use gen_statem for lifecycle management:

stopped -> starting -> ready -> running -> ready
                  \-> failed
StateDescription
stoppedInstance not running
startingModel loading in progress
readyInstance available for requests
runningProcessing a request
failedStartup or runtime error

Inference Configuration

SettingDefaultDescription
inference_bin./llama-serverllama.cpp server binary
inference_gpu_layers99GPU layers to offload
inference_ctx_size4096Context window size
inference_threads4CPU threads

Local Inference (llama.cpp)

Sol manages local llama.cpp inference instances via erlexec:

Automatic process lifecycle (start, monitor, restart) GPU offloading configuration Multiple concurrent instances on different ports Process monitoring using Erlang monitors (not polling)

Local inference is the default. Remote providers serve as fallback when local models are unavailable.