Private, verifiable AI inference on 0G chain — drop-in OpenAI-compatible SDK
Project description
zkai
OpenAI-compatible Python SDK for ZKai — private, verifiable AI inference on 0G chain.
ZKai sends your prompt through a Trusted Execution Environment (Intel TDX), encrypts it client-side so even the gateway cannot read it, and anchors a SHA-256 attestation of every inference on the 0G chain. You get back a normal OpenAI-style response plus an on-chain receipt.
Install
pip install zkai
Optional LangChain adapter:
pip install "zkai[langchain]"
Quick start
from zkai import ZKai
client = ZKai(api_key="zkai-...") # get one at https://zkai-ether-og.vercel.app
response = client.chat.completions.create(
model="qwen2.5:1.5b",
messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)
print("Attestation hash:", response.attestation_hash)
The response is decrypted locally — the gateway sees only ciphertext. The attestation hash is anchored on 0G mainnet and can be verified independently.
How it works (gateway mode, default)
- The SDK fetches the enclave's X25519 public key from the gateway.
- It encrypts your prompt locally with ECDH + ChaCha20-Poly1305.
- It sends only the ciphertext to the gateway.
- The gateway routes the opaque blob to a TDX-sealed enclave running the requested model.
- The enclave decrypts inside sealed memory, runs the model, encrypts the response, and emits a SHA-256 attestation hash.
- The attestation lands on the on-chain
AttestationRegistrycontract. - The SDK decrypts the response locally and returns it to you.
End-to-end, the gateway never sees plaintext.
Configuration
ZKai(
api_key="zkai-...", # issued from the dashboard
base_url="https://zkai-ether-og.vercel.app", # default
encrypted=True, # default; set False to use the legacy plaintext path
provider_endpoint=None, # set to bypass gateway and hit a provider directly
skip_attestation=False, # only for development; do not disable in prod
)
| Argument | Type | Default | Description |
|---|---|---|---|
api_key |
`str | None` | None |
base_url |
`str | None` | https://zkai-ether-og.vercel.app |
encrypted |
bool |
True |
When True, prompts are encrypted client-side. Set False for legacy clients. |
provider_endpoint |
`str | None` | None |
skip_attestation |
bool |
False |
Disables attestation verification. Useful only for dev loops. |
OpenAI compatibility
The response object mirrors OpenAI's chat completion shape:
response.id
response.model
response.choices[0].message.content
response.choices[0].finish_reason
response.usage.prompt_tokens
response.usage.completion_tokens
# ZKai-specific:
response.attestation_hash # on-chain commitment
Drop-in replacement for most OpenAI SDK call sites — just swap the client class.
On-chain components (0G mainnet, chain ID 16661)
| Contract | Address |
|---|---|
| ProviderRegistry | 0x6D400F5D1DcCaA3e98E3dE17322aA23DE38bAC99 |
| PaymentEscrow | 0xb2C7c0F7a4C2877319E8Ed1Fae0bf3C705b6Fc4C |
| AttestationRegistry | 0x8c8Ae0A113084268D181fd1cf23d611DC2EAa2B2 |
Verify any attestation hash on the 0G explorer.
Running your own provider
See the companion zkai-cli package:
pip install zkai-cli
zkai init && zkai start && zkai register
Links
- Dashboard — https://zkai-ether-og.vercel.app
- Repository — https://github.com/skyyycodes/zkai-eth
- Provider CLI — https://pypi.org/project/zkai-cli/
License
MIT
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 zkai-0.5.0.tar.gz.
File metadata
- Download URL: zkai-0.5.0.tar.gz
- Upload date:
- Size: 12.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7e521766c0976053c740e82d141aad9c42850609769c6cf79f86f1f45e7dbad
|
|
| MD5 |
f782d5e3133f5c395286afa7e74c3070
|
|
| BLAKE2b-256 |
de8dadb6b13795580873f0a251a7bf23aac42804afb1839b04400aa171bc6764
|
File details
Details for the file zkai-0.5.0-py3-none-any.whl.
File metadata
- Download URL: zkai-0.5.0-py3-none-any.whl
- Upload date:
- Size: 12.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
175ec362dd4cf001233df19ef9c646821d87d1008327e2eaebd9bad9f02e2c76
|
|
| MD5 |
7de021b0fa265eb5466671ffd7ffa20c
|
|
| BLAKE2b-256 |
fead2a2c74d8f6b89f94de8e6bf72e034aeb5454cc1302fbbfd01a0874791e5a
|