Skip to content

๐ŸŒŒ Python SDK v3.0.0 (luxur-ai) โ€‹

The official LuxurAI Python SDK (v3.0.0) gives developers direct, idiomatic access to LuxurAI's platform capabilities: 322 neural voice models across 142 languages, real-time LLM token streaming with client-side punctuation chunking, unified generation history, smart chat orchestration, and code synthesis.

NOTE

What's New in v3.0.0

  • 322 Neural Voice Models: Full catalog integration with instant voice discovery and filtering across 142 languages and regional accents.
  • Real-Time Punctuation Chunking (type="chunk"): Real-time text-to-speech auto-chunked by sentence boundaries for ultra-low latency LLM voice agents.
  • Direct Speaker Playback (.play): Native audio playback through computer speakers with zero external audio driver dependencies.
  • Clean Architecture: Legacy image generation pipelines have been completely phased out in favor of optimized neural voice, agentic coding, and language modeling workflows.

๐Ÿ“ฆ Installation โ€‹

Install the package directly from PyPI:

bash
pip install --upgrade luxur-ai

Verify the installation:

python
import luxurai
print(luxurai.__version__) # 3.0.0

๐Ÿ”‘ Initialization & Authentication โ€‹

You can use the SDK with either global module configuration (ideal for scripts and single-tenant applications) or an object-oriented Client instance (ideal for async or multi-tenant services).

1. Global Module Configuration โ€‹

python
import luxurai

# Set your API Key globally (lxr_v1_...)
luxurai.LuxurKey = "lxr_v1_your_api_key_here"

2. Client Instance Configuration โ€‹

python
from luxurai import LuxurAI

client = LuxurAI(api_key="lxr_v1_your_api_key_here")

Or as a context manager:

python
with LuxurAI(api_key="lxr_v1_your_api_key_here") as client:
    client.voice.play("Context manager ready!", gender="female")

๐ŸŽ™๏ธ Neural Voice Synthesis (luxurai.voice) โ€‹

1. Synthesize Speech (.speak) โ€‹

Convert text into natural human speech and save directly to an audio file or inspect metadata:

python
import luxurai

luxurai.LuxurKey = "lxr_v1_your_api_key_here"

audio = luxurai.voice.speak(
    text="เคจเคฎเคธเฅเคคเฅ‡! LuxurAI v3.0.0 เคฎเฅ‡เค‚ เค†เคชเค•เคพ เคธเฅเคตเคพเค—เคค เคนเฅˆเฅค",
    gender="female",      # "female" | "male"
    lang="hi",            # Language code or "auto"
    speed=1.0,            # 0.5 to 2.0
    save_to="welcome.mp3" # Save directly to local file
)

print(f"Model used:     {audio.model_used}")
print(f"Audio duration: {audio.duration:.2f}s")
print(f"Cost charged:   {audio.cost_lc} LC")
print(f"Balance left:   {audio.balance_lc} LC")
print(f"Permanent URL:  {audio.audio_url}")

2. Direct Speaker Playback (.play) โ€‹

Play audio directly through system speakers with zero audio player setup:

python
luxurai.voice.play(
    "Hello world! This audio plays straight out of your speakers.",
    gender="female",
    lang="en"
)

3. Real-Time LLM Token Streaming (type="chunk") โ€‹

When generating text from an LLM token-by-token, use type="chunk" to eliminate wait times:

  • Words are buffered locally until punctuation marks (., !, ?, ,, \n).
  • The phrase is instantly sent to the server for audio synthesis.
  • The returned audio plays through the speakers while the LLM continues generating!
python
import luxurai

luxurai.LuxurKey = "lxr_v1_your_api_key_here"

def stream_llm_response():
    tokens = ["Hello", " there!", " Welcome", " to", " LuxurAI", " real-time", " voice", " streaming."]
    for token in tokens:
        yield token

# Auto-chunks by punctuation and plays each sentence chunk seamlessly
luxurai.voice.play(
    stream=stream_llm_response(),
    type="chunk",
    gender="female",
    lang="en"
)

4. Discover the 322 Voices (.list_voices) โ€‹

Explore and filter available neural voices by language or gender:

python
# Discover all Hindi voices
voices = luxurai.voice.list_voices(lang="hi", gender="female")
for v in voices:
    print(f"{v['name']} ({v['gender']}): {v['friendly_name']}")

๐Ÿ’ฌ Smart Chat Orchestration (luxurai.chat) โ€‹

Communicate directly with LuxurAI's high-speed routing engine:

python
reply = luxurai.chat.orchestrate(
    message="Explain the difference between asyncio tasks and threads in Python",
    complexity="medium"
)

print(reply["response_to_user"])

๐Ÿ’ป Autonomous Code Synthesis (luxurai.code) โ€‹

Synthesize clean, production-grade code:

python
code = luxurai.code.generate(
    prompt="Write a high-performance Redis rate-limiter in Python using asyncio",
    language="python"
)

print(code["code"])

๐Ÿ—‚๏ธ Unified Generation History (luxurai.history) โ€‹

Inspect past generations across voice, code, and chat:

python
# List the last 20 voice generations
history = luxurai.history.list(type="voice", limit=20)

for item in history.get("history", []):
    print(item["id"], item["created_at"], item["text"], item.get("audio_url"))

๐Ÿ”’ Ghost Mode (store_voice=False) โ€‹

To synthesize audio without saving the text or recording in history or cloud storage:

python
audio = luxurai.voice.speak(
    text="This is a confidential audio prompt that will not be stored.",
    gender="female",
    store_voice=False
)

Released under the MIT License.