mirror of
https://github.com/hanzoai/python-sdk.git
synced 2026-10-23 20:23:00 +00:00
README: PyPI serves 3.2.1 and this tree is 3.2.11, so the install line is the git one. Between the two the default version left the operation ids — 3.2.1 carries get_v1_keys/get_v1_tools (182 api modules, 2172 models) and this carries get_keys/get_tools — so `pip install hanzoai` above a `get_keys()` quickstart hands the reader a client that cannot run it. Counts are measured off the pinned document: 1814 paths, 2479 operations, 191 tags + default_api = 192 API classes over 2460 models, 2659 importable modules. Auth was wrong everywhere and it was the same root cause: the document declares no securityScheme, so every operation got an empty auth_settings and Configuration(access_token=…) is read by nothing. Serializing get_keys from such a Configuration produces a request with no Authorization header at all — the five flows have been calling anonymously and reading the refusal as a bad key. examples/client.py now passes the bearer through ApiClient's header_name/value pair, verified against a local server that echoes what it received, and a smoke test pins both halves so the day cloud emits the scheme, the test fails and the header moves back into Configuration. The examples gate resolved class names and stopped there, which is how `money` and `tools` once passed it while every call in them named a method that no longer existed. It now walks the syntax tree for attribute accesses on anything bound to a *Api and asks the class: ten names resolve, and a stale get_v1_tools fails in the same second the import passes. Deleted five example scripts that imported hanzoai.Hanzo, hanzoai.cluster, hanzoai.agents and hanzoai.completion — none of which exist — or were dict literals captioned "in practice this would be called through the MCP interface"; compileall passed all five, because syntax is not a claim. Deleted three docs that were fabrication rather than drift and that nothing rendered: FEATURES.md, QUICKSTART.md, GPT5_ORCHESTRATION.md. pkg/hanzo-agent said `pip install hanzoai` and `from hanzoai import Agent, Runner`; the client has no Agent. Its own `full` extra resolved to hanzoai[web3,tee,marketplace,cli], extras the client does not declare, so it installed the client and none of the extensions. pyproject said BSD-3-Clause while LICENSE is the Apache 2.0 text. test_smoke imported tracker_api and no /v1/tracker path is emitted any more, so the suite carried a failing test naming a module the client does not have; it reads analytics_api now, off the client.
48 lines
1.8 KiB
Python
48 lines
1.8 KiB
Python
"""money — what is in the wallet, and what spent it.
|
|
|
|
GET /v1/billing/balance get_billing_balance
|
|
GET /v1/billing/usage get_billing_usage
|
|
|
|
Neither call takes an org: both derive the tenant SERVER-side from the token's
|
|
``owner`` claim, so a key can only ever read its own money. There is no org
|
|
argument to pass.
|
|
|
|
Both are declared with a ``default`` response and no ``content``, so the typed
|
|
methods return None even though the server sends JSON. That is a document gap,
|
|
not an SDK one — 834 of the document's 2479 operations model no response body
|
|
(716 declare no ``responses`` at all, 118 declare responses with no ``content``)
|
|
— so this example reads the raw payload through the generated
|
|
``*_without_preload_content`` variant rather than pretending a type it was not
|
|
given. When the schemas land, these become ordinary typed calls and nothing else
|
|
about them changes.
|
|
|
|
python -m examples.money
|
|
"""
|
|
|
|
import json
|
|
|
|
from hanzoai.cloud import BillingApi
|
|
|
|
from examples.client import client, run
|
|
|
|
|
|
def main() -> None:
|
|
with client() as api:
|
|
billing = BillingApi(api)
|
|
for label, call in (
|
|
("balance", billing.get_billing_balance_without_preload_content),
|
|
("usage", billing.get_billing_usage_without_preload_content),
|
|
):
|
|
response = call()
|
|
body = response.read()
|
|
# The raw variant does NOT raise on a 4xx — that check is part of the
|
|
# typed deserialization this operation does not have. Without this,
|
|
# a 401 body prints as though it were the balance.
|
|
if response.status >= 400:
|
|
raise SystemExit(f"HTTP {response.status}: {body.decode(errors='replace')}")
|
|
print(f"{label}: {json.dumps(json.loads(body), indent=2)}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
run(main)
|