Official Python SDK for LawSaathi Legal AI API — DELTA
Project description
LawSaathi Python SDK
Official Python client for the LawSaathi Legal AI API — powered by DELTA, India's most advanced Legal AI.
Installation
pip install lawsaathi
# With WebSocket streaming support:
pip install lawsaathi[websocket]
Quick Start
from lawsaathi import LawSaathi
client = LawSaathi(api_key="ls_live_your_api_key_here")
# Ask any legal question
response = client.chat("What is IPC Section 302?")
print(response['response'])
print(f"Tokens used: {response['usage']['total_tokens']}")
print(f"Cost: ₹{response['usage']['cost_rupees']}")
File Attachments (OpenAI-style)
Attach files to your queries — just pass file paths. The SDK handles uploading automatically.
# Analyze a contract — just pass the file path!
response = client.chat(
"Summarize the key clauses in this contract",
files=["contract.pdf"]
)
print(response['response'])
# Multiple files work too
response = client.chat(
"Compare these two agreements",
files=["agreement_v1.pdf", "agreement_v2.pdf"]
)
Streaming (WebSocket)
# Requires: pip install lawsaathi[websocket]
for chunk in client.stream("Explain bail provisions under CrPC"):
print(chunk, end="", flush=True)
# Streaming with files
for chunk in client.stream("Analyze this document", files=["contract.pdf"]):
print(chunk, end="", flush=True)
Check Balance
balance = client.get_balance()
print(f"Balance: ₹{balance['balance_rupees']}")
print(f"Tokens available: {balance['tokens_available']:,}")
Error Handling
from lawsaathi import (
LawSaathi,
AuthenticationError,
RateLimitError,
InsufficientCreditsError,
APIError,
)
client = LawSaathi(api_key="ls_live_your_key")
try:
response = client.chat("Hello")
except AuthenticationError:
print("Invalid API key — check or regenerate it")
except InsufficientCreditsError as e:
print(f"Not enough credits. Balance: ₹{e.balance_rupees}")
except RateLimitError as e:
print(f"Rate limited. Retry after: {e.retry_after}s")
except APIError as e:
print(f"API error ({e.status_code}): {e}")
Pricing
| Cost per 1M tokens | ₹998 |
| Free credits on signup | ₹100 |
| Minimum topup | ₹999 |
| Credit expiry | 150 days |
Rate Limits
| Limit | Default |
|---|---|
| Requests/minute | 5 |
| Requests/day | 2,500 |
| Max file size | 100 MB |
Need higher limits? Contact support@lawsaathi.com.
Requirements
- Python 3.8+
requestslibrary (installed automatically)websocket-client(optional, for streaming)
Links
- Dashboard: lawsaathi.com/developer
- API Docs: lawsaathi.com/docs
- Support: support@lawsaathi.com
License
MIT License — see LICENSE for details.
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 lawsaathi-1.0.0.tar.gz.
File metadata
- Download URL: lawsaathi-1.0.0.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56fa9f5fb06dd99bb849fc9eefc61dab9998d0b08e37a7122ece70b81b916906
|
|
| MD5 |
fd8108cc133f1819763abc7e6cf58f4d
|
|
| BLAKE2b-256 |
d0ce5aa0bb32754472dec3ff0c2942676e5d01bdd79d008da75c4bfaaef4fb4b
|
File details
Details for the file lawsaathi-1.0.0-py3-none-any.whl.
File metadata
- Download URL: lawsaathi-1.0.0-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05fb70d146a557475d84aa698f5cd43baae98fbacb6af27b9cfd243c69d2c7d1
|
|
| MD5 |
f5ea33621a61948d45fd4530bf37d506
|
|
| BLAKE2b-256 |
1164632921642d3d343aa4fdbf2dd2206c099d8e72f53c8c54fbcb3ff763ac7e
|