mirror of
https://github.com/hanzoai/java-sdk.git
synced 2026-10-30 15:07:36 +00:00
Every flow's javadoc quoted an operation id from before the default version
left the id — get_v1_keys, post_v1_chat_completions, get_v1_agents_by_ref_runs
and eight more. The document calls them get_keys, post_chat_completions and
get_agents_by_ref_runs; the addresses never moved. Read off the document, not
derived: post_agents and post_agents_by_ref_run differ by more than a suffix.
store said the KV value plane is authored in the document and does not route.
The document declares /v1/kv and /v1/kv/{name} and nothing else — the value
plane went away with the hand-written spec that carried it.
42 lines
1.6 KiB
Java
42 lines
1.6 KiB
Java
package ai.hanzo.cloud.examples;
|
|
|
|
import ai.hanzo.Hanzo;
|
|
import ai.hanzo.cloud.ApiException;
|
|
import ai.hanzo.cloud.api.BillingApi;
|
|
|
|
/**
|
|
* money — the balance, then the usage that moved it.
|
|
*
|
|
* <p>Operations: {@code get_billing_balance} — GET /v1/billing/balance, and
|
|
* {@code get_billing_usage} — GET /v1/billing/usage.
|
|
*
|
|
* <p>Neither takes an org: both derive the tenant server-side from the token's
|
|
* {@code owner} claim, so a key can only ever read its own money.
|
|
*
|
|
* <p>Both are published with no response schema, so the generator types them
|
|
* {@code void}: there is no accessor to print a balance with, and no query
|
|
* parameter to narrow the ledger with, because the document declares neither.
|
|
* The example reports the status each route gave, which is all the document
|
|
* supports. Decoding a body the client was never told the shape of would be an
|
|
* opinion about the API living inside a generated client — the drift these SDKs
|
|
* exist to prevent. When the source declares the shapes, a regeneration prints
|
|
* them.
|
|
*
|
|
* <pre>
|
|
* HANZO_API_KEY=hk-... ./gradlew :examples:money
|
|
* </pre>
|
|
*/
|
|
public final class Money {
|
|
|
|
public static void main(String[] args) {
|
|
BillingApi billing = new BillingApi(Hanzo.client());
|
|
try {
|
|
System.out.printf("balance HTTP %d%n", billing.getBillingBalanceWithHttpInfo().getStatusCode());
|
|
System.out.printf("usage HTTP %d%n", billing.getBillingUsageWithHttpInfo().getStatusCode());
|
|
} catch (ApiException e) {
|
|
System.err.printf("billing failed: HTTP %d %s%n", e.getCode(), e.getResponseBody());
|
|
System.exit(1);
|
|
}
|
|
}
|
|
}
|