Examples
Every TypeScript example here is runnable source under src/examples/typescript/ and calls a real provider API. The website and npm run example -- list are generated from each file’s ax-example header.
Groups
- Generation - 3 examples.
- Agents - 4 examples.
- Long-Horizon Agents - 5 examples.
- Flows - 3 examples.
- Audio - 3 examples.
- Optimization - 4 examples.
Generation
- TypeScript Typed Generation - Runs a small typed generation program against OpenAI. Run:
npm run example -- typescript src/examples/typescript/generation/axgen-openai.ts. - TypeScript Structured Extraction - Extracts structured fields and labels from support text with OpenAI. Run:
npm run example -- typescript src/examples/typescript/generation/structured.ts. - TypeScript Contextual Generation - Answers from supplied context and returns compact citations with OpenAI. Run:
npm run example -- typescript src/examples/typescript/generation/context.ts.
Agents
- TypeScript Grounded Support Agent - Answers a support question grounded in a handbook that is kept out of the model prompt via contextFields. Run:
npm run example -- typescript src/examples/typescript/short-agents/agent-openai.ts. - TypeScript Incident Triage Agent - Triages a noisy incident report held in contextFields, using a lean contextPolicy to keep the raw log out of the prompt while it reasons. Run:
npm run example -- typescript src/examples/typescript/short-agents/tools-agent.ts. - TypeScript Specialist Planner Agent - A specialist that plans a migration from a long brief held in contextFields, using a checkpointed contextPolicy and a runtime-output cap to stay compact. Run:
npm run example -- typescript src/examples/typescript/short-agents/handoff-agent.ts. - TypeScript Multi-Model Panel - Fans one question across three providers (OpenAI, Gemini, Anthropic), then judges the candidates and synthesizes a single grounded answer. Run:
npm run example -- typescript src/examples/typescript/short-agents/model-panel.ts.
Long-Horizon Agents
- TypeScript Incident Log Forensics (RLM) - Infers service architecture and root-cause findings from a huge CloudWatch export that never enters the prompt — held in contextFields and worked through the runtime under a lean contextPolicy. Run:
npm run example -- typescript src/examples/typescript/long-agents/incident-log-forensics.ts. - TypeScript Codebase Q&A with a Peek Context Map - Answers several dependency questions over one large module index by building and reusing an evolving context map (the “peek” orientation cache), so later questions skip re-scanning the corpus. Run:
npm run example -- typescript src/examples/typescript/long-agents/codebase-peek-map.ts. - TypeScript Data Analyst (Large Context + Tools) - Combines a large data dictionary held in contextFields with typed fn() warehouse tools, so the agent answers business questions over a big dataset it never has to inline. Run:
npm run example -- typescript src/examples/typescript/long-agents/data-analyst-with-tools.ts. - TypeScript Self-Improving Lab Agent - A many-tool agent that runs experiments, grades them against a rubric with an independent verifier, and distills verified rules into memory — iterating until the rubric passes. Run:
npm run example -- typescript src/examples/typescript/long-agents/self-improving-lab.ts. - TypeScript Skills + Memory Ops Assistant - An on-call assistant that recalls past decisions from a memory store and loads the right runbook skill on demand, using the agent skills and memories subsystems. Run:
npm run example -- typescript src/examples/typescript/long-agents/skills-and-memory-assistant.ts.
Flows
- TypeScript Sequential Flow - Runs a two-step Ax flow against OpenAI. Run:
npm run example -- typescript src/examples/typescript/flows/flow-openai.ts. - TypeScript Branching Flow - Routes a classification through follow-up flow logic backed by OpenAI. Run:
npm run example -- typescript src/examples/typescript/flows/branch-flow.ts. - TypeScript Composed Flow - Composes multiple typed programs into one OpenAI-backed flow. Run:
npm run example -- typescript src/examples/typescript/flows/composed-flow.ts.
Audio
- TypeScript Text To Speech - Generates speech audio through OpenAI. Run:
npm run example -- typescript src/examples/typescript/audio/speech-audio.ts. - TypeScript Speech To Text - Transcribes a checked-in WAV file through OpenAI. Run:
npm run example -- typescript src/examples/typescript/audio/transcribe-audio.ts. - TypeScript Audio Summary Pipeline - Transcribes audio and summarizes the transcript with an OpenAI-backed generator. Run:
npm run example -- typescript src/examples/typescript/audio/pipeline-audio.ts.
Optimization
- TypeScript AxGen Optimization - Runs a baseline OpenAI prediction and applies a real optimizer result. Run:
npm run example -- typescript src/examples/typescript/optimization/axgen-optimization.ts. - TypeScript GEPA Optimization - Pairs a real OpenAI baseline with a local GEPA optimization pass. Run:
npm run example -- typescript src/examples/typescript/optimization/gepa-optimization.ts. - TypeScript Playbook Context Evolution - Grows a context playbook offline with playbook().evolve, then refines it online with .update(). Run:
npm run example -- typescript src/examples/typescript/optimization/playbook-context-evolution.ts. - TypeScript Optimization Artifact Reuse - Saves and reapplies a real optimizer artifact after an OpenAI baseline. Run:
npm run example -- typescript src/examples/typescript/optimization/artifact-optimization.ts.
Source
- Catalog:
npm run example -- list --jsonfromscripts/example-catalog.mjs - Files:
src/examples/typescript/
Pages
- Generation Generation — TypeScript examples backed by real provider calls.
- Agents Agents — TypeScript examples backed by real provider calls.
- Long-Horizon Agents Long-Horizon Agents — TypeScript examples backed by real provider calls.
- Flows Flows — TypeScript examples backed by real provider calls.
- Audio Audio — TypeScript examples backed by real provider calls.
- Optimization Optimization — TypeScript examples backed by real provider calls.