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 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 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.1.0.tar.gz (10.6 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.1.0-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: luxur_ai-0.1.0.tar.gz
  • Upload date:
  • Size: 10.6 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.1.0.tar.gz
Algorithm Hash digest
SHA256 6281e89e1fd9a9947a2fafb22d156115e8e6696af6dbd380545f5621a4b2d2f7
MD5 515c87c392129c9a8fab7e9319d3a110
BLAKE2b-256 28b92a50dd687dcb533194972b6480887ebc2554af46f31908c60d964a2bbf49

See more details on using hashes here.

File details

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

File metadata

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

Hashes for luxur_ai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9f73be8c2ba6b3d0cea1cd585da7ce3040129ac9b33d3c39976781967185d883
MD5 80bbeede583f0e6b8506fa8e5488a465
BLAKE2b-256 db121e810602a8c2201bf3b05e19f152935226388451a74e4562b02145ca5bed

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