Audio Input (Transcription)
LLM API supports multimodal models that accept audio as part of a chat completions request. You can send audio inline as base64-encoded data alongside text, and the model will transcribe or analyze it.
INFO
This feature uses the standard /v1/chat/completions endpoint — not /v1/audio/transcriptions.
It is designed for multimodal models that process audio and text together, not dedicated STT
models. For standalone transcription see Audio (TTS & STT).
Supported Models
Models that support audio input are marked with the Transcription capability on the models page.
Quick Start
# 1. Encode audio to base64
AUDIO_B64=$(base64 -i recording.mp3)
# 2. Send to chat completions
curl -X POST "https://api.llmapi.ai/v1/chat/completions" \
-H "Authorization: Bearer $LLM_API_KEY" \
-H "Content-Type: application/json" \
-d "{
\"model\": \"google-ai-studio/gemini-2.5-flash\",
\"messages\": [
{
\"role\": \"user\",
\"content\": [
{
\"type\": \"input_audio\",
\"input_audio\": {
\"data\": \"$AUDIO_B64\",
\"format\": \"mp3\"
}
},
{
\"type\": \"text\",
\"text\": \"Transcribe this audio\"
}
]
}
]
}"
Request Format
The content field must be an array when including audio. Each content block has a type:
{
"model": "google-ai-studio/gemini-2.5-flash",
"messages": [
{
"role": "user",
"content": [
{
"type": "input_audio",
"input_audio": {
"data": "<base64-encoded audio>",
"format": "mp3"
}
},
{
"type": "text",
"text": "Transcribe this audio"
}
]
}
]
}
input_audio Block Fields
| Field |
Type |
Description |
data |
string |
Base64-encoded audio data (no data: URI prefix) |
format |
string |
Audio format — see supported formats below |
Supported Audio Formats
| Format |
Value |
| MP3 |
mp3 |
| WAV |
wav |
| OGG |
ogg |
| M4A / AAC |
m4a or aac |
| MP4 |
mp4 |
| WebM |
webm |
| FLAC |
flac |
| Opus |
opus |
Python Example
import base64
from openai import OpenAI
client = OpenAI(
base_url="https://api.llmapi.ai/v1",
api_key="YOUR_KEY"
)
with open("recording.mp3", "rb") as f:
audio_b64 = base64.b64encode(f.read()).decode()
response = client.chat.completions.create(
model="google-ai-studio/gemini-2.5-flash",
messages=[
{
"role": "user",
"content": [
{
"type": "input_audio",
"input_audio": {
"data": audio_b64,
"format": "mp3",
},
},
{"type": "text", "text": "Transcribe this audio"},
],
}
],
)
print(response.choices[0].message.content)
Combining Text and Audio
You can mix text and audio in the same message, and include conversation history with text-only turns:
{
"model": "google-ai-studio/gemini-2.5-flash",
"messages": [
{
"role": "system",
"content": "You are an expert transcriptionist."
},
{
"role": "user",
"content": [
{
"type": "input_audio",
"input_audio": { "data": "<base64>", "format": "wav" }
},
{
"type": "text",
"text": "Transcribe this and identify the speaker's language."
}
]
}
]
}
Billing
Audio input is billed separately from text tokens. The response usage object includes a breakdown:
{
"usage": {
"prompt_tokens": 16513,
"completion_tokens": 2453,
"prompt_tokens_details": {
"audio_tokens": 16508,
"cached_tokens": 0
},
"cost_usd_input": 0.0000015,
"cost_usd_audio_input": 0.016508,
"cost_usd_output": 0.006133
}
}
| Field |
Description |
prompt_tokens_details.audio_tokens |
Tokens consumed by audio data |
cost_usd_audio_input |
Cost for audio tokens at the model's audio input price |
cost_usd_input |
Cost for text tokens only |