langchain-sarvam
Overview
Integration details
| Class | Package | Local | Serializable | JS support | Downloads | Version |
|---|---|---|---|---|---|---|
| ChatSarvam | langchain-sarvam | ❌ | beta | ❌ |
Model features
| Tool calling | Structured output | JSON mode | Image input | Audio input | Video input | Token-level streaming | Native async | Token usage | Logprobs |
|---|---|---|---|---|---|---|---|---|---|
| ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ✅ | ❌ |
Integration package connecting Sarvam AI chat completions with LangChain.
Installation
with uv inside the package:
uv add langchain-sarvam
Setup
# Set the SARVAM API key
sarvam_Api_key = os.getenv("SARVAM_API_KEY")
Usage
Basic Usage
from langchain_sarvam import ChatSarvam
llm = ChatSarvam(model="sarvam-m", temperature=0.2, max_tokens=128)
resp = llm.invoke([("system", "You are helpful"), ("human", "Hello!")])
print(resp.content)
Batch Processing
from langchain_sarvam import ChatSarvam
from langchain_core.messages import HumanMessage
chat = ChatSarvam(model="sarvam-m")
# Batch processing - use list of message lists
messages = [
[HumanMessage(content="Tell me a joke")],
[HumanMessage(content="What's the weather like?")]
]
responses = chat.batch(messages)
for response in responses:
print(response.content)
Using generate() Method
from langchain_sarvam import ChatSarvam
from langchain_core.messages import HumanMessage
chat = ChatSarvam(model="sarvam-m")
# generate() expects a list of message lists
inputs = [
[HumanMessage(content="Tell me a joke with emojis only")],
[HumanMessage(content="What's the weather like?")]
]
result = chat.generate(inputs)
for generation_list in result.generations:
# generation_list is a list of ChatGeneration objects
for generation in generation_list:
print(generation.message.content)
Streaming
for chunk in ChatSarvam(model="sarvam-m", streaming=True).stream("Tell me a joke"):
print(chunk.text, end="")
Metadata
Release files for langchain-sarvam-nishant 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| langchain_sarvam_nishant-0.1.0.tar.gz | 131.5 kB | Without provenance | Details for langchain_sarvam_nishant-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| langchain_sarvam_nishant-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for langchain_sarvam_nishant-0.1.0-py3-none-any.whl |
Total release size: 142.6 kB
Release files / langchain_sarvam_nishant-0.1.0.tar.gz
| Download URL | langchain_sarvam_nishant-0.1.0.tar.gz |
|---|---|
| Size | 131.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3c10121d4884484da34ef12152b14e2773c0cce38ed224133db24677f270d2b7
|
|
BLAKE2b-256 checksum How to use checksums |
e8967e97327a2993b6c528b2b52d8e21ff77ce931f2ac5cabb57a439891a853b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.15
|
Release files / langchain_sarvam_nishant-0.1.0-py3-none-any.whl
| Download URL | langchain_sarvam_nishant-0.1.0-py3-none-any.whl |
|---|---|
| Size | 11.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4b930d3d20f0bd8b9b8ee593c4eff6c51639a66a4591e73cf915d79cb60d1031
|
|
BLAKE2b-256 checksum How to use checksums |
5c532342421348af10a129727a8915cc2188245926fd8cf73913a91a4fdfa165
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.15
|
Security for langchain-sarvam-nishant 0.1.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.