Ax Build AI features and agents with DSPy-style programming, RLM agents, and one compiled framework. Native libraries for TypeScript, Python, Java, C++, Go, and Rust. typescript home home _index.md home Ax

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.

Open-source AI library Validated outputs Cloud and local models Native in six languages

Coding with AI? Install the Ax skills — give Claude Code, Cursor, and other coding assistants the Ax API guide for your language.

TypeScript classify.ts ax()
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!",
});
Example result
{
  "sentiment": "positive"
}
Type-safe, validated, auto-retried on failure

Abridged examples. Run your first complete program or explore the ledger audit.

Ax in your language

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.

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 works

RLM 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 work

One 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 libraries

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 extraction

Sort messages automatically

Categorize incoming requests, customer feedback, or reviews using the labels you choose.

Build a classifier

Answer questions using your content

Give the model relevant documents and a question to build an assistant for your own content.

Explore question answering

Build 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 agent

Add voice to your app

Turn recordings into text, generate spoken responses, or add a voice conversation.

Explore voice examples

Automate a sequence of tasks

Extract information, analyze it, and produce a report. Use workflows to connect steps, branches, and parallel work.

Build a workflow

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 graphjin
$claude mcp add graphjin -- graphjin mcp --demo
Example question and answer
Q: 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 code

DeepORG benchmark

Read the published results

GraphJin publishes task results, costs, and safety checks with the models and methodology used. Read the current report to see what was tested.

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 '*'
Browse agent skills

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.

ValidationStreamingToolsTracesOptimization
Signature contract network

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 to runtime pipeline

Signature syntax

TypeScript signatures.ts TypeScript
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

TypeScript fields.ts TypeScript
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

TypeScript schema.ts TypeScript
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.

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.

TypeScript Classification Classification
ax("text:string -> category:class \"spam, ham, promo\"")

Extraction

Pull structured data from unstructured text.

TypeScript Extraction Extraction
ax("document:string -> names:string[], dates:date[]")

Question answering

Answer questions with provided context.

TypeScript Question answering Question answering
ax("context:string, question:string -> answer:string")

Ask about an image

Provide a photo and a question about it.

TypeScript Image questions Image questions
ax("photo:image, question:string -> answer:string")

Make a decision

Ask the model for a yes-or-no result based on the inputs.

TypeScript Decision Decision
ax("email:string, score:number -> valid:boolean")

Generate text

Turn a topic into text. Use the streaming API to receive it incrementally.

TypeScript Text generation Text generation
ax("topic:string -> chunk:string")

Translation

Translate text into the language you request.

TypeScript Translation Translation
ax("text:string, targetLanguage:string -> translation:string")

Summarize a document

Return a summary and key points from one task.

TypeScript Summarization Summarization
ax("doc:string -> summary:string, keyPoints:string[]")

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.

Micro agents

Coordinate tools and specialists Standard agents

Let an agent find relevant tools, delegate work to specialist agents, and ask for clarification.

Standard agents

Work through larger tasks Long-horizon agents

Keep useful state, memory, and instructions available as an agent works through a longer job.

Long-horizon agents

TypeScript audit.ts JS runtime session
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",
});
RLM loop

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.

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.

Agent function discovery tree

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.

Context growth chart

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.

Read the MCP guide or open the tools guide.

MCP bridge

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:audio for 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.

Read the LLM guide or open media examples.

TypeScript audio.ts speech:audio
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 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.

Read optimization docs or open the optimize API.

GEPA Pareto frontier

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.

OpenAI Claude Gemini OpenAI-compatible Local
TypeScript providers.ts TypeScript
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.

Provider router map

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.

1000+tests
40+OTel metrics
15+LLM providers
6languages

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.

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.

Read telemetry docs.

Production telemetry loop

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.

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.

AxIR compiler pipeline

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.

Language package matrix

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.

Alex L. Zhang, Tim Kraska, Omar Khattab.

External runtime loops and recursive model calls inform AxAgent's runtime state, execution boundary, and small-context turns.

arXiv 2512.24601
MITStanford

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.

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.