#2595·rig

feat: OpenRouter segmented and diarized transcriptions

Author: fversaciCreated Sep 25, 2026Updated Sep 25, 2026
Labelsfeat
  • I have looked for existing issues (including closed) about this

OpenRouter transcriptions can now include timestamps and speaker labels, enabling timed subtitles and diarized conversation views. I have a working implementation on a branch and would like to open a PR.

Summary (AI-generated)

Problem

OpenRouter's STT endpoint can return rich transcripts: per-segment and per-word timestamps, detected language, duration, confidence, and speaker labels for diarizing backends (Azure, Deepgram). This is the raw material for timed subtitles and "who said what" conversation views.

rig today accepts those requests (the keys flow through additional_params) but discards the rich part of the response: the shared OpenAI-compatible transcription decoder keeps only text and usage, so there is no way to obtain timestamps or speaker labels through the typed API, and users fall back to raw HTTP calls.

Proposal

Make the full verbose_json response reachable through rig's typed API, without new request-side API surface:

  1. Response side. The shared OpenAI-compatible transcription response deserializes the optional verbose fields (language, duration, task, confidence, segments, words), all Option, so plain json responses keep decoding unchanged and unmodeled provider extras are ignored. Speakers are Option<u64>, matching the diarizing backends on this wire.
  2. Reachability. A generic decode_as helper on transcription::TranscriptionResponse recovers the provider's typed payload from its raw document, so the verbose data is reachable from the normalized response without a second manual parse. This stays provider-agnostic: rig defines no cross-provider notion of a "segment" or "speaker".
  3. Request side. No new builder fields. response_format, timestamp_granularities, and provider.options already pass through additional_params; they are documented on the OpenRouter module with the known gotchas (some models reject verbose_json with a 400; granularities are ignored without it; diarization is best-effort; provider options are JSON-only, unavailable on multipart).

Evidence

  • Verified live (2026-09) with real audio through OpenRouter: nvidia/nemotron-3.5-asr-streaming-multilingual-0.6b returns segments and words without speakers under verbose_json; microsoft/mai-transcribe-2 with provider.options.azure.diarization.enabled returns speaker-labeled segments and words.
  • Reference: OpenRouter STT docs, https://openrouter.ai/docs/guides/overview/multimodal/stt

Implementation

A working implementation is on my branch ︎openrouter-transcription-verbose, here covering all of the above plus two cassette-backed regression tests replaying real verbose and diarized exchanges (request bodies asserted byte-for-byte) and an example in examples/transcription that prints speaker-labeled, time-aligned segments. I am happy to open a PR from it if the approach sounds right, and I would particularly welcome maintainer input on the reachability question (point 2): whether decode_as is the right shape, or whether rich transcription data should instead map into the normalized response for all providers.

Changelog

  • feat(rig-core): surface OpenRouter verbose transcription segments, words, and speaker labels through the typed API, with a generic decode_as helper and cassette-backed regression tests.

Migration

None. All new response fields are optional and default to unset; plain responses decode exactly as before. Existing additional_params usage is unaffected.