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

Uploaded Python 3

File details

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

File metadata

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

Hashes for luxur_ai-0.2.0.tar.gz
Algorithm Hash digest
SHA256 ff4e8932017ca07e559967976006e9724a4d35b2d77dc79d289c793fabe0d42f
MD5 4860996709dea500c5b57f2aefabdcb4
BLAKE2b-256 875c1b4a090ecb3a13a32f3e87da959e8c3e3cd4a84b4beeebf9749bc695ac4d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: luxur_ai-0.2.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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a508be23a4fc331d166130423ed393fde7a98ffb1567d02c369039ce597d3738
MD5 cc7e53a53834a1ea7985432cd3748835
BLAKE2b-256 88b2db2a9da8e539a367fc8de511b7202ed6b46f3556d3aab692bf40b4a5592a

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