Skip to content

[bot] RubyLLM speech synthesis (RubyLLM.speak) not instrumented #191

Description

@braintrust-bot

Summary

The ruby_llm gem provides RubyLLM.speak(input, ...) for text-to-speech synthesis using AI TTS models. This API is not instrumented by this SDK. The current RubyLLM integration only instruments RubyLLM::Chat — covering chat completions, tool execution, and streaming. speak is a distinct generative AI execution surface (it drives a TTS model to produce audio from text) and produces usage data (token counts via some providers), yet no span is created for it.

This is a direct parity gap with the OpenAI Audio integration gap (#146), which notes that TTS execution via client.audio.speech.create is also uninstrumented. Both use AI models to generate audio from text input.

What is missing

RubyLLM.speak(input, model:, voice:, ...) / RubyLLM::Speech.speak(input, ...) — invokes a TTS provider (OpenAI tts-1, tts-1-hd, or equivalent) and returns a RubyLLM::Speech object containing:

  • data — raw audio bytes
  • model — model ID used for synthesis
  • voice — voice selected
  • format — audio format (mp3, wav, flac, etc.)

What a span should capture

  • Input: the text string passed to speak
  • Metadata: model, voice, format, provider
  • Output: audio format and size (not the raw binary bytes)
  • Metrics: time_to_first_token (latency)

The implementation pattern already exists: RubyLLM::Embed, RubyLLM::Paint, and RubyLLM::Transcription are single-method execution surfaces (see issue #136). RubyLLM::Speech follows the same shape and would be instrumented with the same approach: a new SpeechPatcher wrapping the speak class method.

Braintrust docs status

not_found — The Braintrust RubyLLM integration docs at https://www.braintrust.dev/docs/integrations/sdk-integrations/ruby-llm document only chat completions, tool calls, token usage, and streaming. Speech synthesis is not mentioned.

Upstream sources

Local repo files inspected

  • lib/braintrust/contrib/ruby_llm/patcher.rb — defines only ChatPatcher; no SpeechPatcher
  • lib/braintrust/contrib/ruby_llm/instrumentation/chat.rb — wraps Chat#complete and Chat#execute_tool only
  • lib/braintrust/contrib/ruby_llm/integration.rb — registers [ChatPatcher] only
  • Appraisals — tests ruby_llm at versions 1.8, 1.9, and latest; speech.rb is present in all supported versions
  • Grep for speak, Speech, tts, SpeechPatcher across lib/braintrust/ returns zero matches

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Fields

    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions