TNSAAI Python Client
A powerful, OpenAI-compatible Python SDK for TNSA NGen3 Pro and Lite Models.
Installation
pip install tnsaai-client
Quick Start
from tnsaai import TNSA
# Initialize the client
client = TNSA(api_key="your-api-key", base_url="https://api.tnsaai.com")
# Create a chat completion
response = client.chat.create(
model="NGen3.9-Pro",
messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)
Streaming
stream = client.chat.create(
model="NGen3.9-Lite",
messages=[{"role": "user", "content": "Tell me a story"}],
stream=True
)
for chunk in stream:
if chunk.content:
print(chunk.content, end="")
Async Usage
import asyncio
from tnsaai import AsyncTNSA
async def main():
async with AsyncTNSA(api_key="your-api-key") as client:
response = await client.chat.create(
model="NGen3.9-Pro",
messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)
asyncio.run(main())
Available Models
- NGen3.9-Pro - High-performance model for complex tasks
- NGen3.9-Lite - Fast, efficient model for general use
- Farmvaidya-Bot - Agricultural domain-specific model
Configuration
Set your API key as an environment variable:
export TNSA_API_KEY="your-api-key"
export TNSA_BASE_URL="https://api.tnsaai.com"
Or pass it directly:
client = TNSA(
api_key="your-api-key",
base_url="https://api.tnsaai.com"
)
Features
- ✅ OpenAI-compatible API
- ✅ Synchronous and asynchronous clients
- ✅ Streaming responses
- ✅ Comprehensive error handling
- ✅ Automatic retries with exponential backoff
- ✅ Usage tracking and cost estimation
- ✅ Conversation management
- ✅ Type hints and IDE support
Support
- Email: info@tnsaai.com
- Documentation: https://docs.tnsaai.com
- Issues: https://github.com/tnsaai/tnsaai-python/issues
Metadata
Release files for tnsaai-client 1.0.1
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 |
|---|---|---|---|---|
| tnsaai_client-1.0.1.tar.gz | 17.0 kB | Without provenance | Details for tnsaai_client-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tnsaai_client-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for tnsaai_client-1.0.1-py3-none-any.whl |
Total release size: 38.3 kB
Release files / tnsaai_client-1.0.1.tar.gz
| Download URL | tnsaai_client-1.0.1.tar.gz |
|---|---|
| Size | 17.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
28d7c57b8538171ee04e766ca0795701586afd213cbaf98749665aa06126893b
|
|
BLAKE2b-256 checksum How to use checksums |
c170835fc261c8a4f79acc5ea77e062e5d30bfca61ff3c4c6c067b611dd9cd06
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.5
|
Release files / tnsaai_client-1.0.1-py3-none-any.whl
| Download URL | tnsaai_client-1.0.1-py3-none-any.whl |
|---|---|
| Size | 21.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5d0a2a4df982c16bfa404043b8e90b9b4dc4a22a83d1139c1380ef64d63fb686
|
|
BLAKE2b-256 checksum How to use checksums |
48139eeb136533ba69aab30437fa13804d6437984323fcb1f482000c64a6eeb6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.5
|
Security for tnsaai-client 1.0.1
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.