Skip to content

[FEATURE] Add a gateway-backed TextToSpeech engine alongside local llama-tts #1126

Description

@edenreich

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-1501 validates text_to_speech.engine against exactly
    one value, qwen3-tts. That switch is the discriminator; it has one arm.

  • internal/agent/tools/text_to_speech.go:21 already 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 constructs audio.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/speech operation (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/speech exists in inference-gateway/schemas and is available in the Go SDK (prerequisite; tracked separately).
  • text_to_speech.engine accepts a gateway value in addition to qwen3-tts, with validation updated in config/config.go.
  • A gateway-backed voiceSynthesizer implementation exists under internal/agent/infrastructure/, mirroring ImageService, and is wired through an agentdomain port.
  • internal/agent/tools/registry.go selects the backend from engine instead of always constructing audio.NewSynthesizer.
  • Gateway-engine synthesis appears in gateway logs and in infer traces as 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 the qwen3-tts engine, and are ignored (not silently misleading) under gateway.
  • The default engine is unchanged, so existing local-exec setups keep working without config edits.
  • docs/text-to-speech.md covers both engines and when to pick each.

Activity

  1. added
    enhancement
    on Aug 30, 2026
  2. moved this to Todo in 2026on Aug 30, 2026
  3. edenreich commented on Aug 30, 2026

    @edenreich
    ContributorAuthor

    Filed the schema prerequisite as inference-gateway/schemas#184 - it adds the /audio/speech operation mirroring OpenAI's POST /v1/audio/speech. The CLI work here is blocked until that lands and flows through to the Go SDK.

  4. moved this from Todo to QA in 2026on Aug 31, 2026
  5. added a commit that references this issue on Sep 1, 2026
    571e8cf
  6. inference-gateway-releaser commented on Sep 1, 2026

    @inference-gateway-releaser
    Contributor

    🎉 This issue has been resolved in version 0.186.0 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

  7. moved this from QA to Done in 2026on Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementreleased

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions