Introduction
The RCLI C API provides a unified interface for integrating on-device voice AI into your applications. It combines speech-to-text, large language models, text-to-speech, and tool calling into a single pipeline optimized for Apple Silicon.The C API is designed as a bridging layer for Swift (macOS/iOS), Python, and other languages that can call C functions.
Architecture
Key Features
- Live voice pipeline: Continuous mic → STT → LLM → TTS → speaker loop
- Push-to-talk: Capture audio, then transcribe with offline Whisper
- Text commands: Direct LLM processing without STT
- Tool calling: 43+ macOS actions (AppleScript, system control)
- RAG: Document ingestion and hybrid retrieval (vector + BM25)
- File mode: Process WAV files (iOS, testing)
- Benchmarks: Comprehensive performance testing
Handle Management
All API functions operate on an opaqueRCLIHandle:
Thread Safety
The RCLI engine uses internal mutexes for state management:- Safe to call from multiple threads
- Callbacks fire on worker threads - marshal to UI thread if needed
rcli_stop_processing()is specifically designed for cross-thread cancellation
Memory Management
String ownership rules:- Strings returned by the API (e.g.,
rcli_process_command(),rcli_get_transcript()) are owned by the engine - Do NOT call
free()on returned strings - Strings remain valid until the next call to the same function or until
rcli_destroy() - Exception:
rcli_get_timings()returns amalloc’d string that you mustfree()
Configuration
Pass optional JSON config torcli_create():
Custom system prompt for the LLM. Defaults to built-in RCLI prompt.
Number of LLM layers to offload to GPU. Use
99 for all layers, 0 for CPU-only.LLM context window size in tokens. Default: 4096.
Pipeline States
The pipeline transitions through these states:| State | Value | Description |
|---|---|---|
IDLE | 0 | Not processing |
LISTENING | 1 | Capturing microphone input |
PROCESSING | 2 | Running LLM inference |
SPEAKING | 3 | Playing TTS audio |
INTERRUPTED | 4 | Processing was cancelled |
rcli_get_state() or register a callback with rcli_set_state_callback().
Use Cases
macOS/iOS Swift Integration
Python Bindings
Voice Assistant
File Processing (iOS)
Next Steps
Lifecycle
Initialize and manage the engine
Voice Pipeline
Live voice, push-to-talk, and TTS
Callbacks
Real-time events and state changes
Actions
Execute macOS actions and tools