Skip to main content

Official Python SDK for LuxurAI — AI image generation

Project description

LuxurAI Python SDK

Official Python client for LuxurAI — AI image generation.

Install

pip install luxur-ai

Quick Start

from luxurai import LuxurAI

client = LuxurAI(api_key="lxr_v1_xxxx")

# Generate an image
image = client.generate("a red dragon flying over mountains")
image.save("dragon.png")

Get your API key at luxurai.in → Dashboard → API Keys.


Usage

Generate image

# Auto model + auto resolution (recommended)
image = client.generate("a sunset over the ocean")
image.save("sunset.png")

# Pick resolution
image = client.generate(
    "divine krishna playing flute",
    resolution = "1152x1152",   # brainAI native — best quality
)

# Non-blocking
job = client.generate("anime girl with blue hair", wait=False)
print(f"Queue: #{job.queue_position}  ETA: ~{job.eta_seconds}s")
image = job.wait()
image.save("output.png")

Models & Resolutions (auto-discovery)

info = client.models()
print(info["models"])             # ['brainai-v1']
print(info["default"])            # 'brainai-v1'
print(info["resolutions"])        # ['512x512', '1024x1024', '1152x1152', ...]
print(info["default_resolution"]) # '1024x1024'

model="auto" always uses the latest model from the backend — no SDK update needed when new models launch.

Resolutions

from luxurai import Resolution

client.generate("a mountain", resolution=Resolution.HD)      # 1024x1024
client.generate("a mountain", resolution=Resolution.NATIVE)  # 1152x1152 — brainAI native
client.generate("a mountain", resolution="1920x1080")        # any WxH works

GeneratedImage

image = client.generate("a cat")

image.save("cat.png")       # save to file
image.save("cat.jpg")       # format from extension
raw  = image.bytes()        # raw bytes
pil  = image.to_pil()       # PIL.Image (needs: pip install Pillow)
image.show()                # display in Jupyter / IPython
print(image.url)            # permanent S3 URL

Wallet

balance = client.wallet.balance()
print(f"{balance.lc} LC  =  Rs.{balance.inr:.2f}")

Job history

jobs = client.jobs.list(limit=10)
for job in jobs:
    print(job.id, job.status, job.cost_lc, "LC")

API key management

new_key = client.keys.create(label="my-app")
print(new_key)   # lxr_v1_xxxx — save this!

keys = client.keys.list()

client.keys.revoke(key_id="key_id_here")
client.keys.rotate(key_id="key_id_here")

Check model status

status = client.status()
print(status["available"])    # True/False
print(status["message"])      # "Generation is live!" or "Coming soon..."

Error handling

from luxurai import (
    LuxurAI,
    AuthenticationError,
    InsufficientBalanceError,
    ModelTrainingError,
    JobFailedError,
    JobTimeoutError,
)

try:
    image = client.generate("a dragon")
except AuthenticationError:
    print("Invalid API key")
except InsufficientBalanceError:
    print("Not enough LC — top up at luxurai.in")
except ModelTrainingError:
    print("Model still training — coming soon!")
except JobFailedError:
    print("Generation failed — try again")
except JobTimeoutError:
    print("Timed out — try again")

Requirements

  • Python 3.8+
  • No required dependencies — pure stdlib
  • Optional: pip install Pillow for .to_pil() and .show()

License

MIT © LuxurAI

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

luxur_ai-0.2.1.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

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

luxur_ai-0.2.1-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file luxur_ai-0.2.1.tar.gz.

File metadata

  • Download URL: luxur_ai-0.2.1.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

Hashes for luxur_ai-0.2.1.tar.gz
Algorithm Hash digest
SHA256 441e7acac255a31378de99f1be3b25a9936c7414beb4e2744dc3f42886ffb713
MD5 4621eafd651d6993855ac3cd1e1d0bd1
BLAKE2b-256 f57ffb053fd0d351ffa42964162949fe4bbdc21bbae831b2afef1355ccae31a0

See more details on using hashes here.

File details

Details for the file luxur_ai-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: luxur_ai-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 11.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for luxur_ai-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 108c6a675011a64cea5063c258babf22b36f5958d5ffbd72c7a4a9d12e19ce72
MD5 518880a3a85fdc4f80a5db1e3a262081
BLAKE2b-256 ee2a382621491e422a08ee19b1dc3919f3bc3cd855d376502d7ebf72824a1970

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