Part A — Multimodal
Three Delphi-friendly clients over the OpenAI HTTP API, deliberately dependency-light: primitives in,
strings out or written to a file path you supply.
TVisionClient.Describe(imagePath, prompt) — image question-answering and structured extraction. This is the "read this scanned document" workhorse.
TSpeechClient.Transcribe(audioPath, model) — speech to text via Whisper.
TSpeechClient.Synthesize(text, outputPath, model, voice) — text to speech, written straight to a file.
TImageClient.Generate(prompt, outputPath) — image generation, handling both base64 and URL responses.
Endpoint override for gateways, Azure and OpenAI-compatible servers.
Part B — Local LLMs, offline and free per call
The useful realisation is that the chat pack already runs local models. Ollama and Foundry Local
expose an OpenAI-compatible API, so pointing Connect's chat client at the local
server needs no new code and keeps the full resilience and telemetry pipeline:
LocalChat.dpr
// Local Llama via Ollama (http://localhost:11434), OpenAI-compatible:
Client := TChatClient.Create('openai', 'ollama', 'llama3.1');
Client.Endpoint := 'http://localhost:11434/v1';
Writeln(Client.Complete('You are concise.', 'Explain Delphi in one sentence.'));
On the roadmap
- Azure OpenAI auth (api-key and deployment routing) and Anthropic vision.
- Streaming transcription, word timestamps and translations.
- Offline PDF and document text extraction, pairing naturally with vision for "read this document".
- Image edits, variations and inpainting.
- A thin
TLocalChat convenience wrapper, and in-process local inference via ONNX Runtime GenAI (Phi, Llama) for a no-server option.
Deployment notes
- Audio and image generation produce files: the facade writes to a path your Delphi code supplies, which is the cleanest thing to pass across the bridge.
- Local inference via Ollama needs that server installed and running; the planned in-process ONNX GenAI route is x64-only, the same constraint as AI4Delphi Predict.
- Vision and audio calls carry larger payloads — worth watching with Connect's cost and latency telemetry.
- Requires Core: .Net 8+ or Framework: .NET Framework 4.5 or later, and a dotNetCore4Delphi licence (Core edition) or a .Net Runtime Library for Delphi licence (Framework edition).