Class LlamaCppServerClient
- All Implemented Interfaces:
com.tnsai.llm.LLMClient
llama-server is the HTTP server binary shipped with the
llama.cpp project.
It exposes an OpenAI-compatible chat-completions endpoint at
http://localhost:8080/v1 by default — same wire format as
every other OpenAI-shape provider in this module. The differences
from cloud providers are operational:
- No API key required by default. llama.cpp's server runs
ungated when self-hosted; the
Authorizationheader is only sent when anapiKeyis explicitly supplied (e.g. whenllama-serveris started with--api-keyor fronted by an auth proxy). - Model = the GGUF file the server loaded. The
--modelflag at server-start determines what's served; probeGET /v1/modelsto discover the identifier and pass it asmodel.
llama.cpp's small footprint makes it the lightest possible LLM server — runs on Raspberry Pi 5-class ARM hardware and Apple Silicon laptops equally well. Pairs naturally with edge-class sandbox profiles where Ollama and vLLM are too heavy.
Configuration via environment variables:
LLAMACPP_BASE_URL— Optional override, defaults tohttp://localhost:8080/v1.LLAMACPP_API_KEY— Optional bearer token for llama-server instances started with--api-keyor behind an auth proxy; omitted by default.
This client follows the OllamaClient / LMStudioClient
/ VLLMClient pattern: it accepts the apiKey parameter
for parity with the other providers but does not call
requireApiKey — passing null is fine for the
self-hosted-default deployment.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionLlamaCppServerClient(String model) LlamaCppServerClient(String model, float temperature) LlamaCppServerClient(String model, float temperature, Float topP, Integer maxTokens) LlamaCppServerClient(String model, float temperature, Integer maxTokens) LlamaCppServerClient(String baseUrl, String model, float temperature, Float topP, Integer maxTokens, String apiKey) LlamaCppServerClient(String baseUrl, String model, float temperature, Integer maxTokens, String apiKey) -
Method Summary
Methods inherited from class com.tnsai.llm.providers.AbstractOpenAICompatibleClient
chat, streamChatMethods inherited from class com.tnsai.llm.providers.AbstractLLMClient
getBaseUrl, getCallTimeoutMs, getMaxTokens, getModel, getTemperature, getTopPMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.tnsai.llm.LLMClient
chat, chat, chat, chat, chat, getCapabilities, getProviderName, listModels, streamChat, streamChat, streamChatWithHandler, streamChatWithHandler, streamChatWithSpec, streamChatWithSpec
-
Constructor Details
-
LlamaCppServerClient
-
LlamaCppServerClient
-
LlamaCppServerClient
-
LlamaCppServerClient
-
LlamaCppServerClient
-
LlamaCppServerClient
-