ax() API
Structured generation APIs for typed programs.
Most Used
ax
Create an AxGen program from a string or parsed signature.
| Field | Value |
|---|---|
| Kind | function |
| Ax concept | ax |
| API section | AxGen |
| Form | ax(signature, options=None) |
| Returns | AxGen |
Important Options
functionsexamplesdemosmodelConfigmaxRetriesstreaming assertionsfield processors
Examples
qa = ax("question:string -> answer:string")AxGen
Structured generation program with forward, streaming, optimization, trace, usage, and tool-call behavior.
| Field | Value |
|---|---|
| Kind | type |
| Ax concept | AxGen |
| API section | AxGen |
| Form | AxGen(signature, options=None) |
| Returns | program object |
Important Options
signaturefunctionsexamplesdemosmemoryprompt template
fn
Build a typed function tool. Rust uses tool because fn is reserved.
| Field | Value |
|---|---|
| Kind | function |
| Ax concept | fn |
| API section | Tools |
| Form | fn(name).description(...).arg(...).handler(...).build() |
| Returns | tool builder or Tool |
Important Options
namedescriptionargsreturnshandler
Examples
search = fn("search").description("Search docs").arg("query", f.string()).build()Advanced / internals / full reference
Tool
Callable tool descriptor with JSON-schema-compatible parameters and a host handler.
| Field | Value |
|---|---|
| Kind | type |
| Ax concept | Tool |
| API section | Tools |
| Form | Tool(name, description, parameters, handler) |
| Returns | tool descriptor |
Important Options
parametersreturnshandler
Full Reference
Open the full Python reference. This page highlights the ax symbols most relevant to everyday use.