Skip to main content
NewTranscription sends an audio file to a transcription-capable provider. Import pkg/gateway/llm/transcription and pkg/utils. Given client and ctx:
Audio contains raw file bytes. AudioFilename identifies the format for multipart/provider handling. Bound file size before reading a user upload into memory; this example reads a known local file.

Optional controls

Language is a language hint, Prompt guides vocabulary/style where supported, and ResponseFormat selects the requested response shape. TimestampGranularities can request word or segment timings on models that support them. These settings are not universal across providers. The response always has a Text field and may contain Language, Duration, Words, Segments, Usage, and provider-specific Raw data. Do not assume optional timing fields are present unless the requested format and model support them.

Application handling

Preserve the original audio and transcription relationship if users need to review it. Decide retention, access, and redaction policies before storing sensitive recordings. The SDK does not automatically diarize speakers, chunk oversized recordings, or convert unsupported audio formats. Uploading an audio attachment to an agent does not implicitly call this transcription API. Use it explicitly, expose a transcription tool, or select a model/provider that natively accepts the audio input.