Quick Start
Ax gives TypeScript one typed contract for LLM programs: signatures for data shape, ai() for model access, ax() for structured generation, agent() for tool-using runtime loops, and optimize() for improving programs with examples.
Install
npm install @ax-llm/axFirst Program
Start with a small typed task. The signature declares the fields the model receives and the fields Ax must parse back out.
import { ai, ax } from '@ax-llm/ax';
const llm = ai({ name: 'openai', apiKey: process.env.OPENAI_APIKEY! });
const classify = ax('review:string -> sentiment:class "positive, negative, neutral"');
const result = await classify.forward(llm, {
review: 'Useful and boring in the best way.',
});That is the core loop:
- create a provider client
- declare the input and output contract
- run the program with typed inputs
- read typed outputs instead of scraping prose
flowchart LR A["ai() client"] --> C["forward() with typed inputs"] B["Signature"] --> C C --> D["Validate + retry"] D --> E["Typed output"]
The rest of the site keeps the same concepts but swaps install commands, imports, examples, and API names for TypeScript.
Where To Go Next
Use Examples when you want runnable files. Use Concepts when you want the mental model. Use Subsystems when you know which surface you are trying to use and want the practical call shape.