Skip to main content
The golden rule: call Geko from your server, and let your frontend call your server. The API now allows cross-origin browser calls (CORS), but that doesn’t make it safe to expose your key — a key shipped to the client is public. Keep it on the server.
This applies to both directions: synthesis and transcription use the same billable key, so both belong behind your backend.

Next.js (App Router)

A route handler that proxies synthesis. The key never leaves the server.
app/api/tts/route.ts
Call it from a client component:

Express

Accepting an upload to transcribe

The other direction: take a file from the browser and hand the bytes to stt.transcribe(). Same client, same key.
app/api/transcribe/route.ts
From the client:
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.