Metadata-Version: 2.4
Name: lawsaathi
Version: 1.0.1
Summary: Python Client for LawSaathi - The Most Capable LEGAL AI
Home-page: https://github.com/lawsaathi/lawsaathi-python-sdk
Author: LawSaathi
Author-email: LawSaathi <support@lawsaathi.com>
License-Expression: MIT
Project-URL: Homepage, https://lawsaathi.com
Project-URL: Documentation, https://lawsaathi.com/docs
Project-URL: Repository, https://github.com/lawsaathi/lawsaathi-python-sdk
Project-URL: Dashboard, https://lawsaathi.com/developer
Project-URL: Bug Tracker, https://github.com/lawsaathi/lawsaathi-python-sdk/issues
Keywords: lawsaathi,legal-ai,indian-law,ipc,crpc,delta,ai-sdk,legal-tech,chatbot,api-client
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.25.0
Provides-Extra: websocket
Requires-Dist: websocket-client>=1.0.0; extra == "websocket"
Provides-Extra: dev
Requires-Dist: pytest>=6.0; extra == "dev"
Requires-Dist: pytest-cov>=2.0; extra == "dev"
Requires-Dist: black>=21.0; extra == "dev"
Requires-Dist: flake8>=3.9; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"
Dynamic: author
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-python

# LawSaathi Python SDK

[![PyPI version](https://img.shields.io/pypi/v/lawsaathi.svg)](https://pypi.org/project/lawsaathi/)
[![Python versions](https://img.shields.io/pypi/pyversions/lawsaathi.svg)](https://pypi.org/project/lawsaathi/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

Python Client for **LawSaathi** — The Most Capable LEGAL AI.

## Installation

```bash
pip install lawsaathi

# With WebSocket streaming support:
pip install lawsaathi[websocket]
```

## Quick Start

```python
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.

```python
# 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)

```python
# 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

```python
balance = client.get_balance()
print(f"Balance: ₹{balance['balance_rupees']}")
print(f"Tokens available: {balance['tokens_available']:,}")
```

## Error Handling

```python
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? Request a quota increase from the Developer Dashboard.

## Requirements

- Python 3.8+
- `requests` library (installed automatically)
- `websocket-client` (optional, for streaming)

## Links

- **Dashboard**: [lawsaathi.com/developer](https://lawsaathi.com/developer)
- **API Docs**: [lawsaathi.com/docs](https://lawsaathi.com/docs)

## License

MIT License — see [LICENSE](LICENSE) for details.
