Usage guide
Setup, environment variables, and Python/JavaScript/Go usage examples.
SarvamAILLM
Sarvam AI Large Language Model provider plugin. Wraps the Sarvam AI chat-completions API, which exposes models optimised for Indian languages (22 Indic languages + English). Unique capabilities include Sarvam-specificwiki_grounding (grounding responses in
Wikipedia-derived knowledge) and configurable reasoning_effort for
chain-of-thought depth control. The API is OpenAI-compatible and
supports streaming, tool/function calling, and structured output.
Constructor
Sarvam AI API key. Falls back to the
SARVAM_API_KEY environment variable when None.Sarvam AI model identifier. Defaults to
"sarvam-30b". Available models: "sarvam-30b": 30 B MoE model (2.4 B active params); strong reasoning and conversational capabilities at a balanced performance-to-cost ratio. "sarvam-105b": 105 B flagship model; highest quality Indian-language understanding, reasoning, and generation.Sampling temperature controlling output randomness. Range 0 – 2. Defaults to
0.7 (0.5 when reasoning is enabled, 0.2 when disabled on the API side). Lower values produce more deterministic output.Controls when the model invokes tools. Defaults to
"auto". Mirrors the OpenAI tool_choice parameter ("auto", "none", "required", or a specific tool object).Maximum number of tokens to generate in the completion. Defaults to
1024 when not set. Tier limits: Starter 4 096, Pro 8 192, Business 64 000.Nucleus-sampling probability mass cutoff. Range 0 – 1.
None uses the provider default.Penalises repeated tokens based on their cumulative frequency. Range –2.0 – 2.0.
None disables.Penalises tokens that have already appeared at least once. Range –2.0 – 2.0.
None disables.Fixed random seed for deterministic generation.
None means no fixed seed.Up to 4 stop sequences that halt generation early.
None disables.An opaque end-user identifier forwarded to the API for abuse-detection purposes.
None omits the field.When
True, the model may emit multiple tool calls in a single response turn. None uses the provider default.Structured-output specification dict (e.g.
{"type": "json_object"}). None returns plain text.Controls the depth of chain-of-thought reasoning. Valid values:
"low", "medium", "high", or None to disable reasoning entirely. Higher effort increases both quality and latency/cost since reasoning tokens are billed as completion tokens.When
True, the model grounds its responses using Wikipedia-derived knowledge, improving factual accuracy for knowledge-intensive queries. Defaults to False.aclose
cancel_current_generation
chat
The conversation history to send to the model.
Optional tool definitions the model may call.
Optional conversational graph guiding the exchange.
LLMResponse: Response chunks produced as the model generates output.
emit
The event to emit.
off
The event the handler was registered for.
The handler to remove.
on
callback is omitted.
The event to listen for.
The handler to invoke when the event is emitted. If
None, a decorator is returned that registers the decorated function.The registered callback when
callback is provided, otherwise a decorator that registers and returns the function it wraps.