OpenGPU SDK for distributed AI task deployment
Project description
OpenGPU Python SDK
Python SDK for the OpenGPU Network distributed AI compute marketplace.
pip install ogpu
Overview
The SDK has two sides:
ogpu.chain—ChainConfig,ChainId, nonce utilities, ABI loader (re-exported at top level:from ogpu import ChainConfig)ogpu.client/ogpu.protocol— interact with the blockchain: publish sources and tasks, manage vault staking, monitor eventsogpu.service— framework for source developers to expose task handlers inside Docker containers
Quick Start
Publish a Task
import time
from web3 import Web3
from ogpu import ChainConfig, ChainId
from ogpu.client import TaskInfo, TaskInput, publish_task
ChainConfig.set_chain(ChainId.OGPU_TESTNET)
task = publish_task(TaskInfo(
source="0xYOUR_SOURCE_ADDRESS",
config=TaskInput(function_name="predict", data={"prompt": "hello"}),
expiryTime=int(time.time()) + 3600,
payment=Web3.to_wei(0.01, "ether"),
))
print(task.address) # contract address
print(task.get_status()) # TaskStatus.NEW
print(task.get_source().address) # navigate to the source
Instance Classes
Every on-chain entity has a live proxy class. Methods hit the chain on every call — no stale cache.
from ogpu.protocol import Source, Task, Response, Provider, Master
task = Task.load("0xTASK_ADDRESS") # validates existence on-chain
task.get_status() # TaskStatus
task.get_attempters() # list[str]
task.get_confirmed_response() # Response | None (chain-only)
task.cancel(signer=my_key) # Receipt
snap = task.snapshot() # frozen capture of all fields
print(snap.status, snap.payment, snap.attempt_count)
Vault Operations
from ogpu.protocol import vault
vault.deposit("0xBENEFICIARY", amount=10**18, signer=my_key)
vault.lock(amount=5 * 10**17, signer=my_key)
vault.get_balance_of("0xADDRESS") # int (wei)
vault.is_eligible("0xADDRESS") # bool
Event Watching (Async)
import asyncio
from ogpu.events import watch_attempted
async def monitor(task_addr: str):
async for event in watch_attempted(task_addr):
print(f"Attempt from {event.provider} @ block {event.block_number}")
asyncio.run(monitor("0xTASK_ADDRESS"))
Custom RPC
from ogpu import ChainConfig
ChainConfig.set_rpc("https://my-private-node.example")
ChainConfig.get_rpc() # current URL
ChainConfig.reset_rpc() # restore default
Architecture
ogpu/
chain/ # ChainConfig, ChainId, Web3Manager, nonce, ABI files
types/ # enums, errors, Receipt, metadata
protocol/ # low-level 1:1 contract wrappers
nexus, controller, terminal, vault
Source, Task, Response, Provider, Master
client/ # high-level client workflows
events/ # async event watchers (the one async island)
service/ # source developer framework (separate concern)
Protocol layer — every Solidity view has a Python accessor, every state-changing function has a writer. Signer management via per-call signer= parameter with role-based env-var fallback (CLIENT_PRIVATE_KEY, PROVIDER_PRIVATE_KEY, MASTER_PRIVATE_KEY).
Instance classes — Source(addr), Task(addr), Response(addr), Provider(addr), Master(addr). Stateless — only self.address is stored. Task.load(addr) validates existence eagerly.
Events — async generators in ogpu.events. HTTP filter polling, not WebSocket. Rest of SDK is sync.
Requirements
- Python >= 3.10
web3 >= 7.0
Documentation
Full docs: https://opengpu-network.github.io/sdk-ogpu-py/
Writing a Task Handler (ogpu.service)
import ogpu.service
from pydantic import BaseModel
class MultiplyInput(BaseModel):
a: int
b: int
class MultiplyOutput(BaseModel):
result: int
@ogpu.service.expose()
def multiply(data: MultiplyInput) -> MultiplyOutput:
return MultiplyOutput(result=data.a * data.b)
ogpu.service.start()
License
Released under the MIT License — Copyright © 2026 OpenGPU Network.
You're free to use, modify, distribute, and embed ogpu-py in commercial or
open-source projects. The only requirement is that the copyright notice and
license text travel with the source.
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 ogpu-0.2.1.tar.gz.
File metadata
- Download URL: ogpu-0.2.1.tar.gz
- Upload date:
- Size: 81.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
abed794af65e02a567c97118ea9fb6505803ce7a94da9c459083d2bc68ee9211
|
|
| MD5 |
f8968a40d036d3dde4e966e6c88effae
|
|
| BLAKE2b-256 |
d6f95e60b88f6ed730a41af5a67e36d382418be0550ad880c65fbd142a785b4e
|
File details
Details for the file ogpu-0.2.1-py3-none-any.whl.
File metadata
- Download URL: ogpu-0.2.1-py3-none-any.whl
- Upload date:
- Size: 107.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f779863d3ebc021d34011358cbdb4fd85700edca79a275b0155c9dec69c54bfb
|
|
| MD5 |
c6840005f133a723f004dd0e1d8ef048
|
|
| BLAKE2b-256 |
05cf77af44caacbd7e0013e0c6af26b8078a950a68bf727d3b72197c98072b01
|