# A text-to-speech API: voices, formats and price per 1,000 characters

> Text-to-speech costs $0.04 per 1,000 characters with vibiz/voice and vibiz/voice-lite, featuring nine voices, streamed MP3/PCM, and auto file saves.

**The cheapest text-to-speech API for apps on thelastapi costs $0.04 per 1,000 characters using `vibiz/voice` or `vibiz/voice-lite`.** Both models generate natural audio across nine distinct voices, streaming back in either MP3 or PCM format. Because the endpoint follows the standard OpenAI API structure, you can drop it into any existing application using the official OpenAI client library, plain HTTP requests, or the command line.

When you run text-to-speech inside an app, pricing predictability, voice variety, latency, and asset storage determine whether your architecture holds up. This guide covers available speech models, formatting choices, practical code examples, and how to track per-user voice spend.

## What does text-to-speech cost per 1,000 characters?

Instead of juggling different contracts or seat licenses, speech generation is billed per 1,000 characters of input text. Your requests run directly through stable model tiers:

| Model | Description | Primary strength | Price per 1,000 characters |
| --- | --- | --- | --- |
| `vibiz/voice-lite` | A lab voice model | The fastest voices, supporting 32 languages | $0.04 |
| `vibiz/voice` | A lab voice model | Natural, real-time voices for interactive apps | $0.04 |
| `vibiz/voice-pro` | A lab voice model | High expressiveness for narration and character dialogue | $0.08 |

Every call is billed at the lab's underlying cost plus the catalog markup percentage (`markup_pct`). Calls fail transparently with a `503 model_unavailable` or `503 provider_unavailable` error if a specific provider encounters an outage; the system never quietly swaps your chosen voice model for a different model behind your back. You can check the specific model that produced your audio via the `X-Vibiz-Served-Model` response header.

