Skip to content

Speech to text

POST /v1/audio/transcriptions: upload an audio file and transcribe it with whisper-1, or translate it into English.

The speech-to-text endpoint transcribes an audio file into text. The request uploads the file as a multipart/form-data form. The model available now is whisper-1, which is only in the OpenAI-AZ group, so your key needs that group (see Groups); Model Square is the source of truth.

POST https://codaapi.com/v1/audio/transcriptions

Speech synthesis (/v1/audio/speech, text to speech) has no available models at the moment, so this page doesn't cover it.

Request headers

Name Required Description
Authorization Yes Bearer sk-…, your API key
Content-Type Yes multipart/form-data. curl's -F and the official SDKs set it for you; don't write it by hand

Request body

The request body is a form with these fields:

Parameter Type Required Description
file file Yes The audio file; see the formats below
model string Yes whisper-1
language string No Language of the audio as an ISO-639-1 code, such as zh or en. Setting it improves accuracy and speed
prompt string No Guiding text, such as how to spell proper nouns or the previous segment; it should be in the audio's language
response_format string No json (default), text, srt, verbose_json or vtt
temperature number No Sampling temperature from 0 to 1, default 0
timestamp_granularities[] string No Timestamp granularity: segment (default) or word; you can pass both. response_format must be verbose_json

The gateway passes every form field except file to the upstream as is, and passes only the first file.

File formats: use mp3, mp4, m4a, wav, webm, ogg or flac, and give the file name an extension that matches its format. The gateway first reads the audio duration to estimate the cost, so if the extension isn't one of these (for example .mpga or .mpeg), or the duration can't be read from the file, the request fails at the gateway. The upstream sets the size limit for a single file; OpenAI's is 25 MB, so compress longer recordings or split them into parts.

Request examples

curl

curl https://codaapi.com/v1/audio/transcriptions \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -F [email protected] \
  -F model=whisper-1 \
  -F language=en

Python (pip install openai)

from openai import OpenAI

client = OpenAI()  # reads OPENAI_BASE_URL and OPENAI_API_KEY

with open("meeting.mp3", "rb") as audio:
    transcription = client.audio.transcriptions.create(
        model="whisper-1",
        file=audio,
        language="en",
    )
print(transcription.text)

Node.js (npm install openai)

import fs from 'node:fs';
import OpenAI from 'openai';

const client = new OpenAI(); // reads OPENAI_BASE_URL and OPENAI_API_KEY

const transcription = await client.audio.transcriptions.create({
  model: 'whisper-1',
  file: fs.createReadStream('meeting.mp3'),
  language: 'en',
});
console.log(transcription.text);

For subtitle files, set response_format to srt or vtt and the response is the subtitle text.

Response

The gateway returns the upstream's response unchanged. In the default json format:

{
  "text": "Hi everyone, today's meeting is mainly about next quarter's plan."
}
Field Description
text The transcribed text
language, duration, segments[], words[] Only with verbose_json: the detected language, the audio duration in seconds, and segment and word timestamps

When response_format is text, srt or vtt, the response is plain text rather than JSON.

Translate into English

POST /v1/audio/translations transcribes audio and translates it into English; it outputs English only. The form fields are the same as above except that there's no language, and the model is also whisper-1.

curl https://codaapi.com/v1/audio/translations \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -F [email protected] \
  -F model=whisper-1

OpenAI has announced that this endpoint shuts down on February 26, 2027, so avoid depending on it in new projects.

Errors

Errors come back with a 4xx or 5xx status code and an OpenAI-style error body, {"error": {"message": "…", "type": "…", "code": "…"}}, where message ends with the ID of the request (the request id). For common status codes and what to do about them, see Error codes.

Billing

Billing is by tokens. When the upstream doesn't report token usage (as with whisper-1), the gateway converts the audio duration: 1000 tokens per minute, with the duration rounded up to whole seconds. For each model's price, see Model Square and the price list; for the rules, see Pricing and multipliers.

Updated