Skip to content

[FEATURE]: support xAI Grok TTS and STT in the AI speech/transcription routes #56041

Open

Description

@reynold-hu

Description

The @opencode/ai package ships speech generation and transcription routes for six providers (OpenAI, ElevenLabs, Cartesia, Deepgram, Google, AssemblyAI), but xAI's Grok Speech APIs have no route yet. The chat side already supports xAI, and the grok-voice-* realtime engine is in flight in #55951.

xAI documents both speech APIs as first-party REST endpoints:

  • Text to Speech: POST https://api.x.ai/v1/tts — JSON in, raw audio out. Up to 60,000 characters, expressive voices (voice_id, default eve), language required (BCP-47 or auto), mp3/wav/pcm/mulaw/alaw output, speed 0.7–1.5, speech tags and pronunciation replacements.
  • Speech to Text: POST https://api.x.ai/v1/stt — multipart with file last (or url), model grok-voice-transcribe-2.0, word-level timestamps always returned, optional diarize, repeated keyterm, inverse-text-normalization via format=true, up to 500 MB / 8 channels.

Docs: https://docs.x.ai/developers/model-capabilities/audio/text-to-speech and https://docs.x.ai/developers/model-capabilities/audio/speech-to-text

Proposed scope

  • xai-speech: lower SpeechRequest to voice_id, language (defaulting to auto), output_format.codec, and speed; reject instructions, timestamp requests, and codecs xAI does not produce; describe the returned audio from the codec actually sent.
  • xai-transcription: lower to the multipart form with file last (or a url field for URL sources); support diarize, word-timestamp answers, and repeated keyterm through provider options; map words/speakers, language, duration, and seconds usage.
  • Tests: lowering and rejection coverage, plus replayed cassettes for both routes.

I have a working implementation and will open a PR.

Activity

  1. opencode-agent commented on Oct 16, 2026

    @opencode-agent
    Contributor

    Thanks for the detailed proposal! You're asking for xAI Grok text-to-speech (/v1/tts) and speech-to-text (/v1/stt) routes in @opencode/ai, next to the existing speech and transcription providers. Right now packages/ai has xAI routes for chat, images and video, but not for speech or transcription.

    Maintainers will consider it, and your PR will be reviewed with it.

    Related:

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions