Python SDK Phase 1
Python 3.11+ client for the DAIT chain. Includes the dait-cli command for one-off operations from a shell. Sync and asyncio APIs both supported.
Install
pip install dait-sdk
Quick tour
import os
from dait_sdk import DaitChainClient, ComputeSession
dait = DaitChainClient(
rpc_url="https://rpc.daitchain.io",
evm_rpc_url="https://rpc.daitchain.io",
mnemonic=os.environ["DAIT_MNEMONIC"],
)
with ComputeSession.open(
dait,
model_id="qwen2.5-32b-instruct",
max_calls=10_000,
escrow_uDAIT=5_000_000,
) as session:
out = session.infer(prompt="Summarize this PDF", attachments=[pdf_bytes])
print(out.text)
print(out.receipt.tokens_out, "tokens billed at", out.receipt.price_uDAIT)
CLI
dait-cli auction submit --model qwen2.5-32b-instruct --max-price 25 dait-cli channel open --host dait1abc... --escrow 5000000 dait-cli receipt verify ./receipt.b64 dait-cli pouw credits --address dait1xyz... dait-cli tier register --tier node --gpu-uuid GPU-XXXX
The CLI reads $DAIT_MNEMONIC from the environment and the chain endpoint from $DAIT_RPC_URL (or ~/.dait/config.toml).
Async API
import asyncio
from dait_sdk.async_ import AsyncDaitChainClient, AsyncComputeSession
async def main():
async with AsyncDaitChainClient(rpc_url="https://rpc.daitchain.io") as dait:
async with AsyncComputeSession.open(dait, model_id="qwen2.5-32b-instruct") as s:
async for chunk in s.stream(prompt="Tell me a story"):
print(chunk.text, end="", flush=True)
asyncio.run(main())
Receipt verification
from dait_sdk import verify_receipt next_state = verify_receipt(headers, request_bytes, response_bytes, channel_state) # returns an updated ChannelState, or raises a typed exception
Direct chain access
from dait_sdk.cosmos import MsgRegisterTier
tx = dait.tx.broadcast([
MsgRegisterTier(signer=dait.address, tier_id=3), # Node
])
print(tx.tx_hash)
Provider mode (dait-host)
The provider daemon at github.com/dait-chain/dait-host shares the same dait_sdk primitives. If you are running a host you typically use dait-host (the daemon) rather than the SDK directly. See run a compute host.
Status
Phase 0 scaffold. Cryptography primitives stubbed; public publish to PyPI aligns with Phase 1 alpha.
See also
- TypeScript SDK for the equivalent browser / Node API
- SPUR-IC spec for the receipt format