Ax: Build Reliable AI Apps in TypeScript
Stop wrestling with prompts. Start shipping AI features.
Ax brings DSPyβs revolutionary approach to TypeScript β just describe what you want, and let the framework handle the rest. Production-ready, type-safe, and works with all major LLMs.
Transform Your AI Development in 30 Seconds
import { ai, ax } from "@ax-llm/ax";
// 1. Pick any LLM
const llm = ai({ name: "openai", apiKey: process.env.OPENAI_APIKEY! });
// 2. Say what you want
const classifier = ax(
'review:string -> sentiment:class "positive, negative, neutral"',
);
// 3. Get type-safe results
const result = await classifier.forward(llm, {
review: "This product is amazing!",
});
console.log(result.sentiment); // "positive" β¨
Thatβs it. No prompt engineering. No trial and error. It works with GPT-4, Claude, Gemini, or any LLM.
Why Thousands of Developers Choose Ax
π― Define Once, Run Anywhere
Write your logic once. Switch between OpenAI, Anthropic, Google, or 15+ providers with one line. No rewrites needed.
β‘ Ship 10x Faster
Stop tweaking prompts. Define inputs β outputs. The framework generates optimal prompts automatically.
π‘οΈ Production-Ready from Day One
Built-in streaming, validation, error handling, observability. Used by startups in production handling millions of requests.
π Gets Smarter Over Time
Train your programs with examples. Watch accuracy improve automatically. No ML expertise needed.
Real Apps, Real Simple
Extract Structured Data from Customer Emails
const extractor = ax(`
customerEmail:string, currentDate:datetime ->
priority:class "high, normal, low",
sentiment:class "positive, negative, neutral",
ticketNumber?:number,
nextSteps:string[],
estimatedResponseTime:string
`);
const result = await extractor.forward(ai, {
customerEmail: "Order #12345 hasn't arrived. Need this resolved immediately!",
currentDate: new Date(),
});
// Automatically extracts all fields with proper types and validation
Build Agents That Use Tools (ReAct Pattern)
const assistant = ax(
"question:string -> answer:string",
{
functions: [
{ name: "getCurrentWeather", func: weatherAPI },
{ name: "searchNews", func: newsAPI },
],
},
);
const result = await assistant.forward(ai, {
question: "What's the weather in Tokyo and any news about it?",
});
// AI automatically calls both functions and combines results
Multi-Modal Analysis with Images
const analyzer = ax(`
image:image, question:string ->
description:string,
mainColors:string[],
category:class "electronics, clothing, food, other",
estimatedPrice:string
`);
// Process images and text together seamlessly
Quick Start
Install
npm install @ax-llm/ax
Your First AI Feature (2 minutes)
import { ai, ax } from "@ax-llm/ax";
const llm = ai({ name: "openai", apiKey: process.env.OPENAI_APIKEY! });
const translator = ax(`
text:string,
language:string ->
translation:string
`);
const result = await translator.forward(llm, {
text: "Hello world",
language: "Spanish",
});
console.log(result.translation); // "Hola mundo"
Powerful Features, Zero Complexity
- β 15+ LLM Providers - OpenAI, Anthropic, Google, Mistral, Ollama, and more
- β Type-Safe Everything - Full TypeScript support with auto-completion
- β Streaming First - Real-time responses with validation
- β Multi-Modal - Images, audio, text in the same signature
- β Smart Optimization - Automatic prompt tuning with MiPRO
- β Production Observability - OpenTelemetry tracing built-in
- β Advanced Workflows - Compose complex pipelines with AxFlow
- β Enterprise RAG - Multi-hop retrieval with quality loops
- β Agent Framework - Agents that can use tools and call other agents
- β Zero Dependencies - Lightweight, fast, reliable
Learn More
π Quick Wins
- Getting Started Guide - Set up in 5 minutes
- Examples Guide - Comprehensive examples with explanations
- DSPy Concepts - Understand the revolutionary approach
π Deep Dives
- AxFlow Workflows - Build complex AI systems
- Optimization Guide - Make your programs smarter
- Advanced RAG - Production search & retrieval
- API Reference - Complete documentation
Examples
Run any example:
OPENAI_APIKEY=your-key npm run tsx ./src/examples/[example-name].ts
Core Examples
- extract.ts - Extract structured data from text
- react.ts - ReAct pattern with function calling
- agent.ts - Multi-agent collaboration
- streaming1.ts - Real-time streaming responses
- multi-modal.ts - Image + text processing
Production Patterns
- customer-support.ts - Complete support system
- food-search.ts - Restaurant recommendations with tools
- simple-optimizer-test.ts - Automatic optimization
- mipro-python-optimizer.ts - Advanced MIPRO optimization
- ax-flow-enhanced-demo.ts - Complex workflows
π View Full Examples Guide β
View All 70+ Examples β
Join the Community
- π¦ Follow on Twitter - Latest updates
- π¬ Discord Community - Get help, share ideas
- β Star on GitHub - Support the project
- π Ask DeepWiki - AI-powered docs
Production Ready
- β Battle-tested - Used by startups in production
- β No breaking changes - Stable minor versions
- β Comprehensive tests - Large test coverage
- β OpenTelemetry - Built-in observability
- β TypeScript first - Type-safe by design
License
MIT - Use it anywhere, build anything.
Ready to build the future? Stop fighting with prompts. Start shipping with signatures.
npm install @ax-llm/ax
Built with β€οΈ by developers, for developers.