langchain-sarvam
The langchain-sarvam package provides a LangChain integration for Sarvam AI's language models, optimised for Indian languages and enterprise workloads.
Installation
pip install langchain-sarvam
Setup
Get your API key from Sarvam AI and set it as an environment variable:
export SARVAM_API_KEY="your-api-key"
Usage
Chat Model
from langchain_sarvam import ChatSarvam
llm = ChatSarvam(model="sarvam-105b")
# Invoke
response = llm.invoke("What is the capital of India?")
print(response.content)
# With system message
from langchain_core.messages import HumanMessage, SystemMessage
messages = [
SystemMessage(content="You are a helpful assistant."),
HumanMessage(content="Tell me about Indian languages."),
]
response = llm.invoke(messages)
print(response.content)
# Stream
for chunk in llm.stream("Count from 1 to 5."):
print(chunk.content, end="", flush=True)
# Async
import asyncio
response = asyncio.run(llm.ainvoke("Hello!"))
Available Models
| Model | Description |
|---|---|
sarvam-105b |
Flagship model — best quality (default) |
sarvam-30b |
Faster, lighter model |
Reasoning Mode
llm = ChatSarvam(model="sarvam-105b", reasoning_effort="high")
response = llm.invoke("Explain the Riemann hypothesis.")
# Access reasoning trace
print(response.additional_kwargs.get("reasoning_content"))
Supported values for reasoning_effort: "low", "medium", "high".
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
model |
str |
"sarvam-105b" |
Model name |
temperature |
float |
None |
Sampling temperature [0, 1] |
max_tokens |
int |
None |
Max tokens to generate |
top_p |
float |
None |
Nucleus sampling probability |
streaming |
bool |
False |
Enable streaming |
reasoning_effort |
str |
None |
Reasoning effort: "low", "medium", "high" |
api_key |
str |
env var | Sarvam API key |
base_url |
str |
"https://api.sarvam.ai/v1" |
Custom API base URL |
Development
# Install with dev dependencies
pip install -e ".[test]"
# Run unit tests
pytest tests/unit_tests/ -v
# Run integration tests (requires SARVAM_API_KEY)
pytest tests/integration_tests/ -v
License
MIT
Metadata
Release files for langchain-sarvam 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| langchain_sarvam-0.1.2.tar.gz | 14.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| langchain_sarvam-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 25.7 kB
Release files / langchain_sarvam-0.1.2.tar.gz
| Download URL | langchain_sarvam-0.1.2.tar.gz |
|---|---|
| Size | 14.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2a0dffb1ec152a27d2d8bc332169327ad16185212089c9b81d9aadf092c64207
|
|
BLAKE2b-256 checksum How to use checksums |
d4b4912a88315f34b23e776d286380ec19e3428a19e24fccd94b97fda3a126f3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 22, 2026.
Transparency logRelease files / langchain_sarvam-0.1.2-py3-none-any.whl
| Download URL | langchain_sarvam-0.1.2-py3-none-any.whl |
|---|---|
| Size | 11.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
175836c4aa22013acf60c9e018cdef7a0e8f50825257a30470424b5928c90e22
|
|
BLAKE2b-256 checksum How to use checksums |
5fd525b21fdab9ba9151d91d2197f6f2d1fbc4fc8c142f9903d000e735fe4afd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 22, 2026.
Transparency log