Preview: these APIs are still being designed and aren't available yet.
Skip to Content
UpskyDocs

Speech

Turn text into spoken audio.

Speech models use OpenAI's speech API, so audio.speech.create in any OpenAI SDK works with the same base URL and key as text. The reply is the audio file itself.

import { writeFile } from "node:fs/promises"
import OpenAI from "openai"

const ai = new OpenAI({
  apiKey: process.env.UPSKY_API_KEY,
  baseURL: "https://api.upsky.dev/v1/ai",
})

const speech = await ai.audio.speech.create({
  model: "openai/tts-1",
  voice: "alloy",
  input: "Your order shipped this morning.",
})

await writeFile("speech.mp3", Buffer.from(await speech.arrayBuffer()))

Get the speech models from the models endpoint with ?type=speech.

Options

  • input: the text to speak, up to 5,000 characters.
  • voice: each provider has its own voices, such as alloy for OpenAI or a voice ID for ElevenLabs. Without one, the model uses its default.
  • response_format: mp3, opus, aac, flac, wav or pcm. A model that can't make the format you ask for answers in its own, so check the Content-Type header.
  • instructions: how to speak, such as tone or pace, on models that support it.
  • speed: from 0.25 to 4, on models that support it.
  • language: the language of the text, such as en, when the model needs it.

Upsky doesn't keep the text or the audio.

What it costs

Speech is charged per character of input, at the price listed on the models endpoint as pricing.characters, per million characters. The price is known before the request, so that's exactly what's charged.

The Upsky-Cost header on the reply says what it cost, in US dollars, and Upsky-Characters how many characters were charged.

Music, sound effects and voices priced by the second of audio aren't offered yet.

Test keys

A test key gets one second of silence, as WAV, whatever format you ask for. It never calls a model and is never charged.

On this page