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

Uploaded Python 3

File details

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

File metadata

  • Download URL: luxur_ai-0.2.3.tar.gz
  • Upload date:
  • Size: 11.1 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.3.tar.gz
Algorithm Hash digest
SHA256 bee8f080bce2bf9badc1a99bcceed6b8b2aeff96696030c3b0842b335c472322
MD5 60804ecc482a91cb1b4b5d4214c2fe4e
BLAKE2b-256 ebc0fd73eb713fd32dfe03555f73254e6de0fd6bd87434ff296a782d232caf93

See more details on using hashes here.

File details

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

File metadata

  • Download URL: luxur_ai-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 11.6 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 377c3049b73c49c7872368d98436d70a1f0b8601896da438b929bb9be760bf38
MD5 397f4bac1e0f56625680cccdd705a6c3
BLAKE2b-256 c1086a5ec391e4af097ca4356d06b8faa06c50a4f5a76478f86aef3bc17ce0fe

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