Registry / ai-ml / txtai
library9.12.0pypypi✓ verified 26d ago

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.

pip install txtai
INSTALL
IMPORT
SIG · TXTAI
T
txtai
ai-mlpythonv9.12.0
Install
Import
Disk
Pass rate
0/ 10
Env Coverage0 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v9.12.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
1/4 runs
1/4 runs
py 3.11
1/4 runs
1/4 runs
py 3.12
1/4 runs
2/4 runs
py 3.13
1/4 runs
3/4 runs
py 3.9
1/4 runs
1/4 runs
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Embeddings (basic semantic search)
from txtai import Embeddings # Default model (all-MiniLM-L6-v2) embeddings = Embeddings() # Or specify model explicitly embeddings = Embeddings(path='sentence-transformers/all-MiniLM-L6-v2') # index() — builds NEW index, overwrites existing embeddings.index(['Correct answer', 'Wrong answer', 'Maybe']) # search returns list of (id, score) tuples results = embeddings.search('positive', 1) print(results) # [(0, 0.298)] — id=0 is 'Correct answer'
from txtai import Embeddings embeddings = Embeddings() embeddings.index(['doc 1', 'doc 2']) # Wrong: index() again REPLACES the entire index embeddings.index(['doc 3']) # doc 1 and doc 2 are now gone # Wrong: expecting text back from search without content storage text = embeddings.search('query', 1)[0][0] # returns id (int), not text
index() rebuilds the entire index from scratch — calling it again wipes previous data. Use upsert() to add/update without full rebuild. search() returns (id, score) tuples by default, not text.
Embeddings with content storage
from txtai import Embeddings # Enable content storage to retrieve text from search results embeddings = Embeddings(content=True) # Index with dict documents embeddings.index([ {'id': 0, 'text': 'Python is a programming language'}, {'id': 1, 'text': 'JavaScript runs in browsers'}, {'id': 2, 'text': 'Rust is fast and safe'}, ]) # Now search returns dicts with text results = embeddings.search('compiled language', 1) print(results[0]['text']) # 'Rust is fast and safe' # Can also use SQL results = embeddings.search( "SELECT text, score FROM txtai WHERE similar('web language') LIMIT 1" )
# Without content=True, search only returns (id, score) embeddings = Embeddings() embeddings.index(['text 1', 'text 2']) results = embeddings.search('query', 1) print(results[0]['text']) # KeyError — no text in result
Without content=True, search returns (id, score) tuples only. Enable content=True to store and retrieve document text. SQL queries also require content=True.

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')
txtai --version
Debug
Known issues
breakingTwo packages on PyPI: 'txtai' (full library) and 'txtai.py' (thin API client). They have different APIs. 'pip install txtai.py' installs a client that connects to a remote txtai server — not the local library.
fix
For local use: pip install txtai. For connecting to a remote txtai API server: pip install txtai.py
affects: all
breakingindex() replaces the entire index. Calling it twice means the first index is gone. LLMs commonly generate code that calls index() multiple times to 'add' documents.
fix
Use upsert() to add/update documents without full rebuild. Use index() only for initial load or full re-index.
affects: all
breakingsearch() returns (id, score) tuples by default — not document text. Accessing result['text'] raises KeyError without content=True enabled.
fix
Enable Embeddings(content=True) to store and retrieve text from search results.
affects: all
gotchaSQL queries and content retrieval require content=True at index creation time. Cannot be enabled after index is built without re-indexing.
fix
Always set content=True if you need SQL queries, text retrieval, or metadata filtering.
affects: all
gotchaBase 'pip install txtai' has minimal deps. Most useful features (pipelines, LLM, API server) require extras: txtai[pipeline-text], txtai[api], txtai[all].
fix
For RAG/LLM workflows: pip install txtai[all]. For just semantic search: pip install txtai[similarity].
affects: all
gotchaDefault model downloads from Hugging Face Hub on first use — requires internet access and ~100MB download. Fails in air-gapped environments.
fix
Pre-download model: embeddings = Embeddings(path='/local/model/path'). Or set HF_HUB_OFFLINE=1 with a cached model.
affects: all
gotchaAgents (added in v8) are built on smolagents framework — requires pip install txtai[agent]. Earlier versions used transformers agents which had different API.
fix
pip install txtai[agent] for agent support.
affects: >= 8.0
breakingInstallation of txtai (and its dependencies that require compilation, such as scikit-learn, hnswlib, annoy, fasttext) may fail in minimal environments (e.g., Alpine Linux) due to missing build tools. These packages often require a C/C++ compiler to build native extensions.
fix
Install necessary build tools in the environment before attempting to install txtai. For Alpine Linux, this typically involves `apk add build-base python3-dev`.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'txtai'
The `txtai` library has not been installed in the current Python environment or the environment is not active.
fix
pip install txtai
ValueError: content must be enabled to save content
The `Embeddings` index was initialized without enabling content storage, preventing content retrieval or SQL queries.
fix
Initialize `Embeddings` with `content=True`, e.g., `Embeddings(config={'content': True})`.
OSError: Can't load tokenizer for 'sentence-transformers/all-MiniLM-L6-v2'. If you were trying to load it from 'https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2', make sure you don't have a local directory with the same name.
The specified `sentence-transformers` model cannot be loaded, possibly due to a network issue, a typo in the model name, insufficient disk space, or a corrupted local cache.
fix
Verify the model name and internet connectivity, ensure sufficient disk space, or clear the Hugging Face cache (usually `~/.cache/huggingface/hub`) if a corrupted download is suspected.
AttributeError: 'txtai.embeddings.Embeddings' object has no attribute 'add'
The `Embeddings` object in `txtai` does not have an `add` method; data is added using `index` or `upsert`.
fix
Use `embeddings.index(data)` to rebuild the index or `embeddings.upsert(data)` to add/update existing data.
TypeError: 'str' object is not iterable
The `embeddings.index()` or `embeddings.upsert()` method expects the `data` argument to be a list of items, but a single string (or other non-iterable object) was provided.
fix
Wrap the input data in a list, even if it's a single item, e.g., `embeddings.index(["text_item"])` or `embeddings.upsert([("id1", "text_item", None)])`.
Upgrade
Version history
9.12.0latest on PyPI · released Jul 30, 2026
Audit
Dependencies
torchoptionalRequired for local model inference. Not installed by default — install separately or via txtai[model].
sentence-transformersoptionalRequired for sentence embedding models. Install via txtai[similarity].
faiss-cpurequiredDefault ANN backend. Installed automatically with txtai.
Agent activity
84 hits · last 30 days
node
72
OpenAI (training)
1
Resources
txtai — pip install txtai · libregistry