relay

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:

EndpointDirectionProvider
POST /v1/transcribeaudio → textOpenAI Whisper (whisper-1)
POST /v1/synthesizetext → audioOpenAI 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.mp3

TypeScript

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

FieldAllowedDefault
modeltts-1 · tts-1-hd · gpt-4o-mini-ttstts-1
voicealloy · ash · ballad · coral · echo · fable · onyx · nova · sage · shimmer · versealloy
formatmp3 · opus · aac · flac · wav · pcmmp3
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-..."}'