Repository navigation
Description
Summary
Follow-up to #1115 / #1118. The TextToSpeech tool shipped in #1118 synthesizes
by shelling out to llama.cpp's llama-tts binary — exec.CommandContext in
internal/audio/exec.go, driven by Synthesizer.Synthesize in
internal/audio/synthesizer.go. Nothing about that path touches the gateway, so
TTS is invisible to gateway logs, request tracing and pricing, and it obliges
every user to install and maintain a second inference engine locally even when
their models already run behind the gateway.
This issue tracks adding a gateway-backed synthesis engine alongside the
local one, selected by config, so llama-tts becomes one backend rather than
the only one.
Current state
The extension points already exist and are unused:
-
config/config.go:1493-1501validatestext_to_speech.engineagainst exactly
one value,qwen3-tts. That switch is the discriminator; it has one arm. -
internal/agent/tools/text_to_speech.go:21already declares a consumer-side
interface, so the tool itself is backend-agnostic:type voiceSynthesizer interface { Synthesize(ctx context.Context, text, voiceSamplePath, outPath string) error }
-
The only thing hardcoding local exec is
internal/agent/tools/registry.go:207-209,
which constructsaudio.NewSynthesizer(...)directly instead of resolving a
backend.
ImageGeneration is the precedent to mirror: internal/agent/infrastructure/image_service.go
takes an sdk.Client, sits behind the agentdomain.ImageService port
(internal/agent/domain/ports.go:21), and the registry injects it, gated on the
service being non-nil.
Blocked on: the gateway has no speech endpoint
SDK v1.35.0's openapi.yaml exposes only:
/models /chat/completions /responses /messages /mcp/tools
/metrics /proxy/{provider}/{path} /images/generations
/images/edits /images/variations /health
Images have first-class routes; audio has none. So the CLI side cannot be
finished until an /audio/speech operation is added to
inference-gateway/schemas — mirroring how /images/generations was added —
and flows through to the SDK.
/proxy/{provider}/{path} is a generic passthrough and could reach a provider's
own speech endpoint in the meantime, but it means hand-rolling per-provider
request shapes and gives up normalized model ids, so it is a stopgap rather than
the design.
Cross-repo impact
inference-gateway/schemas— add the/audio/speechoperation (prerequisite).inference-gateway/sdk(Go, and the other language SDKs) — regenerate once the
schema lands.inference-gateway/docs— document the new engine option.inference-gateway/cli— this issue.
Acceptance Criteria
-
/audio/speechexists ininference-gateway/schemasand is available in the Go SDK (prerequisite; tracked separately). -
text_to_speech.engineaccepts agatewayvalue in addition toqwen3-tts, with validation updated inconfig/config.go. - A gateway-backed
voiceSynthesizerimplementation exists underinternal/agent/infrastructure/, mirroringImageService, and is wired through anagentdomainport. -
internal/agent/tools/registry.goselects the backend fromengineinstead of always constructingaudio.NewSynthesizer. - Gateway-engine synthesis appears in gateway logs and in
infer tracesas a normal request, with token/cost accounting where the provider reports it. - Local-exec config keys (
binary_path,models_dir,auto_download,model) are documented as applying only to theqwen3-ttsengine, and are ignored (not silently misleading) undergateway. - The default engine is unchanged, so existing local-exec setups keep working without config edits.
-
docs/text-to-speech.mdcovers both engines and when to pick each.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
edenreich commentedon Aug 30, 2026
Filed the schema prerequisite as inference-gateway/schemas#184 - it adds the
/audio/speechoperation mirroring OpenAI'sPOST /v1/audio/speech. The CLI work here is blocked until that lands and flows through to the Go SDK.feat(tts): add a gateway-backed TextToSpeech engine alongside local l…
inference-gateway-releaser commentedon Sep 1, 2026
🎉 This issue has been resolved in version 0.186.0 🎉
The release is available on:
Your semantic-release bot 📦🚀