Create a transcription
Turn an audio file into text, timestamps or subtitles. OpenAI compatible multipart request, with the cost in usage and a header.
MarkdownOn this page
/v1/audio/transcriptionsTranscribes an audio file. The request is multipart/form-data as for OpenAI's transcription endpoint, so audio.transcriptions.create in the OpenAI SDKs works against it. Walkthrough: Transcription.
Form fields
filefilerequiredThe audio. Lykia sets the size limit (25 MB by default). Send it last to have it streamed straight to the provider.
modelstringrequiredA transcription model id (for example openai/gpt-4o-mini-transcribe) or a preset such as @stt. List them with GET /models?kind=transcription.
languagestringThe spoken language.
promptstringWords or context to expect, for models that take it.
response_formatstringjson (default), verbose_json, diarized_json, text, srt or vtt, as the model allows.
timestamp_granularities[]stringword and/or segment, with verbose_json.
temperaturenumberSampling temperature.
provider_options, metadata, provider (string) — JSON encoded as a string.
userstringA tag stored with the request record.
Example
# Put `file` last: Lykia then streams it to the provider without storing it
curl https://api.getlykia.com/v1/audio/transcriptions \
-H "Authorization: Bearer $LYKIA_API_KEY" \
-F model=openai/gpt-4o-mini-transcribe \
-F language=en \
-F file=@meeting.mp3import os
from openai import OpenAI
client = OpenAI(base_url="https://api.getlykia.com/v1", api_key=os.environ["LYKIA_API_KEY"])
with open("meeting.mp3", "rb") as audio:
transcript = client.audio.transcriptions.create(
model="openai/gpt-4o-mini-transcribe",
file=audio,
language="en",
)
print(transcript.text)
print("cost (USD):", transcript.usage.cost)import { readFile } from "node:fs/promises";
const form = new FormData();
form.append("model", "openai/gpt-4o-mini-transcribe");
form.append("language", "en");
// Put `file` last: Lykia then streams it to the provider without storing it
form.append("file", new Blob([await readFile("meeting.mp3")], { type: "audio/mpeg" }), "meeting.mp3");
const response = await fetch("https://api.getlykia.com/v1/audio/transcriptions", {
method: "POST",
headers: { Authorization: `Bearer ${process.env.LYKIA_API_KEY}` },
body: form,
});
if (!response.ok) throw new Error(`Lykia returned ${response.status}: ${await response.text()}`);
const transcript = (await response.json()) as { text: string; usage: { cost: number } };
console.log(transcript.text);
console.log("cost (USD):", transcript.usage.cost);{
"text": "hello world",
"usage": {
"type": "tokens",
"input_tokens": 20,
"output_tokens": 5,
"total_tokens": 25,
"input_token_details": {
"audio_tokens": 18,
"text_tokens": 2
},
"cost": 0.00005,
"is_byok": false,
"cost_details": {
"upstream_cost": 0.00005,
"platform_fee": 0,
"is_byok": false
}
}
}Response
The provider's result in OpenAI's format for the chosen response_format. With the JSON formats, usage also carries Lykia's cost (USD), is_byok and cost_details. Every format has the X-Generation-Id and X-Lykia-Cost headers. Fields that came after file and could not be applied are named in X-Lykia-Ignored-Fields.
Errors
| Status | Code | When |
|---|---|---|
400 | unsupported_input | An unsupported response_format, timestamp option or audio type (metadata.param). |
400 | unsupported_model | The model does not transcribe audio. |
403 | platform_sales_disabled | The provider is not offered on Lykia credits yet; add your own key for it. |
413 | payload_too_large | The file is larger than Lykia's limit. |