Pay with gamma
Zils is a gamma service on Bittensor subnet 127. A hotkey with gamma credit can call any Zils decision model and train its own, without a Zils account, an API key or a card. The hotkey is the account: you spend gamma at the Zils service hotkey once, then sign each request with that hotkey.
This suits agents and scripts that already hold a Bittensor wallet. If you would rather use an account and an API key, start with the API quickstart. A hotkey's first credited spend opens an account for that hotkey alone. Its credit and the models it trains are separate from any Zils account signed in on the website.
| Subnet | 127 |
| Service hotkey | 5EKrpcqVNWfVfmKiq8v3LRrgb3E3ENBwYzmAziDhMK58gtb5 |
| Signature | btauth/1, sr25519 |
| Credit | 1 gamma = $1.00 |
| Services document | /decision/v1/gamma/services.json |
Prices are the same as for accounts: decisions cost $0.06 per million input tokens, and private training costs $0.20 per million training tokens with a $2.00 minimum per run. The live numbers are at /decision/v1/gamma/pricing; see pricing and limits.
What you need
- A Bittensor wallet with a little TAO in its coldkey.
- A hotkey kept for paying.
btclicalls it an API-key hotkey; don't use a hotkey you stake with. btcliwith thegammacommands, and thebittensorPython package to sign requests. The commands below were run with version 11.3.6 of both.
1. Mint gamma
Minting buys SN127 alpha with TAO, burns it, and credits gamma to a deposit at your hotkey. The coldkey signs it. --amount is in TAO.
btcli gamma mint --netuid 127 --hotkey YOUR_HOTKEY_SS58 --amount 0.02 -w YOUR_WALLETCheck the deposit:
btcli gamma show --netuid 127 --hotkey YOUR_HOTKEY_SS582. Spend gamma at Zils
Spending moves gamma from your deposit to the Zils service hotkey. The hotkey signs it and pays no fee. The smallest spend is 0.1 gamma, unless it empties the deposit.
btcli gamma spend --netuid 127 \
--service-hotkey 5EKrpcqVNWfVfmKiq8v3LRrgb3E3ENBwYzmAziDhMK58gtb5 \
--amount-gamma 1 -w YOUR_WALLET -H YOUR_HOTKEY_NAMEZils credits the spend once its block is finalized, usually within a minute. Your balance is public and needs no signature:
curl 'https://training.zils.ai/decision/v1/gamma/balance?hotkey=YOUR_HOTKEY_SS58'{"hotkey": "5Fx…", "credited_usd": "1.000000000", "used_usd": "0.000000000", "remaining_usd": "1.000000000"}3. Ask a question
Sign every request with btauth/1. The receiver is the Zils service hotkey, and the signed path is the full public path, including the /decision prefix. sign makes a fresh nonce each time; never resend a signed request.
import json
import urllib.request
import bittensor as bt
from bittensor_wallet import Wallet
SERVICE = "5EKrpcqVNWfVfmKiq8v3LRrgb3E3ENBwYzmAziDhMK58gtb5"
wallet = Wallet(name="YOUR_WALLET", hotkey="YOUR_HOTKEY_NAME")
body = json.dumps({
"model": "zils-shared",
"state": {"query": "USB-C cable", "product": "One metre USB-C to USB-C cable"},
"questions": {
"match": {"type": "noul", "instructions": "Does this product match the query?"},
},
}).encode()
path = "/decision/v1/systemone"
headers = bt.http_auth.sign(
wallet.hotkey, method="POST", path=path, body=body, receiver_ss58=SERVICE
)
headers["Content-Type"] = "application/json"
request = urllib.request.Request(
"https://training.zils.ai" + path, data=body, headers=headers, method="POST"
)
with urllib.request.urlopen(request) as response:
print(json.load(response))The answer has the same shape as an account's; usage.billable_input_tokens is what you were charged for. How decision models work explains the question types, and the full request schema is in the Decision API spec.
| Status | Meaning |
|---|---|
401 | The signature is missing, invalid, too old, made for another receiver, or replayed. Sign the request again. |
402 | insufficient_balance: the hotkey has no credit left at Zils. Spend more gamma. |
4. Train your own model
The training API takes the same signature, at https://training.zils.ai with paths such as /v1/jobs. Create a job, PUT the train, calibration and test JSONL splits to the URLs it returns, submit it, and poll GET /v1/jobs/{id}. A private job reserves the $2.00 minimum at submit and its full price once its data is validated; a job your credit cannot cover fails with the price in its error.
def call(method, path, payload=None):
body = json.dumps(payload).encode() if payload is not None else b""
headers = bt.http_auth.sign(
wallet.hotkey, method=method, path=path, body=body, receiver_ss58=SERVICE
)
headers["Content-Type"] = "application/json"
request = urllib.request.Request(
"https://training.zils.ai" + path,
data=body if payload is not None else None,
headers=headers,
method=method,
)
with urllib.request.urlopen(request) as response:
return json.load(response)
job = call("POST", "/v1/jobs", {
"name": "expense-limit",
"tier": "private",
"acceptance": {"min_accuracy": 0.9, "min_brier_improvement": 0},
"allow_training_data_export": True, # required: lets Zils workers read the data to train
})["job"]An accepted model is served under the job name plus the first eight characters of the job id, for example expense-limit-3367ac94. Use that name as model in step 3. Understand the result explains what acceptance means.
Find Zils from an agent
The services document lists the service hotkey, both OpenAPI specs, the model list, pricing and the balance URL. Its URL is registered on chain for the service hotkey, so gamma indexes such as the Taostats gamma API list it.