Documentation

Build LLM-powered agents
with production-ready TypeScript

DSPy for TypeScript. Working with LLMs is complex—they don't always do what you want. DSPy makes it easier to build amazing things with LLMs. Just define your inputs and outputs (signature) and an efficient prompt is auto-generated and used. Connect together various signatures to build complex systems and workflows using LLMs.

15+ LLM Providers
End-to-end Streaming
Auto Prompt Tuning

Migration Guide

This major release removes the old compatibility surfaces that were kept during the factory API transition. New code should use the factory functions and the current optimizer/artifact model.

Use Factories

import { ai, ax, s, flow } from "@ax-llm/ax";

const llm = ai({ name: "openai", apiKey: process.env.OPENAI_APIKEY });
const sig = s("question:string -> answer:string");
const gen = ax("question:string -> answer:string");
const workflow = flow<{ question: string }>();

Removed constructor paths:

Tagged template forms were also removed. Use ax("...") and s("...").

Provider Changes

Wrapper/platform providers were removed from the core package:

Use the OpenAI provider for custom OpenAI-compatible endpoints:

const gateway = ai({
  name: "openai",
  apiURL: "https://api.example.com/v1",
  apiKey: process.env.OPENAI_COMPAT_APIKEY,
  models: [
    { key: "default", model: "provider/model-name", description: "Default model" },
  ],
  config: { model: "default" },
});

Kept providers include OpenAI, OpenAI Responses, Azure OpenAI, Anthropic, Gemini, Mistral, Cohere, Reka, DeepSeek, Grok/xAI, and HuggingFace.

Removed Subsystems

The old document/RAG/vector database stack has been removed:

The old classifier helpers were removed:

The old self-improvement stack was removed:

Use GEPA, agent.optimize(...), and AxBootstrapFewShot for retained optimization workflows.

Removed Compatibility Aliases

Use the current names and artifact shapes: