mcpField
C
chat

chat

github.com/sarvamaiDevelopment72174 installsUpdated today
Repository

About chat

A Sarvam AI chat-completions skill for developers using the Python or JavaScript/TypeScript SDKs. It covers streaming, model selection, OpenAI-compatible calls, and API usage caveats.

Key features

  1. 01Python and JS/TS usage examples
  2. 02Streaming chat completions
  3. 03Sarvam chat model guidance
  4. 04OpenAI-compatible call pattern
  5. 05Reasoning and token caveats

Use cases

  1. 01Adding Sarvam chat completions to an application
  2. 02Receiving generated content incrementally
  3. 03Selecting models for chat or reasoning tasks

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/sarvamai/skills --skill chat

After installing, type/chatin Claude Code to confirm it loaded.

Details

From the project README

Chat Completions — Sarvam AI

Live in-chat completion → sarvam-mcp (sarvam_tools_llm_complete). This skill = SDK code.

Important

Auth: api-subscription-key header — NOT Authorization: Bearer. Base URL: https://api.sarvam.ai/v1

Models

ModelContextBest For
sarvam-105b128KComplex reasoning, coding, agentic workflows
sarvam-105b-conversations32KReal-time chat, voice agents, conversational AI

sarvam-30b is deprecated — migrate to sarvam-105b for complex tasks or sarvam-105b-conversations for real-time/voice (the model built to fill sarvam-30b's old slot). The fixed-context variants (sarvam-105b-32k, sarvam-30b-16k) are retired — base models serve their full context window directly.

Also available (beta, on /v2/chat/completions): open-weight models glm5.3 (1M context, reasoning), deepseekv4-flash (1M context, reasoning), gemma4 (131K context, text+image, no reasoning). Requires beta access on your API key. Called via client.chat.completions_v2(...) in Python — not .completions(). Still under beta and expected to GA soon — see Full Docs for details.

Quick Start (Python)

from sarvamai import SarvamAI
client = SarvamAI()

response = client.chat.completions(
    model="sarvam-105b-conversations",
    messages=[{"role": "user", "content": "भारत की राजधानी क्या है?"}]
)
print(response.choices[0].message.content)
Streaming (Python)
for chunk in client.chat.completions(
    model="sarvam-105b-conversations",
    messages=[{"role": "user", "content": "Write a poem about India"}],
    stream=True
):
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)

Quick Start (JavaScript/TypeScript)

import { SarvamAIClient } from "sarvamai";

const client = new SarvamAIClient({ apiSubscriptionKey: "YOUR_SARVAM_API_KEY" });

const response = await client.chat.completions({
    model: "sarvam-105b-conversations",
    messages: [{ role: "user", content: "भारत की राजधानी क्या है?" }]
});
console.log(response.choices[0].message.content);
OpenAI-Compatible (both languages)
from openai import OpenAI
client = OpenAI(api_key="your-key", base_url="https://api.sarvam.ai/v1")
response = client.chat.completions.create(model="sarvam-105b-conversations", messages=[...])

Gotchas

GotchaDetail
SDK methodPython: client.chat.completions(...), JS: client.chat.completions({...}) — no .create() in either. OpenAI SDK uses .create() as usual.
JS constructornew SarvamAIClient({ apiSubscriptionKey: "..." }) — NOT SarvamAI(). Key is passed explicitly.
content can be NoneModels produce reasoning_content before content. If max_tokens is too low, reasoning consumes the budget, finish_reason is "length", and content is None. Omit max_tokens, set 500+, or disable reasoning with reasoning_effort=None. Check reasoning_content as fallback. Verified live: this is real and a little flaky — the same short prompt at max_tokens=500 returned content=None once and content="OK" on retry, with reasoning eating 251 of the 500 tokens that time. Don't treat 500 as a guarantee; check reasoning_content/finish_reason regardless.
reasoning_effortThinking is on by default at "low". Values: "low"|"medium"|"high", or None to disable reasoning entirely. NOT thinking=True. Reasoning tokens count toward completion tokens and billing.
sarvam-30b now hard-errors, not just "deprecated"Verified live: calling it returns 400 invalid_request_error — "Model 'sarvam-30b' has been deprecated. Please use one of the available models instead: sarvam-105b, sarvam-105b-conversations." It's not a soft warning; existing code on sarvam-30b is already broken. Migrate to sarvam-105b or sarvam-105b-conversations.
Open-weight models: Python-only for nowglm5.3 / gemma4 / deepseekv4-flash go through client.chat.completions_v2(...) on /v2/chat/completions in Python (verified working, all three, with a beta-enabled key). Verified live: the installed JS SDK ([email protected]) has no completionsV2 method at all (client.chat.completionsV2 is not a function) — only .completions() exists in JS right now. Don't generate JS code calling completionsV2 until the JS SDK ships it; check npm ls sarvamai / the changelog first.

Full Docs

Fetch detailed parameters, tool calling, streaming, and examples from:

Comments

Markdown supported