Python package for Indus Chat API by Sarvam AI
Project description
PyIndus
A Python package for interacting with Indus, a ChatGPT alternative by Sarvam AI.
Installation
pip install pyindus
Or with uv:
uv add pyindus
Quick Start
IndusClient acts as a fully-featured, seamless SDK. It automatically saves, loads, and refreshes sessions for you.
1. Initial Login
Run this once to authenticate. The client will automatically save your session to indus_session.json by default.
from pyindus import IndusClient
# Login with phone number
client = IndusClient()
client.login("+91XXXXXXXXXX")
# Enter the OTP received via SMS
client.verify_otp("123456")
# The session is now authenticated and saved automatically!
2. Immediate Re-use (Like an SDK)
Run this anywhere else in your project. Because the session was saved, the client automatically loads it on __init__. If the token expires, the client will dynamically refresh it in the background.
from pyindus import IndusClient
# Automatically loads the previous session from 'indus_session.json'
client = IndusClient()
# Chat directly! No need to login again.
response = client.chat("What is quantum computing?")
print(response.answer)
Integration Guide: Custom Paths
If you're building a web app or managing multiple users, you can specify individual session files.
from pyindus import IndusClient
# Supply a unique path for the user's session
def handle_user_request(user_id, message):
session_path = f"sessions/user_{user_id}.json"
# Auto-loads and manages session in this specific file
with IndusClient(session_file=session_path) as client:
return client.chat(message)
Advanced Usage
Working with Specific Models
Indus supports different "Task Graphs" (models like Sarvam Think, Bulbul, etc.). By default, IndusClient selects the first available chat model automatically.
from pyindus import IndusClient
with IndusClient() as client:
# List available models
models = client.get_models()
for model in models:
print(f"{model.name}: {model.description}")
# Use a specific model
response = client.chat("Explain gravity", task_graph_uid=models[-1].uid)
print(response.answer)
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyindus-0.1.0.tar.gz.
File metadata
- Download URL: pyindus-0.1.0.tar.gz
- Upload date:
- Size: 130.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31820851c751fdca1dd5741cb3911290f60116a6a556a59e40888c80f75e5097
|
|
| MD5 |
75fdc859628d5acb2bfc1f0b4a23b7e4
|
|
| BLAKE2b-256 |
8fbf0e7f119fdd58e0099af400d4e1107583a6f77c8978802fa77d8b90e2b8ec
|
File details
Details for the file pyindus-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pyindus-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b81e72cdd0553f9d846a2c5c8ffc098670a006b258aff1534f58d01dd839e65a
|
|
| MD5 |
a54c91fe49a4aa1d28cd28f342258ca7
|
|
| BLAKE2b-256 |
c55cb9a31534ed4bc6c2548a76670e7981f0d554634ce4bcaafc3bb0e9449d14
|