curl --fail-with-body https://api.pre.dev/v1/audio/speech \
-H "Authorization: Bearer $PREDEV_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "openai/gpt-audio-mini", "input": "Your build is ready.", "voice": "alloy"}' \
-o ready.wavimport os
from openai import OpenAI
client = OpenAI(base_url="https://api.pre.dev/v1", api_key=os.environ["PREDEV_API_KEY"])
with client.audio.speech.with_streaming_response.create(
model="openai/gpt-audio-mini",
input="Your build is ready.",
voice="alloy",
) as speech:
speech.stream_to_file("ready.wav")import fs from 'node:fs/promises';
import OpenAI from 'openai';
const client = new OpenAI({ baseURL: 'https://api.pre.dev/v1', apiKey: process.env.PREDEV_API_KEY });
const speech = await client.audio.speech.create({
model: 'openai/gpt-audio-mini',
input: 'Your build is ready.',
voice: 'alloy',
});
await fs.writeFile('ready.wav', Buffer.from(await speech.arrayBuffer()));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.pre.dev/v1/audio/speech",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'openai/gpt-audio-mini',
'input' => 'Your build is ready.'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.pre.dev/v1/audio/speech"
payload := strings.NewReader("{\n \"model\": \"openai/gpt-audio-mini\",\n \"input\": \"Your build is ready.\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.pre.dev/v1/audio/speech")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"openai/gpt-audio-mini\",\n \"input\": \"Your build is ready.\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pre.dev/v1/audio/speech")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"openai/gpt-audio-mini\",\n \"input\": \"Your build is ready.\"\n}"
response = http.request(request)
puts response.read_body"<string>"Audio
POST /v1/audio/speech for text to speech and music, POST /v1/audio/transcriptions for speech to text.
curl --fail-with-body https://api.pre.dev/v1/audio/speech \
-H "Authorization: Bearer $PREDEV_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "openai/gpt-audio-mini", "input": "Your build is ready.", "voice": "alloy"}' \
-o ready.wavimport os
from openai import OpenAI
client = OpenAI(base_url="https://api.pre.dev/v1", api_key=os.environ["PREDEV_API_KEY"])
with client.audio.speech.with_streaming_response.create(
model="openai/gpt-audio-mini",
input="Your build is ready.",
voice="alloy",
) as speech:
speech.stream_to_file("ready.wav")import fs from 'node:fs/promises';
import OpenAI from 'openai';
const client = new OpenAI({ baseURL: 'https://api.pre.dev/v1', apiKey: process.env.PREDEV_API_KEY });
const speech = await client.audio.speech.create({
model: 'openai/gpt-audio-mini',
input: 'Your build is ready.',
voice: 'alloy',
});
await fs.writeFile('ready.wav', Buffer.from(await speech.arrayBuffer()));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.pre.dev/v1/audio/speech",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'openai/gpt-audio-mini',
'input' => 'Your build is ready.'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.pre.dev/v1/audio/speech"
payload := strings.NewReader("{\n \"model\": \"openai/gpt-audio-mini\",\n \"input\": \"Your build is ready.\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.pre.dev/v1/audio/speech")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"openai/gpt-audio-mini\",\n \"input\": \"Your build is ready.\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pre.dev/v1/audio/speech")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"openai/gpt-audio-mini\",\n \"input\": \"Your build is ready.\"\n}"
response = http.request(request)
puts response.read_body"<string>"audio in architecture.output_modalities.
Text to speech
POST /v1/audio/speech takes the standard speech body and returns audio bytes. Speech models are openai/gpt-audio-mini (fast) and openai/gpt-audio (higher quality); voices are alloy, ash, ballad, coral, echo, sage, shimmer and verse. The response is audio/wav (24 kHz mono); pass response_format: "pcm16" for the raw samples. instructions sets the delivery; by default the model reads the text verbatim.
curl --fail-with-body https://api.pre.dev/v1/audio/speech \
-H "Authorization: Bearer $PREDEV_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "openai/gpt-audio-mini", "input": "Your build is ready.", "voice": "alloy"}' \
-o ready.wav
import fs from 'node:fs/promises';
import OpenAI from 'openai';
const client = new OpenAI({ baseURL: 'https://api.pre.dev/v1', apiKey: process.env.PREDEV_API_KEY! });
const speech = await client.audio.speech.create({
model: 'openai/gpt-audio-mini',
input: 'Your build is ready.',
voice: 'alloy',
});
await fs.writeFile('ready.wav', Buffer.from(await speech.arrayBuffer()));
import os
from openai import OpenAI
client = OpenAI(base_url="https://api.pre.dev/v1", api_key=os.environ["PREDEV_API_KEY"])
with client.audio.speech.with_streaming_response.create(
model="openai/gpt-audio-mini",
input="Your build is ready.",
voice="alloy",
) as speech:
speech.stream_to_file("ready.wav")
<audio> element at it; the Content-Type header names the format. A model id that does not produce audio returns 400 with the list of ids that do.
Music
The same endpoint composes music: sendmodel: "google/lyria-3-clip-preview" (or google/lyria-3-pro-preview) with input set to the mood or style you want, for example "upbeat lo-fi for a launch video". Music models answer with an MP3 (audio/mpeg); voice is ignored. The header x-predev-audio-format carries the format on every speech response.
Transcription
POST /v1/audio/transcriptions is multipart/form-data with a file part and a model field.
curl --fail-with-body https://api.pre.dev/v1/audio/transcriptions \
-H "Authorization: Bearer $PREDEV_API_KEY" \
-F "model=$TRANSCRIBE_MODEL" \
-F "file=@meeting.m4a"
import fs from 'node:fs';
import OpenAI from 'openai';
const client = new OpenAI({ baseURL: 'https://api.pre.dev/v1', apiKey: process.env.PREDEV_API_KEY! });
const transcript = await client.audio.transcriptions.create({
model: process.env.TRANSCRIBE_MODEL!,
file: fs.createReadStream('meeting.m4a'),
});
console.log(transcript.text);
import os
from openai import OpenAI
client = OpenAI(base_url="https://api.pre.dev/v1", api_key=os.environ["PREDEV_API_KEY"])
with open("meeting.m4a", "rb") as audio:
transcript = client.audio.transcriptions.create(model=os.environ["TRANSCRIBE_MODEL"], file=audio)
print(transcript.text)
TRANSCRIBE_MODEL to a speech-to-text model such as openai/whisper-large-v3. Transcription models are not listed by GET /v1/models. Speech, music, and transcription calls return the usual x-predev-* headers and are charged from the model’s metered usage.Authorizations
The workspace API key (pdk_…) from Integrations → Built-in in the pre.dev dashboard.
Headers
Attribute this call to one of the workspace's projects. An id the workspace does not own is ignored.
Body
A catalog model whose architecture.output_modalities includes audio: speech models (openai/gpt-audio-mini, openai/gpt-audio) or music models (google/lyria-3-clip-preview, google/lyria-3-pro-preview).
"openai/gpt-audio-mini"
The text to speak, or for a music model, the style or mood to compose.
1Speech voice, such as alloy, ash, ballad, coral, echo, sage, shimmer or verse. Music models ignore it.
How to deliver the text. By default the text is read verbatim. Music models ignore it.
wav (24 kHz mono) or pcm16 (raw samples; pcm also works). Other values return WAV. Music models return their own container (MP3).
Response
The audio: audio/wav for speech, audio/mpeg for music, or application/octet-stream with raw PCM16 samples (24 kHz mono) when response_format is pcm16.
The response is of type file.
Was this page helpful?

