opendunes
Inputs · 2 min
Copy page ▾

Audio in

Send a recording with your question; get an answer about it.

  1. Pick a model that listens.
  2. Add the recording as a part of your message.
  3. Read the answer.

To turn a recording into text and nothing else, Transcription is the guide.

1. Pick a model that listens

Only some text models take sound. Models that take audio in lists them; the sample below uses google/gemini-2.5-flash.

Watch out

A recording sent to a model that cannot listen is refused before it goes anywhere, with a 400. Nothing is charged.

2. Add the recording as a part of your message

A message's content is a text, or a list of parts. To send a recording, make it a list: one text part for your question, one input_audio part for the recording.

PartHolds
{"type": "text", "text": "..."}your question
{"type": "input_audio", "input_audio": {"data": "...", "format": "wav"}}the recording: its bytes as base64 in data, and its format (wav or mp3) in format

The recording goes in the request itself: there is no link to give. Read the file, encode it as base64, and put the result in data.

import base64
import json
import os
import urllib.request

API_KEY = os.environ["OPENDUNES_API_KEY"]
ADDRESS = "https://opendunes.com/v1/chat/completions"
MODEL = "google/gemini-2.5-flash"
PROMPT = "List the decisions taken in this meeting."
RECORDING_FILE = "meeting.wav"

with open(RECORDING_FILE, "rb") as file:
    recording = base64.b64encode(file.read()).decode()

body = {
    "model": MODEL,
    "messages": [
        {
            "role": "user",
            "content": [
                {"type": "text", "text": PROMPT},
                {
                    "type": "input_audio",
                    "input_audio": {"data": recording, "format": "wav"},
                },
            ],
        }
    ],
}

request = urllib.request.Request(
    ADDRESS,
    data=json.dumps(body).encode(),
    headers={
        "Authorization": "Bearer " + API_KEY,
        "Content-Type": "application/json",
    },
)
with urllib.request.urlopen(request) as response:
    reply = json.load(response)

print(reply["choices"][0]["message"]["content"])
print(reply["usage"]["cost"])
Do

Send wav or mp3, and keep the recording short enough that the whole request stays under 32 MB.

Don't

Don't put a link in data. It holds the recording's bytes, as base64, never an address.

3. Read the answer

The answer is the text in choices[0].message.content, as on any text request. The recording is charged as audio input, counted in usage.prompt_tokens_details.audio_tokens, and usage.cost is the whole charge.

To send the answer back as a stream, see Streaming. Every field of the request: Chat.

Good to know

A batch does not take audio. Send the request on its own: see Batches.

Errors

The body says why. What to do on every status: Errors and retries.

StatusMeans
400the model takes no audio, or the recording is in a format it does not read
402the balanceBalanceWhat you can spend, in DA.More on Balance and charges → cannot cover the request
404no such model
413the request is larger than the door takes