Python SDK for the Citrate distributed AI network
Project description
Citrate Python SDK
The official Python SDK for the Citrate distributed AI network. Deploy AI models, manage learning pools, stake SALT, create classrooms, post compute jobs, and interact with the verified compute marketplace.
Version: 0.5.0 | Chain ID: 40204 (0x9d0c) | Token: SALT
Installation
pip install citrate-sdk
Quick Start
from citrate_sdk import CitrateClient
# Connect to Citrate testnet
client = CitrateClient(
rpc_url="https://rpc.citrate.ai",
private_key="0x..." # Optional: for signing transactions
)
# Check balance
balance = client.get_balance("0xYOUR_ADDRESS")
print(f"Balance: {balance} SALT")
# List learning pools
pools = client.learning.list_pools()
for pool in pools:
print(f"{pool.name}: {pool.member_count} members")
Features
- AI Models — Deploy, query, and run inference on on-chain AI models
- Learning Pools — Join federated learning pools, track OODA cycles, earn from contributions
- Staking — Deposit SALT → stSALT, withdraw, track share price and APY
- Classrooms — Create teacher classrooms, enroll students, manage model whitelists
- Compute Marketplace — Post jobs, bid, register as provider, create GPU pools
- Encryption — End-to-end encryption for model weights and inference data
- IPFS — Pin and manage model artifacts
Managers
The SDK exposes managers for each domain:
| Manager | Access | Purpose |
|---|---|---|
client.learning |
LearningManager |
Learning pools, cycles, contributions |
client.staking |
StakingManager |
stSALT deposit, withdraw, share price |
client.classroom |
ClassroomManager |
Teacher classrooms, student enrollment |
client.compute |
ComputeManager |
Compute marketplace, jobs, providers, pools |
Learning Pools
# List available pools
pools = client.learning.list_pools()
# Join a pool (stake SALT)
tx = client.learning.join_pool(pool_id=0, stake_amount="1000000000000000000")
# Get cycle status
cycle = client.learning.get_cycle_status()
print(f"Cycle {cycle.cycle_id}: {cycle.state}")
# Get your contribution scores
contribs = client.learning.get_contributions(address)
print(f"Score: {contribs.total_score}")
Staking (stSALT)
# Deposit SALT → receive stSALT
tx = client.staking.deposit("32000000000000000000000") # 32,000 SALT
# Check staking info
info = client.staking.get_info()
print(f"Share price: {info.share_price}")
print(f"Your staked value: {info.user_staked_value}")
# Withdraw (7-day lockup)
tx = client.staking.withdraw("1000000000000000000")
Classrooms
# Create a classroom (teachers)
tx = client.classroom.create("AP Computer Science", max_students=30)
# Enroll with invite code (students)
tx = client.classroom.enroll("INVITE-CODE-123")
# Deploy model to classroom whitelist
tx = client.classroom.deploy_model("0xModelHash...")
# Check if student can access a model
can_access = client.classroom.can_student_access_model(student, model_hash)
Compute Marketplace
# Post a compute job
job_id = client.compute.post_job(
model_hash="0x...",
input_data="0x...",
max_price="10000000000",
tier="Commitment" # or "ZKProof", "TEE"
)
# Register as a compute provider (1000 SALT minimum)
tx = client.compute.register_provider(
stake="1000000000000000000000",
models=["0xModel1"],
endpoint="https://my-node.com"
)
# Create a GPU pool
tx = client.compute.create_pool("My Pool", "InferencePool", 3, 1000, "100000000")
# List available pools
pools = client.compute.get_pools()
Models & Inference
from citrate_sdk import ModelConfig, ModelType, AccessType
# Deploy a model
config = ModelConfig(
name="My Model",
model_type=ModelType.GGUF,
access_type=AccessType.PUBLIC
)
deployment = client.deploy_model("./model.gguf", config)
# Run inference
result = client.inference(
model_id=deployment.model_id,
input_data={"text": "Hello world"}
)
print(f"Output: {result.output_data}")
Network Configuration
# Local devnet
client = CitrateClient("http://localhost:8545")
local_chain_id = client.get_chain_id()
# Testnet
client = CitrateClient("https://rpc.citrate.ai", private_key="0x...")
Use get_chain_id() on localhost instead of assuming every local profile uses the public testnet chain ID.
Public testnet chain ID: 40204 | Token: SALT | Block time: ~2 seconds
Testing
pip install -e ".[dev]"
pytest tests/
pytest --cov=citrate_sdk tests/
Support
- GitHub: github.com/SaulBuilds/citrate
- Issues: github.com/SaulBuilds/citrate/issues
- Discord: discord.gg/A3Uwe4BvdN
License
MIT License — see LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file citrate_ai_sdk-0.5.0.tar.gz.
File metadata
- Download URL: citrate_ai_sdk-0.5.0.tar.gz
- Upload date:
- Size: 55.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f2caff6d50cfebbe907e93a7688af8554ac798cb9891996fdbb168afad47562
|
|
| MD5 |
b06ac3d92147b0da0599a25f5e78ac19
|
|
| BLAKE2b-256 |
18e9e1d54e028ff0bde2623f425e00b12d81f916b1e15a09850812acf028689f
|
File details
Details for the file citrate_ai_sdk-0.5.0-py3-none-any.whl.
File metadata
- Download URL: citrate_ai_sdk-0.5.0-py3-none-any.whl
- Upload date:
- Size: 59.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77da559b7eeeed358d8dffef936e45260f48d4fd46be309379f450cf9d8217b4
|
|
| MD5 |
d2b58f00134b575a0dc281143802f76f
|
|
| BLAKE2b-256 |
598b8d63be46196a0ce1c901cacb3b653a5f474f7777437c3c1252fad5200f68
|