AI Runtime

LocalApi owns all AI runtime communication. The frontend never calls Ollama, llama.cpp, or provider sidecars directly.

Provider Model

Runtime integration is behind provider contracts. Providers expose:

  • stable id and display name;
  • status and sanitized failure reason;
  • capabilities for health, model listing, setup, start/stop, chat, and embeddings;
  • configured runtime/model paths and base URL;
  • model listing, chat completion, and embedding generation where supported.

llama.cpp is the first implemented provider. The API shape is ready for Ollama or another provider without frontend contract changes.

llama.cpp runs chat and embedding workloads as separate local llama-server processes. Chat model selection applies only to the chat process. It does not change the embedding model, does not reindex documents, and does not touch stored document embeddings.

llama.cpp Process Configuration

LocalApi starts managed llama-server processes with runtime-level settings from the Ai configuration section. Chat uses Ai:ReasoningMode, which defaults to off, and passes it through llama.cpp's native --reasoning flag instead of modifying prompts. Ai:ChatGpuLayers and Ai:EmbeddingGpuLayers control --gpu-layers for the chat and embedding processes. The default value is 999 to request maximum offload; set either value to 0 for a CPU-only fallback on machines with insufficient VRAM.

LocalApi Endpoints

  • GET /api/v1/runtime/providers returns provider visibility and selected-provider metadata.
  • GET /api/v1/runtime/status returns LocalApi readiness, selected provider status, setup requirements, and runtime paths.
  • POST /api/v1/runtime/ai/setup installs or verifies local runtime assets where supported.
  • GET /api/v1/runtime/ai/setup/{setupId}/events streams setup progress as SSE events (progress, completed, failed).
  • POST /api/v1/runtime/ai/start starts the selected provider where supported.
  • GET /api/v1/runtime/models lists available models through the selected provider.
  • GET /api/v1/runtime/chat-models lists chat-only model catalog entries, installation state, checksum validity, and the selected model.
  • POST /api/v1/runtime/chat-models/{id}/download starts an explicit per-model chat model download.
  • GET /api/v1/runtime/chat-models/downloads/{downloadId}/events streams one chat model download as SSE events.
  • POST /api/v1/runtime/chat-models/{id}/select selects a downloaded, checksum-valid chat model. When LocalApi owns the running chat process, only that chat process is restarted.

RAG chat, semantic search, and ingestion embedding generation depend on provider abstractions instead of concrete runtime clients.