Build production-ready voice AI agents with TypeScript and Next.js

Layercode is voice AI infrastructure for developers. We handle WebSockets, voice activity detection, and global edge deployment—you focus on your agent's logic.

npx @layercode/cli init
$100 free credits. No credit card required. Read the docs

"Voice AI has unique infrastructure demands that traditional cloud architectures aren't built for. By leveraging Cloudflare, the Layercode team delivers the most performant and low-latency voice AI platform that scales."

— Dane Knecht, CTO at Cloudflare

Voice AI demos are easy. Production is hard.

You built a working prototype in a weekend. But when real users start talking to your agent, everything breaks:

The agent lags and users talk over it
Turn-taking feels robotic
It mispronounces your customer's brand
Calls fail and you have no idea why
Scaling means rewriting your entire infrastructure

The gap between "cool demo" and production-ready voice AI is months of work: WebSocket connection management, voice activity detection tuning, global edge deployment, session recording, and observability tooling. Layercode closes that gap.

Not a visual builder. Not a framework. Just infrastructure.

More control than Vapi or Retell

Visual workflow builders work until your logic gets complex. Then you're fighting the platform instead of building your product. Layercode gives you a webhook. Write TypeScript. Ship.

Simpler than LiveKit or Pipecat

Open-source frameworks give you control, but you're signing up for months of WebRTC, TURN servers, and audio pipeline debugging. Layercode handles the infrastructure. You handle the intelligence.

More flexible than OpenAI Realtime

Realtime LLM APIs are black boxes. You can't swap models mid-conversation, control prompts dynamically, or use your own fine-tuned LLM. Layercode calls YOUR backend. You control everything.

Workflow

Your backend. Our infrastructure.

Layercode handles real-time audio streaming. You handle the conversation.

Step 01

User speaks

Your user talks into their browser, phone, or mobile app. Layercode captures the audio stream at the nearest edge location and runs speech-to-text in real-time.

Step 02

Your backend responds

We send transcribed text to your webhook. You process it with any LLM: OpenAI, Anthropic, Google, open-source models, etc. Stream your response back using our SDK.

Step 03

User hears the response

Layercode converts your text to speech and streams audio back to the user. The entire round-trip happens in under a second.

You receive text, you send text. No audio processing, no WebSocket management, no VAD tuning.

Works with any LLM. OpenAI, Claude, Gemini, Llama, Mistral, etc. Use whatever model fits your use case.

Deploy your backend anywhere. Vercel, AWS, Railway, your own servers. Layercode connects to it via webhook.

Add voice to your Next.js app in under 50 lines

Layercode's Node.js SDK integrates with the tools you already use. Here's a complete voice agent backend using the Vercel AI SDK:

import { createGoogleGenerativeAI } from "@ai-sdk/google";
import { streamText } from "ai";
import { streamResponse } from "@layercode/node-server-sdk";

export const POST = async (request: Request) => {
  const google = createGoogleGenerativeAI();
  const body = await request.json();

  return streamResponse(body, async ({ stream }) => {
    if (body.type === "message") {
      const { textStream } = streamText({
        model: google("gemini-2.0-flash-001"),
        system: "You are a helpful voice assistant for Acme Corp.",
        messages: [{ role: "user", content: body.text }],
        onFinish: () => stream.end(),
      });
      
      await stream.ttsTextStream(textStream);
    }
  });
};

Works with the LLM libraries you already use

Vercel AI SDK
LangChain LlamaIndex Ollama Groq

Everything you need to ship voice AI

Hot-swap voice providers

Avoid vendor lock-in: Switch between Deepgram, ElevenLabs, Cartesia and Rime with a single config change. Test different models, optimize for cost or quality.

Analytics & Observability

Replay any conversation. Inspect latency breakdowns, and view transcripts to debug production issues.

Session recording

Every call is recorded automatically. Download audio files, export transcripts, build training datasets. All stored securely.

Per-second billing

Pay only for active conversation time. Silence is always free. No minimum commitments.

Web, mobile, and phone

Connect users via browser, iOS, Android, or phone. Same backend, same pipeline, multiple channels.

Unified billing

One invoice for speech-to-text, text-to-speech, and infrastructure.

"Layercode made it very easy to build and prototype low-latency voice features for our text-based agents built with NextJS and React."

— Lance Jones, AI Agent Developer

Global Edge
INFRASTRUCTURE

330+ edge locations. Sub-50ms audio processing.

The first voice AI infrastructure built for low-latency conversations at global scale.

Traditional voice AI platforms run on centralized cloud infrastructure. When your user is in Tokyo and your servers are in Virginia, latency kills the conversation. Pauses feel unnatural. Users talk over the agent. The experience falls apart. Layercode is built on Cloudflare's global edge network. We process audio at the location nearest to your user—not in a distant data center.

330+
Edge locations worldwide
<50ms
Audio processing at edge
Zero
Cold starts
100%
Session isolation

Low-latency by default

Users connect to the nearest edge location. Speech-to-text, voice activity detection, and audio streaming happen locally—in milliseconds, not hundreds of milliseconds.

Instant, automatic scaling

No capacity planning. No provisioning. Every conversation runs in its own isolated environment that scales automatically with demand.

No noisy neighbors

Platform traffic spikes don't affect your users. Each session runs in complete isolation with dedicated resources.

Global without configuration

Deploy once, serve users everywhere. No multi-region setup, no latency-based routing rules, no infrastructure headaches.

Enterprise-ready security

Layercode is built for production workloads with enterprise security requirements. Your data is encrypted in transit and at rest. Session recordings are stored securely in SOC 2 compliant infrastructure and accessible only to your team.

SOC 2 Type II GDPR Compliant Data encrypted in transit (TLS 1.3) Data encrypted at rest (AES-256)

Simple, predictable pricing

Per-second billing for active conversation time. Silence is free. STT, TTS, and infrastructure costs consolidated into one simple rate. Start with $100 in free credits—no credit card required.

View pricing details →

Ship your first voice agent today

From zero to production-ready in under 5 minutes. $100 in free credits to get started.

npx @layercode/cli init

"Layercode unlocks a huge world of integrated voice-based interactions for apps now that LLMs can handle real-time understanding and response. Having a pre-built, scalable infrastructure ready in minutes means you can focus on crafting the actual experience rather than wrangling webhook APIs, latency, and security issues. Worth experimenting with if you're exploring next-gen conversational products."

— Josh Lannin, VP Accelerate AI, Workday