ThinkLang vs Ax
A feature comparison between ThinkLang and Ax (ax-llm/ax).
Feature Comparison
| Feature | ThinkLang | Ax |
|---|---|---|
| Structured Output | think<T>() with Zod or JSON Schema | gen() with schema |
| Type Safety | Full TypeScript generics | Partial |
| Agents | agent() + multi-agent orchestration | Multi-agent pipelines |
| Tool Calling | defineTool() with Zod input | Function calling |
| Providers | 9+ built-in (Anthropic, OpenAI, Gemini, Groq, DeepSeek, Mistral, Together, OpenRouter, Ollama) | 15+ providers |
| Custom Providers | OpenAICompatibleProvider base class | Adapter pattern |
| Prompt Optimization | optimizedThink() with few-shot examples | DSPy-style optimization |
| Vector Store / RAG | InMemoryVectorStore + indexText() | Built-in RAG pipeline |
| Observability | OpenTelemetry spans on all operations | OpenTelemetry support |
| Big Data | batch(), mapThink(), reduceThink(), Dataset | N/A |
| Streaming | streamThink(), streamInfer() | Streaming support |
| Testing Framework | Built-in .test.tl runner with semantic assertions | N/A |
| Language | .tl files with think keyword | N/A |
| Cost Tracking | Built-in per-call and aggregate cost tracking | N/A |
| Guards | Declarative output validation with retry | N/A |
| Confidence | Confident<T> type with .expect(), .or() | N/A |
Code Comparison
Structured Output
ThinkLang:
import { think, zodSchema } from "thinklang";
import { z } from "zod";
const Sentiment = z.object({
label: z.enum(["positive", "negative", "neutral"]),
score: z.number(),
});
const result = await think<z.infer<typeof Sentiment>>({
prompt: "Analyze sentiment",
...zodSchema(Sentiment),
context: { text },
});Ax:
import Anthropic from "@anthropic-ai/sdk";
import { AxAI, AxChainOfThought } from "@ax-llm/ax";
const ai = new AxAI({ name: "anthropic", apiKey: process.env.ANTHROPIC_API_KEY });
const gen = new AxChainOfThought(ai, "text -> label:string, score:number");
const result = await gen.forward({ text });Agents
ThinkLang:
import { agent, defineTool } from "thinklang";
const result = await agent({
prompt: "Research this topic",
tools: [searchTool, writeTool],
agents: [researcher, writer],
maxTurns: 10,
});What ThinkLang Does Differently
Type Safety First — Generic returns (
think<T>(),agent<T>()) give you compile-time type checking on AI outputs.Testing Framework — Write
.test.tlfiles with semantic assertions. Snapshot fixtures enable deterministic replay without API calls.The
.tlLanguage — A dedicated programming language wherethink,infer, andreasonare first-class keywords. The compiler catches type errors before you spend tokens.Big Data Pipeline —
batch(),mapThink(),reduceThink(), andDatasetmake it easy to process thousands of items through AI with concurrency control and cost budgets.Built-in Cost Tracking — Every call is tracked. Run
thinklang cost-reportto see aggregate spend by model and operation.