Local API
The Local API is an optional loopback HTTP service that lets local client tools use Fluid's speech recognition, text post-processing, transcription history, and speech vocabulary features. It keeps requests on the same Mac and maps each request to the app's existing services rather than creating a separate processing path.
Service boundary
Loopback server
The server listens only for connections from localhost, 127.0.0.1, or ::1. This makes the API a local integration boundary for tools on the same machine instead of a network service for remote clients. The service is disabled unless the user enables it, and it uses port 47733 by default when no valid port is configured. The app starts it during launch and stops it during termination.
Each connection carries one HTTP request and receives one response before the connection closes. The server reads the request headers and body, rejects requests larger than 500 MB, and returns JSON error bodies for malformed requests or service failures.
References: Sources/…/LocalAPIServer.swift• L4-14 Sources/…/LocalAPIServer.swift• L16-70 Sources/…/LocalAPIServer.swift• L73-110 Sources/…/LocalAPIServer.swift• L135-193 Sources/…/LocalAPIModels.swift• L3-24 Sources/…/AppDelegate.swift• L42-45 Sources/…/AppDelegate.swift• L75-80
Request and response model
The API normalizes an incoming HTTP request into a small internal model. The model carries the method, path, query values, lower-case headers, and body. Controllers return a status, headers, and body through the matching response model. JSON output uses ISO 8601 dates and a stable key order, which gives local clients a predictable data format.
The router distinguishes an unknown path from a known path with an unsupported method. These cases return 404 and 405 respectively. Controller and decoding errors normally return 400, while a failure to load local custom-word data returns 500.
References: Sources/…/LocalAPIModels.swift• L26-95 Sources/…/LocalAPIServer.swift• L201-283 Sources/…/LocalAPIRouter.swift• L28-42
Route surface
Endpoint map
The router exposes a small versioned surface. Health checks confirm that the service is available. Inference routes perform recognition or post-processing. History and dictionary routes expose local user data and settings.
| Method | Path | Purpose |
|---|---|---|
GET | /v1/health | Return service status and app version. |
POST | /v1/transcribe | Decode audio and return recognized text. |
POST | /v1/postprocess | Apply configured dictation text processing. |
GET | /v1/history | Return recent transcription history. |
GET | /v1/dictionary/replacements | Return custom replacement rules. |
POST | /v1/dictionary/replacements | Add or replace custom replacement rules. |
GET | /v1/dictionary/custom-words | Return user speech boost terms. |
POST | /v1/dictionary/custom-words | Add or replace user speech boost terms. |
References: Sources/…/LocalAPIRouter.swift• L11-26 Sources/…/LocalAPIRouter.swift• L45-58
Inference requests
Audio decoding
The transcribe route accepts either a path to a readable local audio file or audio bytes supplied by the client. JSON requests can name a file with path, or carry Base64 data in audioBase64 with an optional filename. A non-JSON request sends the audio bytes as the body and can use X-Filename to identify the file type. The decoder uses the file extension to help AVFoundation read byte-backed audio.
Sample-based recognition receives mono audio at 16 kHz. The decoder reads long files in chunks of up to 20 minutes, so the chunk size is a processing boundary rather than a five-minute request limit. Byte-backed audio uses a temporary file only for decoding and removes that file after the request. A JSON path request can use the speech provider's native file path when that provider supports it; otherwise the server converts the file to samples first.
References: Sources/…/LocalAPIAudioDecoder.swift• L4-39 Sources/…/LocalAPIAudioDecoder.swift• L41-58 Sources/…/LocalAPIAudioDecoder.swift• L69-83 Sources/…/InferenceAPIController.swift• L5-9 Sources/…/InferenceAPIController.swift• L72-83 Sources/…/InferenceAPIController.swift• L101-135 Sources/…/ASRService.swift• L2671-2703
Transcription flow
The transcription route sends decoded audio to the app's selected speech recognition service. The service prepares the model when needed, recognizes the audio, and applies the same cleanup used by the app's API transcription path. That cleanup includes filler-word removal, spoken-punctuation formatting, and custom dictionary correction.
The response gives the recognized text with its confidence, the number of normalized samples, and the selected speech provider. Empty sample input is valid and produces empty text with zero confidence. Short sample input is padded to at least one second before recognition so local clients do not need to add silence themselves.
References: Sources/…/InferenceAPIController.swift• L28-69 Sources/…/ASRService.swift• L2634-2668 Sources/…/ASRService.swift• L2671-2765
Text post-processing
The postprocess route accepts text as JSON with a required text field or as a UTF-8 body. It passes the text to the configured dictation post-processing service. That service resolves the active provider and model and can use either a configured remote provider or the app's private local AI path.
The response contains the processed text plus the provider and model that produced it. Blank input returns blank text without running provider work. Missing provider, model, API key, invalid JSON, and invalid text encoding become client-visible errors.
References: Sources/…/InferenceAPIController.swift• L22-26 Sources/…/InferenceAPIController.swift• L85-99 Sources/…/InferenceAPIController.swift• L137-156 Sources/…/DictationPostProcessingService.swift• L135-169 Sources/…/DictationPostProcessingService.swift• L171-215
Local data controllers
History controller
The history route gives local clients a read-only view of recent dictation results. It waits for the history store to finish loading before it reads entries. If the store cannot load, the route returns 503 and tells the client to retry from History in FluidVoice. When the store is ready, the controller reads entries in newest-first order and applies the optional limit query value. The limit defaults to 100 and is clamped to the range 1 through 1000.
Each item includes its identifier and time, raw and processed text, the target app and window, character count, AI-processing state, transcription and AI timing when available, token rate when available, and any AI error. The response also includes the number of items returned. It does not expose a write or delete operation through this API.
References: Sources/…/HistoryAPIController.swift• L3-24 Sources/…/HistoryAPIController.swift• L26-59 Sources/…/LocalAPIModels.swift• L89-94 Sources/…/TranscriptionHistoryStore.swift• L13-27 Sources/…/TranscriptionHistoryStore.swift• L183-220
Dictionary controller
The dictionary routes let local clients manage two forms of speech personalization. Replacement rules map one or more trigger phrases to corrected output. Custom words are recognition boost terms with optional weights and aliases.
Both resources support GET and POST. A write can send an entries array or one entry in the top-level fields. The default append mode preserves existing entries while replacing matching items. The replace mode starts from an empty set. Invalid or empty values are skipped or rejected according to the resource's validation rules.
Replacement writes update the stored custom dictionary and invalidate the recognition dictionary cache. Custom-word writes update the vocabulary store. Both writes notify the recognition system so later transcription can use the new terms.
References: Sources/…/DictionaryAPIController.swift• L3-18 Sources/…/DictionaryAPIController.swift• L44-107 Sources/…/DictionaryAPIController.swift• L109-190 Sources/…/DictionaryAPIController.swift• L194-239 Sources/…/SettingsStore.swift• L4439-4468 Sources/…/ParakeetVocabularyStore.swift• L143-174
Personalization relationship
The two dictionary resources affect different stages of the speech path. Replacement rules correct recognized text after speech recognition. Custom words guide the vocabulary used by the recognition engine. The API therefore gives local tools separate control over output correction and recognition hints without exposing the full settings store.
References: Sources/…/ASRService.swift• L2664-2667 Sources/…/ASRService.swift• L2741-2744 Sources/…/ParakeetVocabularyStore.swift• L180-209 Sources/…/FluidAudioProvider.swift• L475
Client flow
The common client flow starts with a local health check, sends audio or text to the matching inference route, and optionally reads history or changes vocabulary settings. The following diagram shows how request data moves through the server and into the shared app services.
flowchart LR
Client[Local client] -->|loopback HTTP| Server[Local API server]
Server --> Router[Versioned router]
Router --> Decode[Request and audio decoding]
Decode --> ASR[Speech recognition service]
Router --> Post[Dictation post-processing]
Router --> History[Transcription history]
Router --> Dictionary[Replacement and vocabulary stores]
ASR --> Transcription[Text response]
Post --> Processed[Processed text response]
History --> HistoryResponse[History response]
Dictionary --> DictionaryResponse[Dictionary response]
References: Sources/…/LocalAPIServer.swift• L33-67 Sources/…/LocalAPIRouter.swift• L11-42 Sources/…/InferenceAPIController.swift• L43-99 Sources/…/HistoryAPIController.swift• L26-59 Sources/…/DictionaryAPIController.swift• L109-190
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the route table, controller method checks, and client-facing endpoint documentation aligned when a path or HTTP method changes.
- Keep audio extension handling aligned across JSON
filename,X-Filename, temporary files, and AVFoundation decoding. - Preserve the 16 kHz sample contract and the 20-minute chunk boundary when changing audio conversion or provider input rules.
- Keep response field names aligned with the history entry model and the ISO 8601 date encoder.
- Preserve the history store's load wait and
503response when changing history startup or persistence behavior. - When changing dictionary write behavior, preserve cache invalidation and vocabulary-change notification so new terms reach later recognition requests.
- Treat loopback filtering and the opt-in server setting as one security boundary when changing listener startup or connection handling.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| The Local API setting is disabled or the configured port is invalid | No listener starts, so local clients cannot connect | Enable the service and use a valid port; the server falls back to the default port for invalid values. |
| A client connects from a non-loopback address | The connection is cancelled without routing the request | Keep clients on localhost, 127.0.0.1, or ::1. |
| The body exceeds 500 MB | The request fails with a client-visible 413 error | Keep uploads below the request size limit. |
JSON omits both path and audioBase64, or a raw request has an empty body | No audio is available for transcription | Send one supported audio form and use a valid content type. |
| Audio cannot be read or decoded | Transcription returns a 400 error | Use a readable file or an audio format that AVFoundation can decode. |
| The selected speech provider or model is not ready | Inference fails instead of returning a partial result | Allow model preparation to complete and keep a usable provider selected. |
| Post-processing has no verified provider, model, or required remote key | Text post-processing returns an error | Configure the selected provider and its required credentials. |
| History storage is still unavailable or fails to load | GET /v1/history returns 503 instead of partial history | Wait for the history store to load, then retry from the local client. |
| A dictionary write fails to persist or notify the recognition system | The API may return an error, or later recognition may use stale terms | Keep store writes, cache invalidation, and vocabulary-change notifications in the same write path. |
Key files
| File | Why to read it |
|---|---|
| Sources/…/LocalAPIServer.swift | Shows the loopback listener, HTTP request boundary, connection lifecycle, and response handling. |
| Sources/…/LocalAPIRouter.swift | Shows the complete versioned route surface and method-versus-path errors. |
| Sources/…/LocalAPIModels.swift | Defines the shared request, response, JSON, size-limit, and configuration rules. |
| Sources/…/InferenceAPIController.swift | Explains the client input forms and the two inference operations. |
| Sources/…/LocalAPIAudioDecoder.swift | Defines audio normalization, temporary-file handling, and chunk processing. |
| Sources/…/HistoryAPIController.swift | Shows history loading, the read-only history contract, and the fields exposed to local clients. |
| Sources/…/DictionaryAPIController.swift | Shows dictionary and custom-word reads, writes, and update modes. |
| Sources/…/ASRService.swift | Shows how API audio reaches recognition and receives shared text cleanup. |
| Sources/…/DictationPostProcessingService.swift | Shows how API text uses the configured post-processing provider and model. |
| Sources/…/TranscriptionHistoryStore.swift | Defines the history data represented by the API. |
| Sources/…/ParakeetVocabularyStore.swift | Defines persistence for recognition boost terms. |
| Sources/…/AppDelegate.swift | Shows when the server starts and stops in the app lifecycle. |
The broader interface group is described in External interfaces. The related meeting workflow is described in Meeting transcription. History storage and backups are described in Transcription history and backups. Dictionary training is described in Custom dictionary training.