Token-efficient agentic TypeScript runtime
Docs · API Reference · Examples
Six primitives. One agent loop. No magic. Flint gives you well-typed building blocks for AI agents in TypeScript and stays out of the way — plain async functions over the provider API, one runtime dependency, errors returned as values instead of thrown.
npm install flint @flint/adapter-anthropicESM only, Node 20+, strict: true. The Anthropic adapter reads ANTHROPIC_API_KEY from the environment. See the setup guide for tsconfig and .env details.
import { call, tool, agent } from 'flint';
import { budget } from 'flint/budget';
import { anthropicAdapter } from '@flint/adapter-anthropic';
import * as v from 'valibot'; // any Standard Schema library works
const adapter = anthropicAdapter({ apiKey: process.env.ANTHROPIC_API_KEY! });
// One-shot call — errors come back as values, nothing throws
const res = await call({
adapter,
model: 'claude-opus-4-7',
messages: [{ role: 'user', content: 'What is the capital of France?' }],
});
if (res.ok) console.log(res.value.message.content); // "Paris"
// A tool
const add = tool({
name: 'add',
description: 'Add two numbers',
input: v.object({ a: v.number(), b: v.number() }),
handler: ({ a, b }) => a + b,
});
// Agent loop with enforced step / token / dollar caps
const out = await agent({
adapter,
model: 'claude-opus-4-7',
messages: [{ role: 'user', content: 'What is 123 + 456?' }],
tools: [add],
budget: budget({ maxSteps: 5, maxDollars: 0.10 }),
});
if (out.ok) console.log(out.value.message.content); // "579"Core (flint) — 1 runtime dependency (@standard-schema/spec)
- 6 primitives:
call,stream,validate,tool,execute,count agent()loop with step / token / dollar budget caps- compress transforms +
pipeline():dedup,windowLast,windowFirst,truncateToolResults,summarize,orderForCache - recipes:
react,retryValidate,reflect,summarize - RAG (chunk, store, retrieve), conversation memory with async summarization
- safety: injection detection, redaction, permissions, approval gates, boundary wrapping
| Package | Description |
|---|---|
flint |
Core primitives, agent loop, compress, memory, RAG, safety, recipes |
@flint/adapter-anthropic |
Anthropic Messages API — prompt-cache aware |
@flint/adapter-openai-compat |
Any OpenAI-compatible endpoint (OpenAI, Groq, Ollama, DeepSeek, Together) |
@flint/graph |
State-machine agent workflows with memory checkpointing |
@flint/landlord |
Multi-agent orchestration — dynamic workflow runtime and auto-decompose orchestrate() |
Adapters and graph each ship with zero runtime dependencies, on Web API primitives only (fetch, ReadableStream, TextDecoder).
- One dependency —
@standard-schema/speconly. No transitive framework sprawl. - No classes, no chains — plain functions that compose naturally.
- Standard Schema — bring Zod, Valibot, ArkType, or any compatible library.
- Budget-aware — every agent loop enforces step, token, and dollar limits.
- Streaming first —
AsyncIterable<StreamChunk>throughout. - Safety in core — injection detection, redaction, and approval gates, not an afterthought.
- Results, not exceptions —
Promise<Result<T>>everywhere; no try/catch at the call site.
Coming from LangChain? See the Flint vs LangChain guide for a full side-by-side.
Full docs at dizzymii.github.io/Flint — primitives, features, adapters, examples, landlord, testing, and FAQ.
See CONTRIBUTING.md.
MIT — see LICENSE.
