Official Python SDK for LuxurAI — AI image generation
Project description
LuxurAI Python SDK
Official Python client for LuxurAI — AI image generation.
Install
pip install luxurai
Quick Start
from luxurai import LuxurAI
client = LuxurAI(api_key="lxr_v1_xxxx")
# Generate an image (blocks until done)
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
# Basic
image = client.generate("a sunset over the ocean")
image.save("sunset.png")
# With options
image = client.generate(
"divine krishna playing flute, golden light",
model = "brainai-v1", # only model currently
resolution = "1152x1152", # brainAI natural size
fast = False, # fast mode = cheaper
)
# Non-blocking
job = client.generate("anime girl with blue hair", wait=False)
print(f"Queue position: #{job.queue_position}")
print(f"ETA: ~{job.eta_seconds}s")
# ... do other stuff ...
image = job.wait() # block when you're ready
image.save("output.png")
Resolutions
from luxurai import Resolution
client.generate("a mountain", resolution=Resolution.HD) # 1024x1024
client.generate("a mountain", resolution=Resolution.SQ_2K) # 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 / LC balance
balance = client.wallet.balance()
print(f"{balance.lc} LC ≈ ₹{balance.inr:.2f}")
# 45.0 LC ≈ ₹11.25
Job history
jobs = client.jobs.list(limit=10)
for job in jobs:
print(job.id, job.status, job.cost_lc, "LC")
API key management
# List keys
keys = client.keys.list()
for key in keys:
print(key.prefix, key.created_at)
# Create new key
new_key = client.keys.create(label="my-app")
print(new_key) # lxr_v1_xxxx — save this!
# Revoke
client.keys.revoke(key_id="key_id_here")
Check model status
status = client.status()
if status["coming_soon"]:
print("Model still training — coming soon!")
else:
print("Generation available!")
Models
| Model | Description | Status |
|---|---|---|
brainai-v1 |
LuxurAI's ~761M JAX/Flax model | Training |
Error handling
from luxurai import (
LuxurAI,
AuthenticationError,
InsufficientBalanceError,
ModelTrainingError,
JobFailedError,
JobTimeoutError,
)
client = LuxurAI(api_key="lxr_v1_xxxx")
try:
image = client.generate("a dragon")
except AuthenticationError:
print("Invalid API key")
except InsufficientBalanceError as e:
print(f"Need more 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 Pillowfor.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.2.tar.gz
(10.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
luxur_ai-0.2.2-py3-none-any.whl
(11.1 kB
view details)
File details
Details for the file luxur_ai-0.2.2.tar.gz.
File metadata
- Download URL: luxur_ai-0.2.2.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b26a03737499698685c1ea09b72ad1a03f0358b8c5920f769e8dbe460e8a3957
|
|
| MD5 |
fe1a8c38e781c1b44027f70d5e94908c
|
|
| BLAKE2b-256 |
8e951059f21719fe723e10a29a85425a454dbc5442436582339203a2adc06d68
|
File details
Details for the file luxur_ai-0.2.2-py3-none-any.whl.
File metadata
- Download URL: luxur_ai-0.2.2-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a7f6cafd42b884c3927819ea40f60da2bc37d4715f7f0cf714407823087b5ea
|
|
| MD5 |
f267adb4939916d1f54bac45b05154f2
|
|
| BLAKE2b-256 |
5c11caee95c88c25516768ac3e2252c0ed926681ed44293be6d7e209c55e4632
|