Declare signatures, not prompts. Ax compiles type-safe inputs and outputs into optimized LLM calls — then chains them into agents, flows, and self-improving pipelines.

15+ LLM Providers
6 Native Language Packages
DSPy + GEPA Optimizer
RLM Agent Runtime
$
npm install @ax-llm/ax

Why teams choose Ax

Built for production from day one

Battle-tested

Production-Ready

Streaming, validation with auto-retry, OpenTelemetry observability, structured error handling.

Streaming
Validation
Telemetry
Auto-retry
0

Dependencies

No date library dependency. OpenTelemetry stays external and Zod remains peer-only.

6 Languages

Native Packages

TypeScript, Python, Java, C++, Go, and Rust packages share one Ax semantic core.

TSPythonJavaC++GoRust
Multi-Objective

GEPA Optimizer

Returns Pareto frontiers — balance accuracy vs speed vs cost. Pick the optimal trade-off.

Deep Context

Recursive Language Model

Long-context analysis with persistent sessions and iterative refinement. Keeps long context out of root prompt.

Autonomous

AxAgent

ReAct loops, tool calling, child agents, context policies, dynamic function discovery.

Simple & Powerful

Define what you want, not how to prompt for it

classify.ts
import { ax, ai } 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!'
})
output
{
  "sentiment": "positive"
}
Type-safe, validated, auto-retried on failure

One signature, native code

String signatures, fluent builders, and schema output share the same Ax semantics in every language package.

analyze.ts
import { f, ax } from '@ax-llm/ax'

const sig = f()
  .input('document', f.string().min(10))
  .output('summary', f.string().max(500))
  .output('entities', f.object({
    name: f.string().min(1),
    type: f.class(['person', 'org', 'place']),
    confidence: f.number().min(0).max(1),
  }).array())
  .output('tags', f.string().array())
  .build()

const result = await ax(sig).forward(llm, { document })
output
Typed Output
{
  "summary": "Service agreement between...",
  "entities": [
    { "name": "Acme Corp", "type": "org", "confidence": 0.95 },
    { "name": "Jane Smith", "type": "person", "confidence": 0.88 }
  ],
  "tags": ["contract", "legal", "NDA"]
}
Nested objects and typed arrays
Schema validation before returning
Auto-retry on validation failure
Ax Agent

DSPy + RLM agents that actually work

Typed DSPy signatures, a secure JS runtime, and checkpointed context management — a full agent harness that keeps long-running loops stable without prompt bloat.

researcher.ts
JS runtime session
import { agent, AxJSRuntime } from '@ax-llm/ax'

const researcher = agent(
  'topic:string, largeDocument:string -> report:string',
  {
    runtime: new AxJSRuntime(),
    contextFields: ['largeDocument'],
    functions: [search, scrape],
  }
)

const { report } = await researcher.forward(ai, {
  topic: '...',
  largeDocument: doc,
})

Prompt stays lean — across every turn

State lives in the runtime session, not the LLM context

RLM
Naive agent
Ax Agent (RLM)
≈10× less tokens

State in the runtime, not the prompt

Runtime sessions keep objects alive across turns. The LLM only sees a compact current-state summary — token cost stays flat no matter how long the loop runs.

RLM loopBounded contextHost runtime

Typed signatures — end to end

Declare agents as 'topic:string -> report:string'. Inputs and outputs follow the same Ax contract across native language packages.

DSPy-styleNative packagesSchema validated

Auto-optimized with DSPy + GEPA

Few-shot examples are tuned automatically. GEPA finds the instruction set that maximizes accuracy across your evals — no manual prompt engineering required.

GEPADSPyFew-shot tuning

Production-ready from day one

Extensive test coverage, full OpenTelemetry integration, cost tracking, and enterprise-grade error handling — built in, not bolted on.

1000+
Tests
40+
OTel Metrics
15+
LLM Providers
6
Languages

OpenTelemetry

Full distributed tracing with spans per LLM call, function invocation, and agent turn. Drop-in Jaeger, Prometheus, or cloud exporters.

Detailed Metrics

Token usage, latency histograms, error rates, context window utilization, and thinking budget tracking — all as OpenTelemetry metrics.

Streaming & Validation

End-to-end streaming with structured output validation. Auto-retries on schema failures with error correction built in.

Cost Tracking

Per-request cost estimation across all providers. Budget monitoring, optimization insights, and cost allocation labels.

Multi-Language

One semantic core spans TypeScript, Python, Java, C++, Go, and Rust package shapes — from embedded apps to web services.

Enterprise Ready

Rate limiting, configurable sampling, content redaction, error handling with hindsight evaluation, and custom metric creation.

What's in the box

Everything you need to build production AI applications

Declare capabilities, not prompts

Define your inputs and outputs with type-safe signatures. Ax generates the optimal prompt automatically.

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[], amounts:number[]')

Question Answering

Answer questions given context

ax('context:string, question:string -> answer:string')

Multi-Modal

Process images and audio alongside text

ax('photo:image, question:string -> answer:string')

Validation

Auto-validate outputs with built-in constraints

ax('email:string, score:number -> valid:boolean')

Streaming

Get results as they generate in real-time

ax('topic:string -> chunk:string')

Translation

Translate between any languages

ax('text:string, targetLanguage:string -> translation:string')

Complex Workflows

Multiple typed outputs from a single call

ax('doc:string -> summary:string, keyPoints:string[], sentiment:class "pos, neg"')

One interface, every LLM

Switch providers with a single line. Your signatures work everywhere.

OpenAI
ai({ name: 'openai' })
Anthropic
ai({ name: 'anthropic' })
Google Gemini
ai({ name: 'google-gemini' })
Cohere
ai({ name: 'cohere' })
DeepSeek
ai({ name: 'deepseek' })
Mistral
ai({ name: 'mistral' })
Grok
ai({ name: 'grok' })
Reka
ai({ name: 'reka' })
AWS Bedrock
new AxAIBedrock({ region: 'us-east-2' })

Rich type system

Type-safe signatures with automatic validation and retry on failure.

stringname:stringText
numberscore:numberNumeric
booleanvalid:booleanTrue/false
classcat:class "a,b"Enum
string[]tags:string[]Array
jsondata:jsonObject
imagephoto:imageImage
audioclip:audioAudio
datedue:dateDate
?notes?:stringOptional
Also Checkout

Connect AI to your database

GraphJin compiles GraphQL to efficient SQL and doubles as an MCP server — giving Claude Desktop and Ax agents direct, safe access to your data.

ax-agent.ts
import {
  AxAI, AxAgent, AxMCPClient,
  AxMCPHTTPSSETransport
} from '@ax-llm/ax';

// Connect to GraphJin's MCP server
const transport = new AxMCPHTTPSSETransport(
  'http://localhost:8080/api/v1/mcp'
);
const mcp = new AxMCPClient(transport);
await mcp.init();

// Use GraphJin tools in an Ax agent
const agent = new AxAgent({
  name: 'data-analyst',
  description: 'Queries databases',
  signature: 'question:string -> answer:string',
  functions: mcp.toFunction(),
});

Connect GraphJin as an MCP tool inside Ax agents

Works withPostgreSQLMySQLSQLiteMongoDBOracleMSSQLSnowflake