ainize (Python)
Call an Ainize node with the OpenAI code you already have.
import ainize
client = ainize.connect("https://node.example", private_key="0x…")
client.chat.completions.create(
model="qwen3.8-flash-next",
messages=[{"role": "user", "content": "hello"}],
)
connect() signs one challenge to prove your address, and returns a real openai.OpenAI with base_url and
api_key already set. Everything after that line is OpenAI's — its methods, its parameters, its exceptions.
Already hold a key? ainize.connect(url, api_key="ainize-sk-…") skips the signing.
What you pay with
A deposit, not a per-token charge. Send AIN or sAIN to the node; the operator holds it staked, and your share of the node's throughput is your share of what everyone asking at that moment has deposited. An idle deposit costs nobody anything, and the principal is not consumed.
ainize.deposit_address("https://node.example") # where to send
ainize.await_deposit(url, tx_hash, api_key=client.api_key) # wait until the node has credited it
The library never signs a transfer. It tells you where to send and waits for the node to notice; moving funds stays with the wallet you already trust.
Tests
They drive a real node and a stub model — mocking the transport would test our idea of the node's replies rather than the node's replies, and the shapes are exactly where compatibility breaks. Run them from this directory, so the package on disk is the one imported:
python -m venv .venv && .venv/bin/pip install openai eth-account httpx pytest
.venv/bin/python -m pytest
Release files for ainize 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ainize-0.1.0.tar.gz | 4.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ainize-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.1 kB
Release files / ainize-0.1.0.tar.gz
| Download URL | ainize-0.1.0.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7490029fb5c3af39ad77cd7a8f97a64cd1ce778809e5583b415b697fbf8f266b
|
|
BLAKE2b-256 checksum How to use checksums |
ab6f0f1b10624d0dfe4e974d771640c2b9da9e5c3c49efc600dffa24c29c45d9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.12
|
Release files / ainize-0.1.0-py3-none-any.whl
| Download URL | ainize-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0e00aa66caab5d6032a5bc8821b15b94ff5d357bce46baedd19d4ca71a7c0513
|
|
BLAKE2b-256 checksum How to use checksums |
29486b49352f128b554da9e10388f9fcb63923bb374a92500fd922a5bcf7caef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.12
|