OpenrouterSdk.Api.Transcription (OpenRouter SDK v0.1.4)

Copy Markdown View Source

POST /audio/transcriptions — speech-to-text via the dedicated endpoint.

the upstream endpoint is openai-compatible: multipart upload with a file part plus a model field.

{:ok, %{"text" => text}} =
  OpenrouterSdk.Api.Transcription.create(%{
    file: {"recording.wav", File.read!("recording.wav"), "audio/wav"},
    model: "openai/whisper-1",
    language: "en"
  })

caveat

openrouter's gateway currently json-parses the request body and rejects multipart uploads — a real call against this endpoint returns 400 with No number after minus sign in JSON at position 1 (v8's json parser choking on the --<boundary> preamble). until that ships properly, prefer OpenrouterSdk.transcribe/2 (in OpenrouterSdk.Audio), which routes through /chat/completions with an input_audio content block and works against any catalog-listed audio-input model.

Summary

Functions

create(payload, opts \\ [])

@spec create(
  map(),
  keyword()
) :: {:ok, map()} | {:error, OpenrouterSdk.Error.t()}