Reference
Generated API docs, how the examples are tested, and how tai maps to the HTTP API.
Generated API docs
The generated API reference lists every public declaration with its doc comment. To build it locally with Zig’s autodoc:
zig build docs
python3 -m http.server -d zig-out/docs/api
How the examples are tested
Every Zig example in these docs, the README and the doc comments is quoted from a region of a test, marked like this:
// docs:start NAME
...
// docs:end NAME
| Command | What it does |
|---|---|
zig build test | Offline: unit tests, compiles the e2e tests and the consumer project, and fails if any snippet is stale or any Zig code in the docs isn’t quoted from a test |
TYPESAFE_API_KEY=... zig build e2e | Runs the e2e tests and the quick start against the live API |
zig build snippets | Re-extracts the snippets after you edit a test |
The snippets come from:
tests/e2e.zig: end-to-end tests. Assertions sit outside the quoted regions, and check ranges and unambiguous cases rather than exact model output.tests/consumer/: a downstream project that depends ontaiby path. Itsbuild.zigis the install example, and itsmain.zigis the quick start.
Examples
The examples/ directory contains three runnable programs. Each needs TYPESAFE_API_KEY.
| Command | Shows |
|---|---|
zig build run-triage -- "message" | The typed DSL end to end |
zig build run-dynamic -- "text" label... | Runtime-built questions with systemOne |
zig build run-models | listModels |
Mapping to the HTTP API
| HTTP | tai |
|---|---|
POST /v1/systemone | Client.ask (typed) and Client.systemOne (runtime) |
GET /v1/models | Client.listModels |
Authorization: Bearer | Options.api_key / TYPESAFE_API_KEY |
state | The first argument of ask, or Request.state |
questions.{id} | A struct field name, or NamedQuestion.name |
noul criteria.true / .false | .criteria(yes, no) |
choice criteria map | Struct literal or enum type |
score criteria array | Tuple, struct literal, or enum type |
answers.{id} | r.answers.{field} or Response.get(id) |
usage | r.usage |