llm_wire/transcribe

One inline Google audio transcription using the caller’s HTTP Gun client.

Construct Audio under a raw-byte limit, prepare without I/O, then run once. The caller owns HTTP limits, cancellation, deadlines, retries and storage. Only completed nonempty text succeeds. Files, realtime audio, timestamps and speaker data are outside this API. Neither cancellation nor a timeout proves remote rollback. Request JSON contains audio and must be treated as sensitive.

Types

pub opaque type Audio

Why raw audio admission failed. The MIME declaration does not validate an audio codec, recording duration or acoustic quality.

pub type AudioError {
  InvalidAudio
  InvalidLimit
  UnsupportedMime
  AudioTooLarge(limit: Int, observed: Int)
}

Constructors

  • InvalidAudio
  • InvalidLimit
  • UnsupportedMime
  • AudioTooLarge(limit: Int, observed: Int)
pub opaque type Config
pub type Mode {
  Verbatim
  Smart
}

Constructors

  • Verbatim
  • Smart
pub opaque type Prepared

Model and language support are provider decisions. An empty language list requests automatic detection. Use BCP-47 language hints when known.

pub type Settings {
  Settings(
    model: String,
    language_codes: List(String),
    mode: Mode,
  )
}

Constructors

  • Settings(model: String, language_codes: List(String), mode: Mode)

Values

pub fn audio(
  bytes: BitArray,
  mime: String,
  max_bytes: Int,
) -> Result(Audio, AudioError)

Check raw bytes before Base64 expansion. The caller already owns this input allocation. Supported MIME names follow Google’s documented audio formats.

pub fn google(api_key: String) -> Config

Pure Google Interactions configuration. Credentials are captured in a closure and checked during preparation; ordinary value inspection cannot print them.

pub fn prepare(
  config: Config,
  settings: Settings,
  input: Audio,
) -> Result(Prepared, error.PrepareError)

Admit and encode with no timers, observations, socket or provider work. A prepared value may be reused explicitly; it provides no deduplication.

pub fn request_json(prepared: Prepared) -> String

The admitted body, without headers. It includes Base64 audio; do not log it.

pub fn run(
  client: http_gun.Client,
  prepared: Prepared,
) -> Result(String, llm_wire.Failure)

Perform exactly one attempt. The borrowed client view is used unchanged: transport bounds, destination restrictions and cancellation remain effective. Synchronous response interpretation has no independent preemption guarantee.

pub fn settings(model: String) -> Settings
pub fn with_endpoint(config: Config, endpoint: String) -> Config

A complete HTTPS operation URL, subject to the supplied client’s trust and destination policy. Query, fragment, userinfo and control characters refuse.

pub fn with_request_limit(config: Config, bytes: Int) -> Config

Bound encoded JSON after construction. This is separate from audio’s raw byte admission and the HTTP client’s response allowance.

✨ Search Document