Built in

Vercel AI SDK apps with Cartesia speech and transcription

Install the AI SDK's Cartesia provider, then call generateSpeech for audio or stream a transcription with Ink 2.

install.sh
pnpm add ai @ai-sdk/cartesia

transcribe.ts
import { cartesia } from '@ai-sdk/cartesia';
import { experimental_streamTranscribe as streamTranscribe } from 'ai';

const result = streamTranscribe({
  model: cartesia.transcription('ink-2'),
  audio, // ReadableStream<Uint8Array | string> of raw audio chunks
  inputAudioFormat: { type: 'audio/pcm', rate: 24000 },
  providerOptions: { cartesia: { language: 'en' } },
});

for await (const part of result.fullStream) {
  if (part.type === 'transcript-partial') console.log('partial:', part.text);
  if (part.type === 'transcript-final') console.log('final:', part.text);
}

What you can do with Vercel AI SDK

What teams build when they put Cartesia and Vercel AI SDK together.

Speech from TypeScript

generateSpeech takes a Cartesia model, the text and a voice ID, and returns the audio to your TypeScript code.

Streaming transcription

The AI SDK's streaming transcription is experimental. It accepts Ink 2 and emits partial and final transcripts.

Realtime sessions

An experimental realtime factory runs browser sessions with a short-lived token that your server creates.

More code for Vercel AI SDK

From the AI SDK's Cartesia provider page.

speech.ts
import { generateSpeech } from 'ai';
import { cartesia } from '@ai-sdk/cartesia';
import { writeFile } from 'node:fs/promises';

const { audio } = await generateSpeech({
  model: cartesia.speech('sonic-3.5'),
  text: 'Hello, world!',
  outputFormat: 'mp3',
  voice: '694f9389-aac1-45b6-b726-9d9369183238',
});

await writeFile('speech.mp3', audio.uint8Array);

Set it up

Built in: Cartesia is a provider in the AI SDK, published as @ai-sdk/cartesia and maintained in the AI SDK's own packages. Vendor details read in October 2026.

  1. Install

    Add ai and @ai-sdk/cartesia.

  2. Set CARTESIA_API_KEY

    The provider reads it from the environment by default.

  3. Call generateSpeech

    Pass a model, your text, an output format and a voice ID.

  4. Stream a transcript

    Use experimental_streamTranscribe with the ink-2 model.

Before you build

Model IDs

The AI SDK page lists the Sonic model IDs its provider accepts. Cartesia's current model and dated snapshots are on the model page in Cartesia's docs.

Experimental pieces

The AI SDK marks streaming transcription and realtime as experimental, and their names may change.

Vercel AI SDK integration FAQs

Does the Vercel AI SDK support text to speech?

Yes. generateSpeech in the ai package turns text into audio, and @ai-sdk/cartesia adds Cartesia's Sonic models to it. Call cartesia.speech('sonic-3.5') with your text, an output format and a voice ID. The AI SDK page also lists sonic-3, sonic-2, sonic-turbo and sonic-latest.

Can the AI SDK transcribe audio with Cartesia?

Yes, two ways. The ink-whisper model handles batch transcription of recorded audio, and experimental_streamTranscribe with ink-2 streams raw audio and emits partial and final transcripts. The AI SDK marks streaming and realtime transcription as experimental, so their names may change.

Is Cartesia available through Vercel AI Gateway?

No. The AI SDK's Cartesia page says Cartesia models are not currently available through AI Gateway, so install @ai-sdk/cartesia and call it with your own CARTESIA_API_KEY, which the provider reads from the environment by default.

Who maintains the @ai-sdk/cartesia provider?

It lives in the AI SDK's own packages, published as @ai-sdk/cartesia, and Cartesia's docs describe the models it calls. Cartesia's current Sonic model and its dated snapshots are listed on the TTS models page.

What does Cartesia cost through the AI SDK?

The provider calls Cartesia's API, so you pay API credits on your plan. Sonic text to speech costs 1 credit per character, about 750 to 800 credits per minute of audio, and Ink 2 transcription costs 3 credits per second. The Free plan includes 20K credits a month, and paid plans start at $5/month.

Get started today

Talk to an expert.

Connect with a member of our team and learn how Cartesia can help you build world-class voice experiences.

Contact Sales

Start building.

Access our models via API and bring a voice agent into production in minutes.

Try Cartesia