feat: OpenRouter segmented and diarized transcriptions
- 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:
- Response side. The shared OpenAI-compatible transcription
response deserializes the optional verbose fields (
language,duration,task,confidence,segments,words), allOption, so plainjsonresponses keep decoding unchanged and unmodeled provider extras are ignored. Speakers areOption<u64>, matching the diarizing backends on this wire. - Reachability. A generic
decode_ashelper ontranscription::TranscriptionResponserecovers 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". - Request side. No new builder fields.
response_format,timestamp_granularities, andprovider.optionsalready pass throughadditional_params; they are documented on the OpenRouter module with the known gotchas (some models rejectverbose_jsonwith 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.6breturns segments and words without speakers underverbose_json;microsoft/mai-transcribe-2withprovider.options.azure.diarization.enabledreturns 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_ashelper 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.
Source: 0xPlaygrounds/rig