Lazarus Local LLM Wrapper
↗https://github.com/Benjimen1966/Lazarus-Free-Pascal-Local-LLM-wrapper
Licence: MIT, © 2026 Benjimen Chan
A demo for ↗Lazarus/FreePascal showing how to connect your desktop application to local Large Language Models (LLMs) via ↗Ollama and ↗LM Studio. This example demonstrates that AI integrations can be implemented in FreePascal - without Python, Node.js, or external runtimes.
Ollama endpoint: http://localhost:11434/api/chat
LM Studio endpoint: http://localhost:1234/v1/chat/completions
The wrapper uses FreePascal's built-in ↗fpHttpClient to make plain HTTP/JSON requests. Requests run in an application's background thread (TLocalLLMThread) so the UI stays responsive, and responses are parsed with ↗fpJson.
Example JSON request body:
{
"model": "llama3.1",
"messages": [
{ "role": "user", "content": "Hello, who are you?" }
],
"stream": false
}
Multi-turn conversation history is kept client-side and re-sent with each request, since neither server maintains conversation state between calls.