Antfly is a search-and-inference database written in Zig. One engine carries full-text (BM25), dense, and sparse vector indexes plus graph traversal over the same table, and the models that chunk, embed, rerank, transcribe, OCR, and extract run inside the process. Embeddings, chunks, entities, and graph edges are generated automatically as you write data, and built-in RAG agents tie it together. The same engine runs as a single .aflite file, a single node with a hot standby, a multi-Raft cluster, or serverless over object storage.
# Install the CLI (macOS and Linux), then start a single node with built-in ML inference
curl -fsSL https://releases.antfly.io/antfly/latest/install.sh | sh
antfly standalone
# Or with Homebrew (macOS or Linux)
brew install antflydb/taps/antfly
# Or build from source
make build && ./antfly standalone
# Or run with Docker
docker run -p 127.0.0.1:8080:8080 ghcr.io/antflydb/antfly:latest standalone --host 0.0.0.0These quickstarts run without authentication and are intended for local development. Keep Docker ports bound to loopback. Before allowing remote access, enable authentication and provision a unique admin password, then configure TLS at a reverse proxy.
That gives you the Antfarm dashboard at http://localhost:8080 — playgrounds for search, RAG, knowledge graphs, embeddings, reranking, and more.
See the quickstart guide for a full walkthrough.
| Product | How it runs | License |
|---|---|---|
| Antfly Lite | An embedded .aflite database through libantfly, Zig, Go, Python, Rust, TypeScript, or browser WASM; local file commands through antfly-lite lite |
Apache 2.0 |
| Antfly inference | In-process inference, browser WASM (wasm32/wasm64), or the independent antfly-inference executable and inference APIs |
Apache 2.0 |
| Antfly database server | antfly standalone, distributed clusters, or serverless deployment; database HTTP APIs and the dashboard |
ELv2 |
The Apache antfly-embedded release archive bundles antfly-lite,
antfly-inference, libantfly, its C header, and the private inference worker,
with runtime files and license notices. Python/npm embedded packages use the same
library without installing public commands. Go/Rust consumers
link the library from the archive or a local build using its relocatable
lib/pkgconfig/libantfly.pc metadata.
Zig applications can fetch the independent Apache
antfly-embedded-source_<version>.tar.gz release package. It exports the
embedded and inference modules and native/WASM artifacts without a server
checkout; see the Zig package guide.
Build the Apache Lite CLI and native library from source:
cd zig
zig build lite -j1
./zig-out/bin/antfly-lite lite init app.afliteThe Lite build installs its CLI, libantfly, and the C header. To serve that file over HTTP, use the full database server executable:
antfly standalone --storage-engine lite --storage-path app.afliteThe standalone server uses the same Apache engine under ELv2. See LICENSING.md for the source boundaries and third-party licenses.
- Hybrid search — full-text (BM25), dense vectors (RaBitQ-compressed with SPFresh-style updates), and sparse vectors (SPLADE), fused with reciprocal rank or relative score fusion in one query
- Full-text search — Lucene-style segments with highlighting, geo, regex, wildcard, and fuzzy queries, plus English and ten Snowball stemmer languages
- RAG agents — built-in retrieval-augmented generation with streaming, multi-turn chat, tool calling (graph traversal, plus web search through an Exa connection), confidence scoring, and TOON document rendering to cut prompt tokens
- Query-builder agent — turns a natural-language question into a structured Antfly query, with evaluation metrics to measure retrieval quality
- Graph indexes — automatic relationship extraction and graph traversal over your data
- Multimodal — index and search images, audio, and video with CLIP, CLAP, and vision-language models
- Reranking — cross-encoder and late-interaction (ColBERT, ColQwen2) reranking with score-based pruning to cut the noise
- Aggregations — stats, terms facets, histogram, date histogram, range, and geo-distance aggregations for analytics
- Transactions — ACID transactions at the shard level with distributed coordination
- Document TTL — automatic document expiration so you don't have to clean up yourself
- PostgreSQL CDC — mirror a Postgres table into Antfly over logical replication, every insert, update, and delete included
- CLI — one
antflybinary for the server, tables, queries, backups, auth, and the model registry (antfly inference pull owner/model) - Secrets — reference credentials as
${secret:...}keystore entries or env vars instead of putting them in config - Object storage — the serverless engine (in progress) keeps artifacts, manifests, WAL, and catalog state in S3-compatible storage (S3, MinIO, R2) or Google Cloud Storage
- CPU, Metal, and CUDA — native kernels for inference and vector search: SIMD on x86 and ARM, Metal on Apple silicon, and CUDA with kernels generated at build time and shipped as fatbins, plus an opt-in runtime kernel JIT for Metal and CUDA (
ANTFLY_INFERENCE_KERNEL_JIT_MODE, off by default) - Distributed — multi-Raft consensus, key-range sharding and replication, online shard splits (automatic size-based split and merge is opt-in), cross-shard transactions, horizontal scaling
- Runs anywhere — Antfly Lite as a single
.aflitefile, a single node with a hot standby, a Raft cluster, or serverless over object storage (in progress) - Embeddable — a C API (
libantfly), embedded bindings for Go, Python, Rust, and TypeScript, and an in-browser WASM build so the engine runs in-process, in unit tests, or on the edge - Extensions — run your own code inside the engine with the Wasmtime extension runtime
- Enrichment pipelines — configurable pipelines per index for embeddings, summaries, graph edges, and custom computed fields
- Bring your own models — Ollama, OpenAI, OpenRouter, Cohere, Bedrock, Gemini, Vertex AI, or run models locally with Antfly inference (GGUF, safetensors, and ONNX)
- Fine-tuning — LoRA, QLoRA, SFT, DPO, GRPO and more with recipes for Gemma 4, GLiNER2, ColQwen2, LayoutLMv3, rerankers, and chunkers
- Auth — built-in user management with API keys, basic auth, and bearer tokens
- Backup & restore — portable backups to local disk, S3, or Google Cloud Storage
- Kubernetes operator — deploy and manage clusters with the operator (docs)
- MCP and A2A protocols — protocol adapters let agents and LLMs use Antfly directly, and an n8n guide wires it into workflows
- Relational tables —
storage_mode: relationaltables with typed packed rows,relationalindexes, row query and mutate APIs, databases, a system catalog, and tablespaces - Antfarm — web dashboard with playgrounds for search, RAG, chat, knowledge graphs, embeddings, reranking, chunking, extraction, OCR, transcription, and evals
- SQL and the Postgres wire protocol — SQL lowered to native typed plans, a
psql-compatible server, and lake tables over Iceberg and Parquet. Tracked in #145
antfly.io/docs, or the source under docs/. Good starting points:
- Quickstart, Document Engine, and Hybrid Search
- Multimodal, Artifact Indexes, and Inference with the supported models
- Documentation index
- Antfly Lite, Architecture, and Object storage
- End-to-end guides: support answer agent, site search and answers, ticket routing, coding copilot retrieval
- Runnable examples: Lite in Go, image search, memoryaf, Pinecone migration, Postgres sync
Prefer not to run it yourself? Antfly Cloud is the hosted option.
| Language | Package | Source |
|---|---|---|
| Go | github.com/antflydb/antfly/go/pkg/sdk |
go/pkg/sdk |
| TypeScript | @antfly/sdk |
ts/packages/sdk |
| Python | antfly-sdk (import antfly) |
py/packages/sdk |
| Rust | antfly-sdk |
rs/crates/sdk |
| React | @antfly/components |
ts/packages/components |
| PostgreSQL | antfly-postgres (SQL: antfly_postgres) |
rs/crates/postgres |
antfly-postgres brings Antfly search into Postgres. The Cargo package is antfly-postgres; the PostgreSQL extension and query-builder schema are antfly_postgres. Enable the extension, create an index, and use the @@@ operator:
CREATE EXTENSION antfly_postgres;
CREATE INDEX idx_content ON docs USING antfly (content)
WITH (url = 'http://localhost:8080/db/v1/', collection = 'my_docs');
SELECT * FROM docs WHERE content @@@ 'fix my computer';@antfly/components gives you drop-in React components for search UIs — QueryBox, Autosuggest, Facet, ActiveFilters, Results, Pagination, AnswerResults, AnswerFeedback, ChatBar, and ChatMessages, plus streaming hooks like useAnswerStream, useChatStream, useCitations, and useSearchHistory.
Antfly inference handles the ML side: embeddings, chunking, reranking, classification, NER, OCR, transcription, generation, and more. The Apache runtime can run in-process or independently as antfly-inference. The full database server also exposes antfly inference commands and includes inference in standalone mode.
| Package | What it does | Source |
|---|---|---|
| docsaf | Ingest content from the filesystem, web crawls and sitemaps, git repos, S3, and Google Drive | go/pkg/docsaf |
| evalaf | LLM/RAG/agent evaluation ("promptfoo for Go") | go/pkg/evalaf |
| Genkit plugin | Firebase Genkit integration for retrieval and docstore | go/pkg/genkit/antfly |
| memoryaf | Shared long-term memory for AI agents over MCP and HTTP | go/pkg/memoryaf |
| embedded | Go, Python, Rust, and TypeScript bindings for local databases and inference over the C ABI | go/pkg/embedded, py/packages/embedded, rs/crates/embedded, ts/packages/embedded |
The distributed database server uses a multi-Raft design with separate consensus groups:
- Metadata raft — table schemas, shard assignments, cluster topology
- Storage rafts — one per shard, handling data, indexes, and queries
The runtime includes our own Raft, LSM, WAL, full-text search, HTTP/2 and HTTP/3, and inference implementations. The repository also maintains a standalone Apache-licensed Zig LMDB-compatible B+tree and a vendored C LMDB oracle for compatibility testing; neither is a production storage backend. Bundled and adapted third-party code retains its original licenses; see THIRD_PARTY_NOTICES.md. Our Snowball fork generates the checked-in stemmer tables. The engine runs under a deterministic VOPR simulation harness that injects storage, network, concurrency, and clock faults, in the style of TigerBeetle.
End-to-end chaos tests — inspired by Jepsen — cover node crashes, leader failures, shard splits under load, and cluster scaling. These tests run real multi-node clusters and inject faults to verify that Raft consensus, transactions, and replication behave correctly under failure.
Critical distributed protocols are formally specified, model-checked, and trace-validated with TLA+ under zig/specs/tla:
- AntflyTransaction — distributed transaction protocol
- occ-2pc — optimistic concurrency control with two-phase commit
- AntflySnapshotTransfer — Raft snapshot transfer
- AntflyShardSplit — shard split coordination
- AntflyLsmLifecycle — LSM ownership handoff under allocation failure
- etcdraft — Raft, trace-validated against the Zig implementation
Join the Discord for support, discussion, and updates.
Interested in contributing? See CONTRIBUTING.md.
The shared embedded engine, Antfly Lite CLI, native libantfly, Zig embedding package, embedded bindings, SDKs, and inference runtime and executable are Apache 2.0.
The standalone database server, database HTTP serving, distributed control, and serverless orchestration are Elastic License 2.0 (ELv2). Third-party components retain their original licenses. See LICENSING.md for the exact scope and THIRD_PARTY_NOTICES.md for upstream notices.
