CortexDB · docs

CortexDB best practices: ingestion, embeddings, local vs API models

A practical guide for teams putting CortexDB into production. It covers what to send and how, which embedding model to run, which parts can run inside your network, and how to keep a deployment current. Every setting named here is in Production Deployment and the API Reference.


1. Ingestion

What CortexDB does with a write

Every event you send is stored exactly as sent, in an append-only history, and made searchable (by meaning and by keywords) without any schema on your side. Nothing you send is silently dropped: the original is the record, and every summary, fact or graph is a view rebuilt from it. When enrichment is on (CORTEX_ENRICHMENT_URL, CORTEX_ENRICHMENT_MODEL, CORTEX_ENRICHMENT_DELAY_SECONDS), a model reads each event in the background and extracts facts, entities and beliefs. With enrichment off, events are still stored and searchable; nothing is extracted.

CortexDB decides what to learn from an event, never whether to keep it. Deciding what to keep is your filter (below).

Filter before you send

SendHow
Conversations, tickets, decisions, outcomesnormally (modality: "conversation", "observation", ...)
Tool results, logs, reference documentsas search-only: "directives": {"extract": []}. They stay findable but never become facts about a person
Health checks, retries, empty or duplicate responses, huge raw dumps nobody will ask aboutdon't send them
Anything containing passwords, tokens or keysdon't send it; PII scanning flags personal data, it does not remove secrets

Sending everything works, but every event costs an embedding call (and an extraction call when enrichment is on) and adds noise to recall.

Shape each write well

Volume and backfills

Documents

Upload the file with POST /v1/blobs (raw bytes, the file's own Content-Type) and reference it as blob_ref content. What reads it is CORTEX_DOCUMENT_PROVIDER:

ProviderReadsRuns
nativeplain text, Markdown, CSV, HTML, JSON, XMLinside CortexDB
tika (recommended on-prem)PDF, Word, PowerPoint, Excel and morean Apache Tika server you run next to CortexDB: CORTEX_DOCUMENT_API_URL=http://tika:9998
unstructuredcomplex layouts, tables, formsthe Unstructured API, hosted or self-hosted: CORTEX_DOCUMENT_API_URL, CORTEX_DOCUMENT_API_KEY

Scanned PDFs (pictures of pages) need OCR: use a Tika image that includes Tesseract. Store reference documents search-only ("extract": []) unless you want facts extracted from them.

Keeping memory tidy

2. Embeddings

Embeddings turn text into numbers so CortexDB can find things by meaning, not only by exact words.

Pick one before you load real data

A data directory is pinned to the embedding provider, model and width it started with. Changing any of them later is a planned rebuild (Embedding Migration Runbook): while it runs, recall uses keywords only. Choose deliberately, then keep the setting.

Keep the key set. The Docker image refuses to start without its embedding key, and a data directory refuses a different provider than the one it is pinned to. A bare binary started with no embedding endpoint or key falls back to test vectors with a warning: never load real data that way.

Options

ProviderSettingsGood for
OpenAI (default)CORTEX_EMBEDDING_API_KEY or OPENAI_API_KEY; model text-embedding-3-small, 1536 dimsbest quality for the effort, cheap, nothing to run
Any OpenAI-compatible endpoint (Azure OpenAI, OpenRouter, LiteLLM, vLLM, TEI)CORTEX_EMBEDDING_URL, CORTEX_EMBEDDING_MODEL, CORTEX_EMBEDDING_DIMS, CORTEX_EMBEDDING_API_KEYkeeping data in your own cloud account; test a write and a recall before loading data
CohereCORTEX_EMBEDDING_PROVIDER=cohere, COHERE_API_KEYteams already on Cohere
Ollama (local)CORTEX_EMBEDDING_PROVIDER=ollama, CORTEX_EMBEDDING_URL=http://ollama:11434, CORTEX_EMBEDDING_MODEL (for example nomic-embed-text), CORTEX_EMBEDDING_DIMS matching the modeldata that must never leave your network

CORTEX_EMBEDDING_DIMS must equal the model's output width (768 for nomic-embed-text, 1024 for mxbai-embed-large), and a data directory built at one width refuses to start at another.

Local or API?

3. What can run inside your network

PartHosted APIInside your network
Storage, indexes, search—always (CortexDB itself)
EmbeddingsOpenAI, Azure OpenAI, CohereOllama, or any OpenAI-compatible server
Enrichment (fact extraction), optionalOpenAI, Anthropic, Google, Bedrock via a proxyOllama or an OpenAI-compatible server (CORTEX_ENRICHMENT_URL)
Answers (/v1/answer), optionalAnthropic (default), OpenAI, Google, BedrockOllama (CORTEX_ANSWER_PROVIDER=ollama)
Reranking, optionalCoherea local ONNX cross-encoder (CORTEX_RERANKER_MODEL_PATH) or a Cohere-shaped server you host (CORTEX_RERANKER_URL)
DocumentsUnstructured APIApache Tika, or self-hosted Unstructured

A fully air-gapped install runs every row on the right. Recall (/v1/recall) needs only embeddings; enrichment, answers and reranking are optional.

4. Reusing answers

For repeated questions, turn on the answer cache with CORTEX_ANSWER_CACHE=1. A repeated question from the same caller, in the same scope and with the same options, is answered from the stored response instead of running recall and the model again. The cache never serves an answer that may be out of date:

The x-cortex-answer-cache response header says hit, miss or bypass. Send Cache-Control: no-cache to force a fresh answer (it then replaces the stored one), or no-store to keep a request out of the cache. Streaming requests are always answered fresh. The cache is in memory on each server and is never written to disk or replicated: a restart empties it. On a cluster each data node keeps its own (set CORTEX_ANSWER_CACHE in the node's [engine] table), only a shard's leader answers, and after a leader change the new leader starts with an empty cache. The cluster ingress passes Cache-Control through to the data node. Details: API Reference §8.4.1.

5. Staying current

6. Launch checklist