Documentation
Voice
Speech-to-text and text-to-speech endpoints, BYOK against OpenAI. Audio bytes pass through — they never touch our database.
What ships today
Pattern A — pre/post processing. Two endpoints:
| Endpoint | Direction | Provider |
|---|---|---|
| POST /v1/transcribe | audio → text | OpenAI Whisper (whisper-1) |
| POST /v1/synthesize | text → audio | OpenAI TTS (tts-1, tts-1-hd, gpt-4o-mini-tts) |
Transcribe (STT)
Multipart upload. The file field is the audio binary; supported formats are whatever Whisper accepts (mp3, mp4, mpeg, mpga, m4a, wav, webm).
curl -X POST https://api.relaygh.dev/v1/transcribe \
-H "Authorization: Bearer $RELAY_API_KEY" \
-F file=@clip.mp3 \
-F language=es
# → { "text": "Hola, esto es una prueba." }TypeScript
import { transcribe } from "@relayhq/sdk";
const file = await fetch("./clip.mp3").then((r) => r.blob());
const { text } = await transcribe({
file,
language: "es",
responseFormat: "json", // or "text" | "srt" | "vtt" | "verbose_json"
});
console.log(text);Python
from pathlib import Path
from relayhq import transcribe
result = await transcribe(
file=Path("clip.mp3"),
language="es",
)
print(result["text"])Synthesize (TTS)
JSON in, audio bytes out. The response streams the audio in the requested format; the SDK helpers buffer it into an ArrayBuffer (TS) or bytes (Python).
curl -X POST https://api.relaygh.dev/v1/synthesize \
-H "Authorization: Bearer $RELAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": "Hola, esto es una prueba.",
"model": "tts-1",
"voice": "nova",
"format": "mp3"
}' \
--output hello.mp3TypeScript
import { synthesize } from "@relayhq/sdk";
const { audio, mime } = await synthesize({
input: "Hello from Relay",
voice: "alloy",
format: "mp3",
});
// Browser: play it
const blob = new Blob([audio], { type: mime });
const url = URL.createObjectURL(blob);
new Audio(url).play();Python
from pathlib import Path
from relayhq import synthesize
audio_bytes, mime = await synthesize(
input="Hola desde Relay",
voice="nova",
format="mp3",
)
Path("hello.mp3").write_bytes(audio_bytes)Options
| Field | Allowed | Default |
|---|---|---|
| model | tts-1 · tts-1-hd · gpt-4o-mini-tts | tts-1 |
| voice | alloy · ash · ballad · coral · echo · fable · onyx · nova · sage · shimmer · verse | alloy |
| format | mp3 · opus · aac · flac · wav · pcm | mp3 |
| input | ≤ 4096 characters | — |
Setup
The only requirement is an openai credential on your tenant. If you've used Relay with GPT-4o, you already have it. Otherwise:
curl -X PUT https://api.relaygh.dev/v1/credentials/openai \
-H "Authorization: Bearer $RELAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"apiKey":"sk-..."}'