Skip to main content

Models

Both models answer in text by default. Ask for modalities ["text", "audio"] to get speech as well. Requests to these models may be up to 16 MB, room for a few minutes of audio.

Send audio

Add an input_audio part to a user message, with a WAV file as base64 and format wav. Other formats, including OpenAI’s mp3, return 400, and audio URLs are not accepted. The models hear at 16 kHz, so 16 kHz mono WAV is the smallest upload that loses nothing; other rates are resampled. This example transcribes a recording:
LFM3-Omni also takes image_url parts, so a spoken question can be about a photo sent in the same message.

Get a spoken reply

Ask as you would OpenAI: modalities ["text", "audio"] and audio {"voice": "alloy", "format": "pcm16"}. The reply comes back in OpenAI’s shape, so code written for the OpenAI SDK works unchanged. Streamed, each delta.audio carries base64 audio in data and the spoken words in transcript; delta.content stays empty. Without streaming, the whole reply is in message.audio. The format is pcm16, headerless 16-bit PCM at 24 kHz mono (what OpenAI requires for streaming), or wav, where each streamed chunk is a complete WAV file that plays on its own. OpenAI’s other formats, such as mp3 and opus, return 400.
For a follow-up turn, send the reply back as an assistant message with its audio.transcript as content. A message that refers to an earlier reply only by its audio.id returns 400.

Tasks and voices

A system prompt picks the task. These come from the models’ cards; swap in your own languages. The voice is chosen in the system prompt too, as a speech language and a female or male voice: American English, British English, Arabic, Chinese, Danish, Dutch, Finnish, French, German, Greek, Hebrew, Italian, Japanese, Korean, Polish, Portuguese, Spanish, Swedish, Turkish. OpenAI’s audio.voice is accepted, since the SDK requires it, but does not change the voice.

Usage and billing

usage follows OpenAI: prompt_tokens and completion_tokens include audio, and prompt_tokens_details.audio_tokens and completion_tokens_details.audio_tokens say how much of each was audio. Audio takes about 12.5 tokens a second each way: every clip in the conversation counts toward the prompt on every turn, and the spoken reply toward the completion. Audio tokens are billed at the model’s audio prices where it has them, and text tokens at its text prices.

Not supported yet

  • The /audio/transcriptions, /audio/speech, and /realtime endpoints. Use chat completions for transcription and speech.
  • Video input, which LFM3-Omni can understand but the API does not accept yet.