Skip to main content

A powerful, OpenAI-compatible Python SDK for TNSA NGen3 Pro and Lite Models

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tnsaai_client-1.0.1.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tnsaai_client-1.0.1-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

File details

Details for the file tnsaai_client-1.0.1.tar.gz.

File metadata

  • Download URL: tnsaai_client-1.0.1.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for tnsaai_client-1.0.1.tar.gz
Algorithm Hash digest
SHA256 28d7c57b8538171ee04e766ca0795701586afd213cbaf98749665aa06126893b
MD5 8a2ec60ec275e2d35144ef0f2de01e29
BLAKE2b-256 c170835fc261c8a4f79acc5ea77e062e5d30bfca61ff3c4c6c067b611dd9cd06

See more details on using hashes here.

File details

Details for the file tnsaai_client-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: tnsaai_client-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 21.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for tnsaai_client-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5d0a2a4df982c16bfa404043b8e90b9b4dc4a22a83d1139c1380ef64d63fb686
MD5 5f49307c60a97fafe3aa46e13ddbcf4e
BLAKE2b-256 48139eeb136533ba69aab30437fa13804d6437984323fcb1f482000c64a6eeb6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page