If your product also handles listening or vision, you can see how audio fits into the broader stack in [one API for image, video and voice AI models](https://thelastapi.dev/blog/one-api-image-video-voice-models) and pair speech outputs with transcription using [a speech-to-text API for 99 languages](https://thelastapi.dev/blog/speech-to-text-api-99-languages).

## Which voices and audio formats can you use?

The text-to-speech endpoint supports nine standard voice personas:

- `alloy`
- `ash`
- `coral`
- `echo`
- `fable`
- `nova`
- `onyx`
- `sage`
- `shimmer`

Each request accepts up to 4,096 characters of text in the `input` field. For audio output, you can request either `mp3` or `pcm`:

- **MP3 (`audio/mpeg`)**: The default format for web playback, downloads, and mobile application caches. It streams directly to the client as chunks arrive.
- **PCM (`audio/pcm`)**: Raw 24 kHz, 16-bit mono PCM audio. This format eliminates container encoding overhead, making it practical for real-time audio pipelines and custom DSP processing.

## How to generate speech in code

Because the gateway is OpenAI-compatible under `/v1/ai`, you do not need custom audio client packages. Point the official OpenAI SDK to `VIBIZ_AI_BASE_URL` or run standard `curl` calls.

### Using the OpenAI Node.js SDK

Set your environment variables when initializing your project:

```bash
vibiz init "Acme Reader" --resources ai
vibiz dev
```

Your `.env.development.local` file automatically receives `VIBIZ_AI_BASE_URL` and `VIBIZ_AI_API_KEY`, as well as standard `OPENAI_BASE_URL` and `OPENAI_API_KEY` aliases.

```ts
import OpenAI from 'openai';
import fs from 'node:fs';

const openai = new OpenAI({
  baseURL: process.env.VIBIZ_AI_BASE_URL,
  apiKey: process.env.VIBIZ_AI_API_KEY,
});

async function makeAudio() {
  const response = await openai.audio.speech.create({
    model: 'vibiz/voice-lite',
    voice: 'alloy',
    input: 'Your appointment is confirmed for tomorrow morning at nine.',
    response_format: 'mp3',
  });

  const buffer = Buffer.from(await response.arrayBuffer());
  await fs.promises.writeFile('notification.mp3', buffer);
}

makeAudio();
```

If you use `@vibiz/app`, you can pass your configuration directly with `new OpenAI(vibiz.ai)`.

### Using the command line

You can test voices and generate audio clips straight from your terminal using the `vibiz` CLI:

```bash
vibiz say "Welcome to Acme Bakery" -o welcome.mp3 --voice alloy
```

### Using HTTP directly

To integrate audio generation into languages without official client support, submit a `POST` request to `/v1/ai/audio/speech`:

```bash
curl https://thelastapi.dev/v1/ai/audio/speech \
  -H "Authorization: Bearer $VIBIZ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "vibiz/voice",
    "voice": "nova",
    "input": "Thank you for calling Acme support. Please hold while we transfer you."
  }' \
  --output hold_message.mp3
```

## How generated audio files and links work

Whenever you run a text-to-speech request within a project, you do not need to upload the resulting audio buffer to a separate storage bucket. Every audio clip is saved directly into the project's [Files](https://thelastapi.dev/docs/files).

Each completed response to `POST /v1/ai/audio/speech` includes two custom HTTP response headers:

- `X-Vibiz-File-Id`: The unique record identifier (such as `file_01k...`).
- `X-Vibiz-File-Url`: A permanent public URL where the audio file can be fetched at any time.

Public file URLs follow a consistent structure:

`https://thelastapi.dev/f/<key>/<name>`

Because `<key>` consists of 32 random characters, links cannot be guessed or scanned. Files are served with complete streaming headers: `X-Content-Type-Options: nosniff`, `Accept-Ranges: bytes` so clients can seek, and an inline `Content-Disposition`.

When using project keys, your environment dictates storage placement:
- Calls using development keys save to development Files.
- Calls using production keys save to production Files.
- Calls made with an account-level key without an associated project do not write to Files; their media links expire after 24 hours.

You can inspect or manage stored audio files later from the CLI:

```bash
vibiz files --type audio
vibiz files latest --type audio
```

## How to track and cap TTS spend per user

Voice features can become a financial vulnerability if end users make excessive requests. To prevent cost overruns, you can enforce limits and track usage at multiple levels:

### 1. Tagging requests to specific users
Include your user's identifier in the `user` body property or send an `X-Vibiz-User` header with the request. The console breaks down spend by end user, helping you audit which accounts generate the most audio volume.

### 2. Built-in daily ceilings
Every account has a daily spend ceiling of $5 across all AI and actions by default, which can be modified by the account owner in Billing. Individual projects have a daily budget of $1 by default. If your app hits a limit, the API returns HTTP status `429` with `details.reason: "project_budget"` or `details.reason: "daily_spend"`.

You can adjust these thresholds programmatically with the API:

```bash
curl -X PATCH https://thelastapi.dev/v1/projects/prj_123/ai \
  -H "Authorization: Bearer $VIBIZ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "daily_budget_usd": 15.00,
    "end_user_daily_budget_usd": 0.50
  }'
```

Whenever an account or project hits 80% and 100% of its budget, owners automatically receive email notifications and console alert banners.

## Can you use your own Google key?

If you already maintain an account with Google AI Studio, you can link your own Gemini API key. Google models run on your account, and the platform fee for those calls drops to 0:

```bash
GEMINI_API_KEY=your_key_here vibiz ai keys set google
```

When using your own Google key for speech:
- Set your speech model to a Google TTS model id, such as `google/gemini-3.8-flash-tts`.
- If you request `mp3`, speech on a Google key comes back as WAV (`audio/wav`) because the gateway avoids lossy audio transcode overhead. If you request `pcm`, it returns standard 24 kHz 16-bit mono PCM.
- If your Google key fails or runs out of credits, the request fails with `customer_key_rejected` or `provider_failed`. It will never silently fall back to platform billing.

To review complete parameters and gateway details, consult the [AI documentation](https://thelastapi.dev/docs/ai).

To start generating speech for your app, create your account at [thelastapi.dev/start](https://thelastapi.dev/start) to receive your developer key.

## Frequently asked questions

### What is the maximum character limit for a single text-to-speech request?

Each speech generation request accepts a maximum input length of 4,096 characters. For longer passages, split your text into multiple requests and join or stream the resulting audio files.

### Where are generated MP3 files stored after the API call completes?

When called with a project key, generated speech files are automatically saved in your project's Files storage with a permanent URL returned in the `X-Vibiz-File-Url` header. If called with an account key that lacks a project identifier, the audio URL expires after 24 hours.

### How do I choose between vibiz/voice and vibiz/voice-lite?

Use `vibiz/voice-lite` when your app demands lower latency or requires multilingual synthesis across its supported 32 languages at $0.04 per 1,000 characters. Use `vibiz/voice` when conversational, natural inflection in real-time interactions is your top priority.

---

Published 2026-11-15 · https://thelastapi.dev/blog/text-to-speech-api-pricing
