Skip to content

marinom2/lightnode-py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lightnode-sdk (Python)

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.

Install

pip install lightnode-sdk

Python 3.10+. Pulls httpx, websockets, cryptography, eth-account, web3, rich. No native build step.

Quickstart

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)

CLI

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

Compatibility

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.

Provenance

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.

License

MIT.

About

Community Python SDK for LightChain AI (read-only client + encrypted inference). Mirrors lightnode-sdk.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages