Sarvam AI
SarvamLLMService streams chat completions from Sarvam AI through its OpenAI-compatible API.
Overview
Sarvam AI's models for Indian languages, over an OpenAI-compatible API (sarvam-105b, plus a few hosted open models).
SarvamLLMService: anOpenAILLMServicesubclass with Sarvam AI's base URL and default model.
Upstream page
Pipecat's documentation for the same service.
Source
packages/sarvam/src/llm.ts.
Sarvam docs
Models and the API reference.
Installation
bun add @pipedog/sarvamIt depends on @pipedog/openai, which is installed with it.
import { SarvamLLMService } from "@pipedog/sarvam/llm";Prerequisites
- A Sarvam account and an API key from the Sarvam dashboard.
- Pass the key as
apiKey. It is required, and the service never falls back toOPENAI_API_KEY. The examples read it fromSARVAM_API_KEY.
SarvamLLMService
Configuration
Prop
Type
The other options (organization, project, defaultHeaders, serviceTier,
retryOnTimeout, retryTimeoutSecs, function calling) are OpenAILLMService's. See
OpenAI.
| Base URL | https://api.sarvam.ai/v2 |
| Default model | sarvam-105b |
| Models to try | sarvam-105b, sarvam-105b-conversations, gemma4, glm5.3, deepseekv4.1-flash. See the provider's catalog for the rest. |
Settings
Runtime-updatable settings, passed as settings: new SarvamLLMService.Settings({...})
(SarvamLLMSettings). They are OpenAI's settings, with these
defaults:
| Setting | Type | Default | Description |
|---|---|---|---|
model | string | "sarvam-105b" | Model name. |
wikiGrounding | boolean | null | null | Sent as wiki_grounding when set. Only sarvam-105b and gemma4 support it. |
reasoningEffort | "low" | "medium" | "high" | null | null | Sent as reasoning_effort when set, on the models that reason. |
Every other setting keeps OpenAI's default. Unset sampling settings are left out of the request, so
the provider's own defaults apply. extra carries provider-specific request fields.
Usage
import { LLMUpdateSettingsFrame } from "@pipedog/core/frames/frames";
import { SarvamLLMService } from "@pipedog/sarvam/llm";
const llm = new SarvamLLMService({
apiKey: process.env.SARVAM_API_KEY ?? "",
settings: new SarvamLLMService.Settings({
model: "sarvam-105b",
systemInstruction: "You are a helpful assistant in a voice conversation.",
}),
});Ground answers in Wikipedia and set the reasoning effort:
const grounded = new SarvamLLMService({
apiKey: process.env.SARVAM_API_KEY ?? "",
settings: new SarvamLLMService.Settings({
model: "sarvam-105b",
wikiGrounding: true,
reasoningEffort: "low",
}),
});Change settings mid-call with an LLMUpdateSettingsFrame. The next completion uses them:
// Queue it on the worker, or push it from a processor upstream of the service.
const update = new LLMUpdateSettingsFrame({
delta: new SarvamLLMService.Settings({ temperature: 0.2 }),
});Notes
- Runs a completion for each
LLMContextFrame, between anLLMFullResponseStartFrameand anLLMFullResponseEndFrame, and streams the reply asLLMTextFrames, asOpenAILLMServicedoes. Function calls, token usage metrics andrunInferencework the same way. - "developer" messages are sent as "user" messages, since the API doesn't support that role (
supportsDeveloperRoleisfalse). - Only
deepseekv4.1-flash,gemma4,glm5.3,sarvam-105bandsarvam-105b-conversationsare accepted as the model. Any other raises when the service is constructed. - When you don't pass
baseUrl, it is chosen from the model:/v1forsarvam-105b-conversationsand/v2for the rest. - A context that a model can't serve (an image for a model without vision, say) fails with a non-fatal
ErrorFrame, not an exception, so anLLMSwitchercan fall back to another service. - The same package has Sarvam's speech-to-text and text-to-speech services.
Runtime notes
| Runtime | Works | What it needs |
|---|---|---|
| Bun | ✅ yes | Nothing. |
| Node.js | ✅ yes | Nothing. |
| Deno | ✅ yes | Nothing. |
| Cloudflare Workers | ✅ yes | Nothing. |
Generated from pipecat.runtimes and pipecat.compat in packages/sarvam/package.json: ✅ means the compat smoke test passes on that runtime.
- The client is the official
openaiJS SDK (through@pipedog/openai), which talks throughfetch. It works on Bun, Node, Deno and Cloudflare Workers. - The deprecated
modelconstructor option is not ported. Usesettings. - Tested against a local OpenAI-compatible mock server, not against Sarvam AI itself.
pipedog is an unofficial community TypeScript port of Pipecat. It is not affiliated with or endorsed by Daily or the Pipecat project.
Portions adapted from the Pipecat documentation, Copyright (c) 2024–2025 Daily, BSD-2-Clause (see apps/docs/LICENSE-pipecat-docs).