Skip to main content
Speech models connect audio and text input/output forms. They support both automatic speech recognition (ASR) and text-to-speech (TTS). Both are called through the standard Chat Completions interface, making them easy to integrate into transcription workflows, voice assistants, and accessibility tools. Representative models include:
  • bosonai/asr: Speech-to-text.
  • bosonai/tts: Text-to-speech.
For the full model list and pricing, refer to Models.

Use Cases

  • Transcription: Convert meetings, calls, lectures, or voice notes into searchable text.
  • Voice assistants: Combine ASR, an LLM, and TTS to build conversational voice experiences.
  • Subtitles and captions: Generate captions and subtitles for video and audio content.
  • Accessibility: Read content aloud, or let users interact by voice instead of typing.

Usage

Both types of models are called through the /chat/completions endpoint and the messages array, similar to chat models. The main difference is the input and output content.
  • Text-to-speech (TTS): Send the text to be spoken as a normal user message. The generated audio appears in choices[0].message.audio.data as base64-encoded WAV. Decode it and write it to a file to play it.
  • Speech-to-text (ASR): Send audio as a content part of type input_audio, including the base64 data and format information such as wav. The transcription result is returned as plain text in choices[0].message.content.

Key Parameters

  • TTS:
    • model: bosonai/tts.
    • messages: The role is user, and content is the text to be spoken.
  • ASR:
    • model: bosonai/asr.
    • messages: The role is user, and content is an array containing {"type": "input_audio", "input_audio": {"data": "<base64>", "format": "wav"}}.

Notes

  • Supported audio formats and maximum file size or duration vary by model. For details, refer to the model details in Models.
  • For long audio, splitting it into shorter segments helps stay within limits and reduces timeout risk.

Billing

  • Pricing unit: Speech models are typically billed by audio duration or by the number of characters/tokens processed, depending on the model. Check the model details in Models for the exact pricing unit.
  • Recommendation: For longer recordings, split the audio into multiple segments and process them separately to reduce timeout and retry costs.

Examples

The examples read the API key from an environment variable to avoid writing secrets into code.

Text-to-Speech (TTS)

Speech-to-Text (ASR)