Community Python client for LightChain AI, mirroring the TypeScript
lightnode-sdk.
This Python port is narrower than the TypeScript SDK on purpose: it ships the two surfaces Python users ask for most.
- Read-only network client (
LightNode): workers, jobs, models, on-chain registration truth, network stats, fees, model ids. Free, no key. - Encrypted inference (
run_inference_with_key): the 5-line API. Pass network + private key + prompt, get an answer back. Byte-perfect crypto (ECDH P-256 + raw 32-byte shared secret + AES-256-GCM) vs the TS SDK and LightChain's reference Go client.
For the rest (bridge, DAO, on-chain model registry, multi-turn helper, worker preflight + watch), use the TypeScript SDK at https://github.com/marinom2/lightnode.
pip install lightnode-sdkPython 3.10+. Pulls httpx, websockets, cryptography, eth-account,
web3, rich. No native build step.
from lightnode_sdk import LightNode, run_inference_with_key
# Read-only: any chain data, no key required
ln = LightNode("mainnet")
print(ln.get_network_stats())
print(ln.get_models())
print(ln.estimate_fee("llama3-8b"))
# Encrypted inference (paid, ~0.022 LCAI on mainnet)
r = run_inference_with_key(
network="testnet",
private_key="0x...",
prompt="Reply with a one-sentence fun fact about the ocean.",
)
print(r.answer)
print(r.create_session_tx, r.submit_job_tx, r.job_completed_tx)pip install lightnode-sdk also installs a lightnode command.
lightnode network --net mainnet
lightnode models --net mainnet
lightnode worker 0x... --net mainnet
lightnode reliability --net mainnet
lightnode fee llama3-8b --net mainnet
PRIVATE_KEY=0x... lightnode chat "Write me a haiku about LightChain" --net testnet| Surface | Status |
|---|---|
Read-only LightNode (subgraph + RPC) |
Full parity with TS SDK |
run_inference_with_key |
Full encrypted flow (SIWE -> session -> on-chain -> relay -> decrypt) |
| Bridge / DAO / model-registry / preflight | Not in this port. See TS SDK. |
Same protocol surface as the TypeScript SDK: consumer gateway, relay, JobRegistry ABI, byte-perfect crypto. Reverse-engineered from LightChain's reference client and cert-transparency host enumeration.
Independent, community-built. Not affiliated with or endorsed by the LightChain team.
MIT.