mirror of
https://github.com/bitbaum/ai-kit.git
synced 2026-12-04 05:48:21 +01:00
The registry has declared `kind: "transcribe"` since it was written, with
nothing behind it. This is the thing that was supposed to be behind it.
The fleet has three hand-rolled transcription clients — one in heidi, two in
loki — and not one of them has a chain, a fallback, a health tracker or
rate-limit classification. Each is a single vendor and a single key, so one
Groq blip takes dictation down in every app that has it, separately, with a
different error message each time. That is the exact shape this package exists
to stop being written a fourth time.
**The routing is not reimplemented.** `walkChain` already owns what a dead
vendor is, when a rejected key condemns a whole provider, and when to stop
walking — and there must be ONE answer to those questions or the fleet ends up
with two that disagree. `transcribe()` is a one-liner over it; only the request
differs, which is why the file is short.
To borrow the walk, `walkChain` now takes a named subset of what it actually
reads rather than `CompleteOptions`. `CompleteOptions` satisfies `WalkOptions`
structurally and did not change, so `complete()` and `completeStream()` are
untouched — the alternative was `transcribe()` faking a `messages` field to get
at the routing, or copying thirty lines of vendor-liveness logic.
Decisions the tests pin, each one a judgement a hand-rolled client got wrong:
- A DAILY 429 condemns the vendor and a capacity 429 does not — made by the
same `classifyRateLimit` the text path uses, not a second copy.
- An EMPTY transcript is an ANSWER. Silence genuinely transcribes to nothing,
and demoting it would re-upload the same audio to every vendor in the chain
to be told the same true thing, slowly and at the caller's expense.
- A 200 carrying no `text` field IS a failure — a success code over a body
that is not a transcript, which is the same call `complete` makes about
empty content.
- No `content-type` header is set by hand. `fetch` writes it from the
FormData including the multipart boundary; setting it manually omits the
boundary and every vendor answers 400 on a body it cannot split.
- Each link gets its own deadline rather than sharing the caller's signal,
for the reason `complete` documents: a vendor that accepts the connection
and never answers is the outage a fallback is least able to survive.
The MODELS stay the caller's. A chain of chat models is not a chain of
transcription models, and guessing one from the other is how an app ends up
POSTing audio at a text endpoint; `kind` in the registry is what an app builds
its chain from.
289 tests, 11 of them new.
Claude-Session: https://claude.ai/code/session_01FzYBD3sZroCAYeRgTYrpfT
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>