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
| Provider | Adapter | Capabilities |
|---|---|---|
| Anthropic | sol_provider_anthropic | Messages API, streaming, vision |
| OpenAI | sol_provider_openai | Chat Completions, streaming, function calling |
| z.ai | sol_provider_zai | GLM-5.1, streaming, vision |
| Ollama | sol_provider_ollama | Local models, streaming |
| Gemini | sol_provider_gemini | Google AI, streaming |
| DeepSeek | sol_provider_deepseek | Chat Completions, streaming |
| Alibaba | sol_provider_alibaba | Qwen models, streaming |
| Bedrock | sol_provider_bedrock | AWS Bedrock, streaming |
| Xiaomi | sol_provider_xiaomi | MiMo models (OpenAI-compatible), streaming |
| Declarative | sol_provider_declarative | Config-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 declaringformat: "responses"fail validation and no responses-adapter models are registered. Use theopenaioranthropicwire.
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
| State | Description |
|---|---|
stopped | Instance not running |
starting | Model loading in progress |
ready | Instance available for requests |
running | Processing a request |
failed | Startup or runtime error |
Inference Configuration
| Setting | Default | Description |
|---|---|---|
inference_bin | ./llama-server | llama.cpp server binary |
inference_gpu_layers | 99 | GPU layers to offload |
inference_ctx_size | 4096 | Context window size |
inference_threads | 4 | CPU 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.