Endpoints
Music & audio
Generate music and spoken audio on api14 with audio-output chat models, including the audio parameters, formats and response handling.
Try it in the playgroundMusic and audio-output models (Lyria 3, GPT Audio and others) don't have a dedicated endpoint: you call them through Chat completions and ask for audio output with modalities. The generated audio comes back base64-encoded in the assistant message.
POST https://api14.com/api/v1/chat/completions
Request
All chat completion parameters apply. The audio-specific ones:
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | yes | An audio model id, e.g. google/lyria-3 or openai/gpt-audio. |
messages | array | yes | Describe the music or the speech you want. |
modalities | string[] | yes | ["text", "audio"] to receive audio. |
audio | object | no | Output options for speech models: { "voice": "alloy", "format": "wav" }. |
stream | boolean | no | Stream audio chunks as server-sent events where supported. |
Example
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api14.com/api/v1",
apiKey: process.env.API14_API_KEY,
});
const result = await client.chat.completions.create({
"model": "google/lyria-3",
"messages": [
{
"role": "user",
"content": "Explain vector databases in two sentences."
}
]
});
console.log(result.choices[0].message.content);
A raw request:
{
"model": "google/lyria-3",
"modalities": ["text", "audio"],
"messages": [
{ "role": "user", "content": "A 30-second lo-fi hip hop loop with soft piano and vinyl crackle." }
]
}
Response
{
"id": "gen-1791100000-xyz",
"object": "chat.completion",
"model": "google/lyria-3",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Here is your loop.",
"audio": { "id": "audio_01", "data": "UklGRiQAAABXQVZFZm10...", "format": "wav" }
},
"finish_reason": "stop"
}
],
"usage": { "prompt_tokens": 24, "completion_tokens": 1500, "total_tokens": 1524, "cost": 0.06 }
}
Decode choices[0].message.audio.data from base64 and save it with the given format extension.
Audio input
To send audio into a model (e.g. "summarize this recording"), use an input_audio content part, see Vision & files. For plain speech-to-text, Transcription is simpler and cheaper; for text-to-speech, use Speech.
Listing audio models
curl "https://api14.com/api/v1/models?category=audio"
Pricing
Audio models are billed at their listed price (per audio token, per second or per request, depending on the model). The exact cost is in usage.cost.
Errors
| Status | Code | When |
|---|---|---|
| 402 | insufficient_balance | Your USD balance is $0. |
| 403 | plan_required | Your plan does not include audio models. |
| 404 | model_not_found | Unknown or disabled model id. |
See Errors.