AI 0.5.0: Text-to-speech through your AI endpoints
AI 0.5.0 adds text-to-speech. Code in your app can now send text to a configured AI endpoint and get audio back, with the request logged like any other AI call.
Speech from text
The new function is PhoenixKitAI.speak(endpoint_uuid, text, opts). It uses the same endpoint lookup and checks as completions and embeddings, posts the text to the provider’s /audio/speech address and returns the audio as bytes together with its format. The format defaults to mp3 and can be changed with :response_format. A voice can be passed as :voice for a preset name or :voice_id for a saved or cloned voice; only the one given is sent.
Providers answer in two ways, and both are understood: Mistral returns the audio as base64 inside JSON, while OpenRouter and self-hosted vLLM servers return the audio file directly. An answer with no usable audio returns an error, The TTS provider returned an unreadable audio response.
Logged like other requests
Each call, successful or failed, is written to the AI request log with the new request type tts. Speech has no token counts, so the log records the number of input characters, the audio format and the size of the audio instead. Whether the input text is stored follows the capture_request_content setting, as for other request types.
Upgrading
No migration. Update the dependency. Nothing changes for existing endpoints. There is no admin screen for speech in this release; it is used from code.
Full release notes: AI 0.5.0
0.5.0 · 10 June 2026
Added
- Text-to-speech support (
PhoenixKitAI.speak/3). Synthesizes speech from text through a configured AI endpoint and returns the raw audio bytes, mirroring theembed/3path (shared endpoint resolution, credential validation, error mapping, and request logging):PhoenixKitAI.speak(endpoint_uuid, text, opts)→{:ok, %{audio: binary(), format: String.t()}}. Options::voice(preset id) /:voice_id(saved/cloned id) — only the present one is sent, keeping the package provider-neutral — plus:response_format(default"mp3") and:source.PhoenixKitAI.Completion.text_to_speech/3posts to/audio/speechand decodes both response shapes: Mistral hosted base64-JSON ({"audio_data": "<base64>"}) and the raw binary audio body used by OpenRouter / OSS vLLM.- Request log gains a
"tts"request_type. TTS carries no token usage (per-character billing), so rows recordinput_chars,audio_format, andaudio_bytesinstead; the input text honours the existingcapture_request_contentPII gate. - New
:invalid_audio_responseerror reason inPhoenixKitAI.Errorsfor an unreadable/empty audio response.
AI 0.5.0. Install or update: {:phoenix_kit_ai, "~> 0.5"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.