txtai

9.7.0 · active · verified Wed Mar 25

All-in-one AI framework: embeddings database, semantic search, LLM orchestration, RAG, pipelines and agents. Current version: 9.7.0 (Mar 2026). TWO packages on PyPI: 'txtai' (full local library) and 'txtai.py' (thin API client for remote txtai server). Most tutorials use the full 'txtai' package. Core API: Embeddings class. index() rebuilds entire index. upsert() adds/updates without full rebuild. Content storage must be enabled for SQL queries and content retrieval.

Warnings

Install

Imports

Quickstart

txtai Embeddings with content storage, search, upsert, save/load.

# pip install txtai
from txtai import Embeddings

# Create embeddings with content storage
embeddings = Embeddings(
    path='sentence-transformers/all-MiniLM-L6-v2',
    content=True
)

# Index documents
embeddings.index([
    {'id': 0, 'text': 'Python is a programming language created by Guido'},
    {'id': 1, 'text': 'JavaScript is used for web development'},
    {'id': 2, 'text': 'Rust provides memory safety without garbage collection'},
    {'id': 3, 'text': 'Go is designed for cloud infrastructure'},
])

# Semantic search — returns dicts with text
results = embeddings.search('systems programming language', 2)
for r in results:
    print(r['text'], r['score'])

# Upsert — add without rebuilding
embeddings.upsert([{'id': 4, 'text': 'TypeScript adds types to JavaScript'}])

# Save and load
embeddings.save('/tmp/myindex')
embeddings.load('/tmp/myindex')

view raw JSON →