Ax
The pretty much "official" DSPy framework for Typescript
Last verified:
What is Ax?
Ax is a TypeScript framework for building reliable AI applications that brings DSPy's approach to TypeScript development. Instead of manually writing and debugging prompts, developers define what inputs they provide and what outputs they expect, and Ax automatically generates optimal prompts. The framework handles prompt engineering, validation, error handling, and retries underneath, allowing developers to ship AI features faster without maintaining infrastructure.
Key features include support for 15+ LLM providers (OpenAI, Anthropic, Google, Mistral, Ollama, and more) with the ability to switch providers in one line of code. Ax provides full TypeScript support with auto-completion, real-time streaming with validation, multi-modal capabilities for images and audio, automatic prompt tuning with MiPRO/ACE/GEPA optimizers, built-in OpenTelemetry tracing, AxFlow for complex workflows, multi-hop RAG with quality loops, and agent tools with multi-agent collaboration. The framework is zero-dependency, lightweight, and production-ready.
Ax is designed for TypeScript developers building AI applications who want to avoid prompt engineering headaches. It's ideal for teams shipping AI features to production, developers working with multiple LLM providers, those needing structured data extraction, classification tasks, agent-based workflows, RAG systems, or anyone who wants type-safe AI applications with automatic optimization and built-in observability.
Ax pricing
Pricing model: Freemium
Ax itself is free and open source under Apache 2.0 license. The framework has zero dependencies and is lightweight. However, you need your own API keys from LLM providers (OpenAI, Anthropic, Google, etc.) which have their own pricing. Installation is via npm install @ax-llm/ax at no cost. Additional optional packages include @ax-llm/ax-ai-aws-bedrock for AWS Bedrock, @ax-llm/ax-ai-sdk-provider for Vercel AI SDK v5, and @ax-llm/ax-tools for MCP and code execution tools - all free.
Ax pros
- No prompt engineering required - framework generates optimal prompts automatically
- Write once, run anywhere - switch between 15+ LLM providers with one line
- Full TypeScript support with auto-completion and type safety
- Real-time streaming with built-in validation during generation
- Multi-modal support for images, audio, and text in same signature
- Automatic prompt tuning with MiPRO, ACE, and GEPA optimizers
- Built-in OpenTelemetry tracing for production observability
- AxFlow for composing complex AI pipelines and workflows
- Multi-hop RAG with quality loops for production search
- Agent support with tools and multi-agent collaboration
- Zero dependencies - lightweight, fast, and reliable
- Automatic retry with corrections on validation errors
- Input and output validation with constraints like email, URL, regex
- Battle-tested in production handling millions of requests
- Stable minor versions with comprehensive test coverage
- Works with GPT-4, Claude, Gemini, and any major LLM
- AWS Bedrock provider for Claude, GPT, Titan on AWS
- Vercel AI SDK v5 integration with LanguageModelV2 specification
- 70+ comprehensive examples for real-world patterns
- Apache 2.0 license - open source and free to use
Ax cons
- Requires Node.js 20 or higher - older versions not supported
- TypeScript-first - JavaScript users get limited benefits
- Must learn DSPy concepts and signature syntax upfront
- Requires API keys from LLM providers - not free itself
- Learning curve for developers new to DSPy paradigm
- Debug mode needed to see what happens under the hood
- Browser usage requires corsProxy setup in some cases
- Limited to TypeScript ecosystem - no Python or other language support
Frequently asked questions about Ax
Which LLM providers does Ax support?
Ax supports 15+ LLM providers including OpenAI, Anthropic, Google Gemini, Mistral, Groq, Cohere, Together, DeepSeek, Ollama, HuggingFace, OpenRouter, Azure OpenAI, Reka, and x-Grok. You can switch between providers with one line of code without rewriting your application.
How do I install Ax?
Install Ax with npm install @ax-llm/ax. You need Node.js 20 or higher. Set your API key as an environment variable like OPENAI_APIKEY=your-api-key-here in a .env file or export it in your terminal. Additional packages are available for AWS Bedrock, Vercel AI SDK v5, and tools.
How does validation work in Ax?
Validation runs before LLM calls on inputs and after LLM responses on outputs with automatic retry on errors. Available constraints include .min(n), .max(n), .email(), .url(), .date(), .datetime(), .regex(pattern, description), and .optional(). Validation also works during streaming with incremental validation as fields complete.
What optimization techniques does Ax use?
Ax automatically tunes prompts using MiPRO, ACE, and GEPA optimizers. You can train your programs with examples and watch accuracy improve automatically without ML expertise. These optimizers are documented in the Optimization guide and help make your AI programs smarter over time.
What is AxFlow?
AxFlow is used to compose complex AI pipelines and workflows. It enables building multi-step processes and complex AI systems. Production patterns include customer-support.ts, food-search.ts, ace-train-inference.ts, and ax-flow-enhanced-demo.ts. The AxFlow Workflows documentation provides deep dives into building complex AI systems.
Is Ax production-ready?
Yes, Ax is battle-tested in production handling millions of requests. It has stable minor versions, comprehensive test coverage, built-in OpenTelemetry tracing, TypeScript-first design, and Apache 2.0 license. The framework includes built-in streaming, validation, error handling, and observability for production use.