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
CommandWhat it does
zig build testOffline: 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 e2eRuns the e2e tests and the quick start against the live API
zig build snippetsRe-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 on tai by path. Its build.zig is the install example, and its main.zig is the quick start.

Examples

The examples/ directory contains three runnable programs. Each needs TYPESAFE_API_KEY.

CommandShows
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-modelslistModels

Mapping to the HTTP API

HTTPtai
POST /v1/systemoneClient.ask (typed) and Client.systemOne (runtime)
GET /v1/modelsClient.listModels
Authorization: BearerOptions.api_key / TYPESAFE_API_KEY
stateThe 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 mapStruct literal or enum type
score criteria arrayTuple, struct literal, or enum type
answers.{id}r.answers.{field} or Response.get(id)
usager.usage