DSPy-style programming. RLM-powered agents. One compiled framework.
Build AI features and agents in your app.
Define the inputs and outputs. Improve results using examples and evaluations. Build agents that work through data and tools using code. One shared framework brings it all to TypeScript, Python, Java, C++, Go, and Rust.
Coding with AI? Install the Ax skills — give Claude Code, Cursor, and other coding assistants the Ax API guide for your language.
import { ai, ax } from "@ax-llm/ax";
const llm = ai({ name: "openai" });
const classify = ax(
"review:string -> sentiment:class \"positive, negative, neutral\""
);
const result = await classify.forward(llm, {
review: "This product is amazing!",
});
{
"sentiment": "positive"
}
Abridged examples. Run your first complete program or explore the ledger audit.
One framework, native in six languages. Switch the language to see the same task in its native API. Runnable examples, documentation, and package checks are maintained together.
Why Ax?
Program it. Give it tools. Use it across your stack.
Ax combines three ideas that help you grow from a first AI feature to agents working with real data.
DSPy-style programming
Program and improve your AI.
Define what a task receives and returns. Ax builds the prompt, validates the response, and lets you optimize instructions and examples against your evaluations — tests that score how well the task works.
How DSPy-style programming worksRLM agents
Give agents data they can work with.
Following the Recursive Language Model approach, agents run small code steps to inspect data, calculate results, and use tools. Large inputs stay in the runtime; selected evidence enters the model's context.
See how RLM agents workOne compiled framework
Learn once. Use it across your stack.
One shared core brings consistent concepts and checked behavior to TypeScript, Python, Java, C++, Go, and Rust. Native libraries fit each language, so teams can use Ax in the applications they already have.
How one framework becomes six librariesWhat can you build?
Start with something useful.
Add one AI feature to your app, then combine it with tools and other steps as your needs grow.
Turn documents into usable data
Extract names, dates, and amounts from text into fields your application can use.
Try structured extractionSort messages automatically
Categorize incoming requests, customer feedback, or reviews using the labels you choose.
Build a classifierAnswer questions using your content
Give the model relevant documents and a question to build an assistant for your own content.
Explore question answeringBuild assistants that use your tools
Let an agent look up information, calculate results, and work through several steps to answer a request.
Build your first agentAdd voice to your app
Turn recordings into text, generate spoken responses, or add a voice conversation.
Explore voice examplesAutomate a sequence of tasks
Extract information, analyze it, and produce a report. Use workflows to connect steps, branches, and parallel work.
Build a workflowAI for your databases
Connect your databases to AI with GraphJin.
Ask questions across your databases in plain English. GraphJin connects the data and enforces configured access rules; its built-in agent uses Ax to investigate questions and assemble answers.
Already using Claude Code? These commands connect it to a GraphJin demo with sample data. Connecting your own databases requires a separate GraphJin configuration.
npm install -g graphjinclaude mcp add graphjin -- graphjin mcp --demoQ: which customers churned last month,
and what did they have in common?
A: 9 of 12 churned accounts were on the Starter plan.
7 opened a support ticket in their final 30 days.
Median tenure: 4 months.Queries checked against the schema · configured access rules enforced
GraphJin source codeGraphJin publishes task results, costs, and safety checks with the models and methodology used. Read the current report to see what was tested.
Get started
Quick install
Pick your language and install its native library. The quick start walks you through setting a model API key and running your first program.
npm install @ax-llm/axon npm
Set up your API key and run the first example.
Help your coding agent write Ax
Ax includes skills: instruction files that give Claude Code, Cursor, and other coding assistants the API guide and examples for your chosen language. Install them alongside Ax to help your assistant use the library.
npx skills add https://ax-llm.github.io/ax/typescript/ --skill '*'
Your first AI call · DSPy
Describe the input and output. Ax handles the model call.
A signature is a short description of the inputs you provide and the outputs you want. In the review example, text goes in and a sentiment label comes back. This is the DSPy-style starting point: define the task, then test and improve how it performs.
Get results your app can use.
Ax parses the response into fields, checks their types and constraints, and can retry with feedback when validation fails. These checks enforce the requested format; evaluate the answers too when correctness matters.
Signature pipeline
Ax handles the steps around the model call.
Your signature supplies the prompt fields and output checks. Ax calls the model, reads its response, and returns the declared fields. You can also stream results and inspect the steps when something goes wrong.
Signature syntax
const extract = ax(
"doc:string -> names:string[], dates:date[], amounts:number[]"
);
Name the inputs and outputs in one line. Use arrays, dates, numbers, and other field types to describe the result you need.
Fields and constraints
const sig = f()
.input("document", f.string().min(10))
.output("summary", f.string().max(500))
.output("tags", f.string().array())
.build();
Build a signature in code when you need rules such as a maximum summary length or a list of tags.
Structured schema output
const sig = f()
.output(z.object({
summary: z.string(),
score: z.number().min(1).max(10),
}))
.build();
Use a supported schema builder to define the output shape and constraints, such as a score from one to ten.
Patterns
Small tasks start with a few fields.
These signature examples describe a task’s inputs and outputs. Run the program with a model and input values, as shown in the quick start. Choose your language to see the equivalent syntax.
Classification
Categorize text into predefined classes.
ax("text:string -> category:class \"spam, ham, promo\"")Extraction
Pull structured data from unstructured text.
ax("document:string -> names:string[], dates:date[]")Question answering
Answer questions with provided context.
ax("context:string, question:string -> answer:string")Ask about an image
Provide a photo and a question about it.
ax("photo:image, question:string -> answer:string")Make a decision
Ask the model for a yes-or-no result based on the inputs.
ax("email:string, score:number -> valid:boolean")Generate text
Turn a topic into text. Use the streaming API to receive it incrementally.
ax("topic:string -> chunk:string")Translation
Translate text into the language you request.
ax("text:string, targetLanguage:string -> translation:string")Summarize a document
Return a summary and key points from one task.
ax("doc:string -> summary:string, keyPoints:string[]")Agents · RLM
Build agents that work through data and tools.
An agent works through a task over several steps. Ax uses the RLM approach: the agent writes and runs code against data and tools, then uses the results to decide what to do next. Large inputs can stay in its runtime session, with selected evidence passed to the model.
Try the grounded-audit example: an agent audits a 250-row ledger and checks its totals and flagged transactions against an answer calculated in ordinary code. The published results describe this specific task and the models tested. See the measurements.
Answer using a few tools Micro agents
Start with a small task, the functions it needs, and the fields you want in the reply.
Coordinate tools and specialists Standard agents
Let an agent find relevant tools, delegate work to specialist agents, and ask for clarification.
Work through larger tasks Long-horizon agents
Keep useful state, memory, and instructions available as an agent works through a longer job.
import { agent, ai } from "@ax-llm/ax";
const llm = ai({ name: "google-gemini" });
const auditor = agent(
"ledger:json[], question:string -> total:number, flagged:string[]",
{
contextFields: ["ledger"], // 250 rows stay in the runtime
functions: [getVendor, getPolicy],
}
);
const result = await auditor.forward(llm, {
ledger, // never enters the prompt
question: "Total PROJECT-X spend; flag txns over threshold",
});
Find the right tools
Discovery lets the agent load the tools it needs as it works, even when many are available.
Keep track of the task
Context maps and summaries help the agent find relevant information without rereading the whole conversation.
Reuse useful knowledge
Add memory for information worth recalling and skills for instructions the agent can use again.
Improve against your tests
Use agent.optimize(...) with examples and scoring criteria to evaluate changes to agent behavior.
Function discovery
Connect tools and specialist agents as the job grows.
Group related tools and give specialist agents focused jobs. The main agent can discover those capabilities when it needs them.
Context policy
Keep the work available between steps.
Store intermediate results in the runtime and use summaries to track progress. Context policies control how much of the conversation the model sees on later turns.
MCP and tools
Connect your AI to tools and services.
Tools let your AI call functions in your application. MCP (Model Context Protocol) is a standard way to connect tools from other services. Ax can use both in a task or an agent.
Audio
Build text, voice, and realtime AI apps.
Turn recordings into transcripts, generate spoken responses, or build a voice conversation. Choose a model and audio API that support the experience you need.
Choose what your app needs to hear or say.
ai.transcribe(...)for batch speech-to-text.ai.speak(...)for batch text-to-speech.speech:audiofor a program that returns generated speech alongside other fields..chat()audio config for conversational or realtime audio turns.- Agents can transcribe audio inputs and work with the resulting text.
import { ai, ax } from "@ax-llm/ax";
const llm = ai({ name: "openai" });
const narrator = ax("article:string -> speech:audio, summary:string");
const result = await narrator.forward(
llm,
{ article },
{ speech: { speak: { voice: "alloy", format: "mp3" } } }
);
Transcribe and speak
Turn a recording into text or generate an audio file from a written response.
Conversational audio
Build a spoken conversation using a provider’s supported audio chat or realtime API.
Agent audio
Give an agent a recording to work from and return a spoken response.
Improve with evaluations · DSPy
Improve your AI against examples of good results.
Give Ax example tasks and a way to score the results. Its optimizers test changes to instructions and examples so you can compare answer quality, speed, and cost. This is the next step in DSPy-style programming: improve the program against evaluations you control.
Choose the results that fit your app.
GEPA searches for useful tradeoffs rather than one score alone. Compare the candidates, evaluate the one you choose on fresh tasks, and save its configuration for reuse. Optimization is an explicit training step; it does not happen automatically on every request.
LLM providers
Choose the model that fits your app.
Use OpenAI, Claude, Gemini, or a supported local model through ai(). Keep your task’s inputs and outputs while trying different models. Available features, such as voice, depend on the provider.
const openai = ai({ name: "openai" });
const claude = ai({ name: "anthropic" });
const local = ai({
name: "openai",
config: { baseURL: "http://localhost:11434/v1" },
});
Need routing, embeddings, audio, or context caching? Read the LLM guide.
Understand your app in production
See what happened and what it cost.
Follow model calls and tool use, investigate errors, and track response times and estimated costs. Ax integrates with OpenTelemetry so you can inspect AI work alongside the rest of your application.
Follow a request
OpenTelemetry traces connect model calls, tool calls, and agent steps.
Spot slow or failing steps
Track response times, token usage, and errors as your app runs.
Show results as they arrive
Stream output fields and check their format and constraints with validation and retry feedback.
Track estimated costs
See the estimated model cost of a request and compare it with answer quality.
Work across your stack
Use the shared Ax programming model from each of the six native libraries.
Control how requests run
Configure rate limits, provider routing, redaction, and error handling for your app.
Operate Ax systems
Trace a result back to the steps that produced it.
Use the telemetry guide to connect Ax’s traces and metrics to your monitoring tools.
AxIR compiler
One framework, compiled into native libraries.
TypeScript is the reference runtime. The AxIR compiler represents shared Ax behavior in a portable intermediate representation and emits native libraries for Python, Java, C++, Go, and Rust. Each library uses its language’s own names, errors, and builders, with shared checks for supported behavior.
Compiler pipeline
Shared behavior. APIs that fit your language.
Use Ax in a Python service, a TypeScript app, or a Go backend while working with the same concepts. The compiler emits APIs shaped for each language from the shared core.
Verified across languages
Language support comes with checks you can inspect.
The axir verify checks cover generated packages and their shared behavior. Runnable examples, documentation, and capability manifests show what each language supports, including differences in host runtimes and transports.
The ideas behind it
Built on DSPy, GEPA, ACE, RLM, and PEEK.
Explore the papers behind the programming model, optimization, and agents you have seen on this page. Each link connects a research idea to the part of Ax that puts it to work.
Declarative modules, signatures, examples, and self-improving LLM pipelines shape Ax's programming model.
Constraints, validation, and self-refinement inform Ax signatures, schemas, retry feedback, and output reliability.
Reflective prompt evolution and Pareto tradeoffs map directly to Ax optimization for generators, flows, and agents.
Evolving context playbooks via generation, reflection, and curation map to Ax's ACE optimizer for agents and programs.
External runtime loops and recursive model calls inform AxAgent's runtime state, execution boundary, and small-context turns.
Persistent context maps and orientation caches are the product instinct behind Ax memory, skills, and context management.
Ax Academy
Learn Ax step by step.
A free course in your browser, with short lessons, practice exercises, and review tailored to what you need next. Take it one lesson at a time; the full course is about six hours.
Start now
Build your first AI feature today.
Choose your language, install Ax, and run a small task. Add tools, agents, and optimization when you need them.
Built by @dosco — follow on X for new releases and to chat about Ax.
Building with an AI coding agent? Install the Ax skills to give your assistant the API guide.