Skip to main content
Apidly Cloud
Cookie policy

Analytics and ad cookies stay off unless you accept. Cookie policy

We would like to use Google Analytics and Microsoft Clarity to understand how the public pages are used, including page views and session recordings, and the Reddit Pixel to measure whether our ads on Reddit lead to visits and sign-ups. You choose here whether they are on. Rejecting changes nothing about how the site works.

Turn text into speech with Kokoro on a cloud GPU

Run Kokoro text to speech on a rented GPU with a web page and an OpenAI-style API: narrate a whole text file, copy the audio home and stop paying.

Published November 27, 20265 min read

Text to speech is no longer a robotic voice. Kokoro is a small open model that reads text aloud with natural-sounding voices in several languages, and it needs far less GPU memory than a language model. On a rented GPU you start a server that gives you a web page and an API, turn a script, an article or a whole book into audio files, copy them home and stop the server, paying by the second only while it runs. This guide shows how.

When this is worth it

  • Narration for videos, courses or podcasts where you have the script and want an audio file.
  • Reading articles or documents aloud, in bulk.
  • An app that needs a voice, with the speech API behind it. The API follows the OpenAI speech format, so code written for that format needs a new address and key.

For one short sentence, a free browser voice is enough. A rented server pays off when you have a lot of text, want the same voice every time, or want to call it from your own code.

What you need

  • An Apidly account with some credit.
  • Your text. Read the voice and licence terms that apply to how you will use the audio, and do not present a synthetic voice as a real person.
  • A terminal with curl; Python 3 with the requests package is optional, for the loop in step 4.
  • No SSH key: the page and the API are used over the web.

Step 1: Choose the GPU

The Kokoro template needs at least 4 GB of GPU memory (VRAM) and recommends 8 GB, so a small, cheap card is enough. The model is already inside the image, which makes the first start quick. The template does not run on RTX 50-series and other Blackwell GPUs; Deploy marks those configurations.

Prices follow supply and change often. In our public price list on 27 November 2026 at 07:11 UTC, a single GTX 1070 (8 GB) was $0.094 per hour and an RTX 3060 (12 GB) was $0.137 per hour, both available. Check live pricing before you plan a run.

Step 2: Start the server

  1. Open Deploy, sort by Price, low to high and pick a configuration with at least 8 GB of GPU memory. Select Continue.
  2. Select Speech above the template cards, then the Kokoro text-to-speech card, then Continue.
  3. Name the server, for example kokoro-voice. Leave KOKORO_API_KEY empty and the platform creates a key for this server. The suggested disk size is enough for text and audio.
  4. On the review step check Per hour, keep the automatic stop under Automation (optional) on, and select Start my server.

Some new servers are reviewed by our team first; you are not charged until the server runs.

Step 3: Try the web page

  1. Open the server and select the Connect tab.
  2. Under Sign in with you see the user name admin and the API key. Show and copy the key.
  3. Select Open app and add /web to the end of the address. The browser asks for a user name and password: enter admin and the key.

On the page, choose a voice, type a sentence and generate it. Try several voices and languages; the page lists those the model has. Voices differ in language, so match the voice to the language of your text.

Step 4: Use the API

The API is on the same address and port. Copy the App address from the Connect tab; below it is SERVER_ADDRESS, and the key is YOUR_KEY. One sentence to a file:

curl http://SERVER_ADDRESS/v1/audio/speech \
  -H "Authorization: Bearer YOUR_KEY" -H "Content-Type: application/json" \
  -d '{"model": "kokoro", "input": "Hello from a rented GPU.", "voice": "af_heart"}' \
  --output hello.mp3

Open hello.mp3 to listen. If it is only a few bytes, open it in a text editor: it is an error message, for example a wrong key.

Narrate a whole text file

Put your text in script.txt with one paragraph per line. This script sends each paragraph on its own and saves one audio file per paragraph, so a failure loses one paragraph and not the whole job. It uses only Python's requests package:

import pathlib
import requests

URL = "http://SERVER_ADDRESS/v1/audio/speech"
HEADERS = {"Authorization": "Bearer YOUR_KEY"}

lines = [l.strip() for l in pathlib.Path("script.txt").read_text(encoding="utf-8").splitlines()]
out_dir = pathlib.Path("audio")
out_dir.mkdir(exist_ok=True)

for i, text in enumerate(lines, start=1):
    if not text:
        continue
    out = out_dir / f"{i:04d}.mp3"
    if out.exists():
        continue  # already done, so a rerun picks up where it stopped
    r = requests.post(
        URL,
        headers=HEADERS,
        json={"model": "kokoro", "input": text, "voice": "af_heart"},
        timeout=300,
    )
    if r.ok:
        out.write_bytes(r.content)
        print("done", out.name)
    else:
        print("failed", out.name, r.status_code)

Listen to the first files before you convert the rest: check names, numbers, abbreviations and foreign words, which any speech model can get wrong. Fix them in the text, for example by spelling a number out, and run again. Join the files into one with any audio editor or with ffmpeg.

Keep it private

The server uses plain http, so your text and the key travel unencrypted. Do not send confidential text over a network you do not trust, and do not share the key. The service runs on third-party machines operated by independent, verified hosting providers, so for text you must not expose, use your own hardware. If the key leaks, destroy the server and start a new one.

Control the cost

A server has two charges: compute while it runs, and the disk for as long as it exists. A made-up example, to show the arithmetic and not a measurement: a 1-hour session on an RTX 3060 at $0.137 per hour with the template's 30 GB disk at $0.000706 per GB per hour is about $0.14 for compute plus $0.02 for the disk, about $0.16 in total.

  • Convert in one sitting, then stop. Stopping ends the compute charge; the disk is still billed.
  • Copy your audio out first. Your script writes the files on your own computer, so nothing is left behind. Anything only on the server is lost when you destroy it.
  • Add an automatic stop. See Automation.
  • Destroy when the job is done. That ends every charge.

How billing by the second works has more worked examples, and Control costs covers budgets and warnings.

Common problems

  • 401 Unauthorized. The header must be Authorization: Bearer YOUR_KEY, with the word Bearer and a space.
  • The page does not load. Add /web to the address, and check that the server shows Running.
  • The voice mispronounces a word. Respell the word in the text, or split a very long sentence.
  • The address stopped working after a restart. Copy it again from the Connect tab after Start.

Next steps

To go the other way and turn audio into text, see Transcribe audio with Whisper. To chat with a model and have it read the answers, combine this with a private chat server. When you are ready, start a Kokoro server.

Try what this guide shows

Start one of these templates on a rented GPU server. You see the price per hour before you start, and you pay by the second.

Try it on a real GPU server

Create a free account and add a balance from $10. Servers are billed by the second, and the review step shows the price per hour before you request one.

Related guides