Audio transcription
Transcribe an audio file with a model of kind transcription.
Transcribe a file#
POST /v1/audio/transcriptions takes a multipart/form-data body with the audio file and the model.
transcription is offered yet404 model_not_found for every model id. The samples below show the request for when one is offered.Set PANWARD_TRANSCRIPTION_MODEL to the id of a model of kind transcription from the model catalog. An id that is not a canonical id answers 404 model_not_found.
curl https://api.panward.ai/v1/audio/transcriptions \ -H "Authorization: Bearer $PANWARD_API_KEY" \ -F file=@ward-round.mp3 \ -F model=$PANWARD_TRANSCRIPTION_MODEL \ -F language=en
import os import requests with open("ward-round.mp3", "rb") as audio: r = requests.post( "https://api.panward.ai/v1/audio/transcriptions", headers={"Authorization": f"Bearer {os.environ['PANWARD_API_KEY']}"}, files={"file": ("ward-round.mp3", audio, "audio/mpeg")}, data={"model": os.environ["PANWARD_TRANSCRIPTION_MODEL"], "language": "en"}, ) r.raise_for_status() print(r.json()["text"])
import { readFile } from "node:fs/promises"; const form = new FormData(); form.append("file", new Blob([await readFile("ward-round.mp3")], { type: "audio/mpeg" }), "ward-round.mp3"); form.append("model", process.env.PANWARD_TRANSCRIPTION_MODEL!); form.append("language", "en"); const response = await fetch("https://api.panward.ai/v1/audio/transcriptions", { method: "POST", headers: { Authorization: `Bearer ${process.env.PANWARD_API_KEY}` }, body: form, }); if (!response.ok) throw new Error(`transcription: ${response.status}`); console.log(((await response.json()) as { text: string }).text);
curl https://api.panward.ai/v1/audio/transcriptions \ -H "Authorization: Bearer $PANWARD_API_KEY" \ -F file=@ward-round.mp3 \ -F model=$PANWARD_TRANSCRIPTION_MODEL \ -F response_format=srt -o ward-round.srt
Formats, size and options#
The file is flac, mp3, mp4, m4a, ogg, wav or webm, at most 25 MB. A larger body is refused with 413 request_too_large: split long recordings into parts and transcribe each.
| Field | Required | Values | Limits | Notes |
|---|---|---|---|---|
| file | Yes | string | The audio file (flac, mp3, mp4, m4a, ogg, wav or webm), at most 25 MB. | |
| model | Yes | string | Canonical id of a model of kind `transcription`. | |
| language | No | string | Language of the audio as an ISO 639-1 code. Improves accuracy and speed. | |
| prompt | No | string | Text to guide style or spelling. | |
| response_format | No | json, text, verbose_json, srt, vtt | ||
| temperature | No | number | min 0; max 1 |
With response_format text, srt or vtt the answer is plain text; otherwise it is JSON.
The receipt of an upload#
The receipt's request.received hash covers the exact multipart body bytes your client sent, boundary included. To run step 4 of verification you need those bytes: build the multipart body yourself, save it to a file and send that file, because a client that builds the body for you does not keep it. Without them the verdict is verified_without_content.
What is stored and billed#
The audio is processed in memory and is not stored. Transcription is billed per audio minute.
The response carries the same headers as a chat completion, among them panward-receipt-id, panward-tier and panward-region, and the request has a receipt like any other (Receipts and verification). panward-hold-until-verified: true is accepted: the response waits until the verification level is known and the answer is 503 verification_unavailable instead of an unverified one.