hanzoai 2.2.7 → 2.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
TypeScript client for the [Hanzo API](https://api.hanzo.ai). Generated from the
|
|
6
6
|
API's own OpenAPI document — the one each subsystem's router emits — so it
|
|
7
|
-
carries every `/v1` route, 2479 operations across
|
|
7
|
+
carries every `/v1` route, 2479 operations across 191 products, and cannot name
|
|
8
8
|
an address the server does not serve.
|
|
9
9
|
|
|
10
10
|
## Install
|
|
@@ -53,8 +53,8 @@ argument.
|
|
|
53
53
|
|
|
54
54
|
**Pass it as `baseOptions`, not as `accessToken`.** The API document declares no
|
|
55
55
|
`securityScheme`, so the generator emitted no auth code: `accessToken`
|
|
56
|
-
type-checks, sends no `Authorization` header, and
|
|
57
|
-
|
|
56
|
+
type-checks, sends no `Authorization` header, and the call is refused as
|
|
57
|
+
anonymous. `baseOptions` is spread into every request by every operation, so the
|
|
58
58
|
header set once below reaches all 2502 methods.
|
|
59
59
|
|
|
60
60
|
```ts
|
|
@@ -104,28 +104,33 @@ npm ci && npm run build
|
|
|
104
104
|
npx tsx examples/hello/index.ts
|
|
105
105
|
```
|
|
106
106
|
|
|
107
|
-
`npm run examples` type-checks all six against the client
|
|
108
|
-
|
|
107
|
+
`npm run examples` type-checks all six against the client, and `hanzo.yml` makes
|
|
108
|
+
that a CI gate — which is what keeps them from rotting into pseudocode.
|
|
109
109
|
|
|
110
110
|
## The API surface
|
|
111
111
|
|
|
112
|
-
One class per product — the first path segment after `/v1/`.
|
|
112
|
+
One class per product — the first path segment after `/v1/`. 191 of them:
|
|
113
113
|
`ChatApi`, `ModelsApi`, `IamApi`, `BillingApi`, `KvApi`, `AgentsApi`,
|
|
114
|
-
`ToolsApi`, `McpApi`, `CommerceApi`, `O11yApi`, and
|
|
115
|
-
`
|
|
114
|
+
`ToolsApi`, `McpApi`, `CommerceApi`, `O11yApi`, and 181 more. A 192nd class,
|
|
115
|
+
`DefaultApi`, holds the 50 routes the document leaves untagged — `/` and the
|
|
116
|
+
`/.well-known/*` family. Each takes a `Configuration`; each method takes one
|
|
117
|
+
request object.
|
|
116
118
|
|
|
117
119
|
```ts
|
|
118
|
-
import { BillingApi } from 'hanzoai';
|
|
119
|
-
|
|
120
|
+
import { Configuration, BillingApi } from 'hanzoai';
|
|
121
|
+
|
|
122
|
+
const billing = new BillingApi(new Configuration({ basePath: 'https://api.hanzo.ai' }));
|
|
123
|
+
billing.getBillingBalance().then(({ data }) => console.log(data));
|
|
120
124
|
```
|
|
121
125
|
|
|
122
126
|
Method names are the document's operation ids in camelCase — `get_billing_balance`
|
|
123
127
|
is `getBillingBalance`, and a path parameter reads as `by`:
|
|
124
128
|
`GET /v1/kv/{name}` is `getKvByName({ name })`.
|
|
125
129
|
|
|
126
|
-
|
|
127
|
-
`data` arrives
|
|
128
|
-
in the client; it closes as the
|
|
130
|
+
891 of the 2479 operations declare a route but not a response shape, so their
|
|
131
|
+
`data` arrives untyped — `void` for 834 of them, `any` for the other 57 — and
|
|
132
|
+
wants a cast. That is a gap in the document, not in the client; it closes as the
|
|
133
|
+
subsystems describe their own replies.
|
|
129
134
|
|
|
130
135
|
Full reference: [docs.hanzo.ai](https://docs.hanzo.ai).
|
|
131
136
|
|