Next.js (App Router)
A route handler that proxies synthesis. The key never leaves the server.app/api/tts/route.ts
Express
Accepting an upload to transcribe
The other direction: take a file from the browser and hand the bytes tostt.transcribe(). Same client, same key.
app/api/transcribe/route.ts
Check your platform’s request body limit before accepting long audio — Vercel serverless functions cap request bodies at 4.5 MB, which is only a few minutes of WAV. For longer files, upload to storage first and pass a URL:
geko.stt.transcribe({ url }) has the server fetch it, so the audio never transits your function.Serverless notes
Cold starts: both GPU backends scale to zero, so the first request after idle can take tens of seconds. Raise your function’s max duration (e.g. Next.js
maxDuration) and keep the SDK’s default 120 s timeout. The two services warm independently.- Reuse the client: construct
new Geko(...)once at module scope, not per request. One client covers both directions. - Long text? stream it. For paragraphs or assistant replies,
geko.tts.stream()starts audio after the first sentence instead of the full render — proxy the chunks straight through. See Streaming audio. - Long audio? pass a URL. Avoids your function’s body limit and its execution time budget entirely.