Sarvam AI
Vercel AI SDK logo

Sarvam + Vercel AI SDK

Developer Tools

The sarvam-ai-sdk community provider wraps Sarvam chat, text to speech, speech to text, translation, transliteration, and language identification behind the standard generateText, generateSpeech, and transcribe functions.

Sarvam APIs supported
saaras:v4

Speech-to-Text

Accurate transcription built for Indian accents, dialects, and real-world audio with speaker diarisation.

bulbul:v4-flash

Text-to-Speech

Natural, expressive voices in 10 Indian languages and English, for conversational agents, dubbing, and accessibility.

sarvam-105b

Language model

Multilingual model with support for Indian languages, for text generation and reasoning.

Sarvam Translate

Translation

High-quality translation across 12+ Indian languages, optimised for conversational and enterprise content.

How it works
1.

Install the provider

Add sarvam-ai-sdk and pin the matching AI SDK major version with ai@7.

2.

Add your API key

Set SARVAM_API_KEY in a .env file with a key from indus.sarvam.ai. The provider reads it automatically.

3.

Call the standard AI SDK functions

Import sarvam from sarvam-ai-sdk and pass it to generateText, generateSpeech, or transcribe.

Quick start
Install
Bash
npm install sarvam-ai-sdk ai@7
Code
JavaScript
import { sarvam } from "sarvam-ai-sdk";
import { generateText } from "ai";

const { text } = await generateText({
  model: sarvam("sarvam-105b"),
  prompt: "Translate this to malayalam: 'Keep cooking, guys'",
});

console.log(text); // പാചകം തുടരൂ, സുഹൃത്തുക്കളേ
Best practices

Pin the ai major version

sarvam-ai-sdk 0.4.x tracks AI SDK 7. Installing ai@latest can pull in an incompatible major version and cause type and runtime errors.

Raise maxOutputTokens for long answers

Output length is capped by default. Check that finishReason is not "length" to catch responses that stop mid-sentence.

Use Output.object for structured output

Prefer generateText with Output.object. generateObject still works but is deprecated in the AI SDK.

Send text through the right field

Translation, transliteration, and language identification act only on prompt and user messages. System and assistant messages pass through unchanged.

Use cases

Full-stack

Full-stack apps

Add chat, text to speech, and speech to text to Next.js and other TypeScript apps without switching SDKs.

Tool-calling

Tool-calling agents

Build agents with function calling and structured output through the standard AI SDK interfaces.

Multilingual

Multilingual voice features

Combine speech to text, translation, and text to speech behind one provider for products in Indian languages.

Resources and details
Type Community provider
Language TypeScript
Maintained by Sarvam
Install npm install sarvam-ai-sdk ai@7

Ready to build? Follow the Vercel AI SDK guide in the Sarvam docs.