All Insights
By Roshan Desai
There are two ways an AI system can get enterprise context: read through the sources at query time, or query an index that was built ahead of time. The first approach pushes every document an agent touches through the LLM's context window, on every task, at full token price. The second pays for document understanding once, at indexing time, and answers every subsequent query with a retrieval call that costs a few thousand tokens instead of a few hundred thousand.
This is the difference between an agent that opens Confluence, pages through Slack, and reads ten documents to find one paragraph, and an agent that asks a RAG engine and gets the paragraph back. A June 2026 study measured the gap at 26x per-query token cost for document-grounded question answering, and for multi-step agentic workflows the gap compounds with every step. This guide explains how Onyx's RAG engine is architected around that difference: what the indexing pipeline does to each source, how the retrieval pipeline is designed for cheap and precise context, and how Onyx Craft agents tap the same engine mid-workflow instead of combing through sources themselves.
TL;DR: Reading sources through an LLM is the most expensive way to use them. Onyx indexes content from 40+ sources once, condenses it into a hybrid vector index (OpenSearch, dense embeddings + BM25), and serves any question from a few thousand tokens of ranked, permission-filtered passages. Retrieval itself costs zero LLM tokens. The same engine backs chat, search, deep research, and Craft agents: instead of manually combing through Slack, Drive, and Confluence with tool calls, a Craft agent invokes the company-search skill and gets grounded enterprise context in one cheap call. With per-token prices roughly flat in 2026 and inference consuming ~85% of enterprise AI budgets, this architecture is the difference between AI spend that scales with query volume and AI spend that explodes with it.
Pricing and market data verified against primary sources as of July 2026.
For two years the advice was "don't optimize token costs, prices fall faster than you can engineer around them." That advice is out of date. Effective API token pricing declined only 6% in the first five months of 2026, enterprises keep routing spend to premium frontier models, and providers now charge explicit long-context premiums: Gemini 3.1 Pro doubles input pricing above 200K tokens, and GPT-5.5 jumps from $5 / $30 to $10 / $45 per million in the long-context band.
Meanwhile usage is exploding. Agentic workflows trigger 10-20 LLM calls per task, and inference now accounts for roughly 85% of enterprise AI budgets. Every one of those calls carries context, and where that context comes from is the architecture decision that sets your bill. You cannot negotiate your way out of it. You have to send fewer tokens, and that means retrieving context instead of reading for it.
Consider what "the agent finds the answer itself" actually costs. An agent asked to summarize the current state of a customer account, without a RAG engine, has to behave like a very fast, very expensive intern:
Every document read is billed at full input-token price, the reads repeat on every task (nothing is remembered between queries), and each additional source multiplies the calls. Research on context relevance shows why this is structurally wasteful: when less than roughly 20% of provided context is relevant to the question, selective retrieval beats reading everything on both cost and reliability, and enterprise sources are almost always far below 20% relevance for any single question. Worse, more context actively degrades answers past a point: 48K well-chosen tokens outperform 117K tokens of full context by 13 F1 points, because relevant passages get diluted.
The manual-combing pattern pays the highest possible price for the lowest possible precision. The fix is to move the reading out of query time entirely.
Onyx is an open-source (MIT-licensed) enterprise AI platform built around a RAG engine. 40+ connectors sync content from Slack, Confluence, Google Drive, SharePoint, Jira, GitHub, Salesforce, Zendesk, Gmail, and more into a hybrid OpenSearch index, kept current in near real time along with each document's metadata and access permissions. On top of that engine, Onyx serves permission-aware search, AI chat, multi-step deep research, and agents, with any LLM (OpenAI, Anthropic, Google, DeepSeek, Llama, Mistral, Qwen) via cloud APIs or local inference through Ollama, vLLM, or LM Studio.
It runs in production at Ramp (115K queries per month), Thales (82,000-employee organization), and UC San Diego (37K+ users, fully air-gapped), among 1,000+ enterprise customers. Everything below describes the pipeline those queries flow through.
Onyx's answer to the combing problem starts before any question is asked. Each connector understands its source natively: a Slack connector pulls threads with their reply structure, a Confluence connector pulls pages with their hierarchy and labels, a Drive connector pulls documents with their sharing settings. From there, every piece of content flows through the same pipeline:
The economics of this pipeline are the whole point:
The result is your entire knowledge footprint, condensed into a form where finding the right 5K tokens is a database operation, not an LLM operation.
At query time, Onyx's retrieval pipeline is designed to hand the LLM the smallest context that answers the question:
Everything above happens in OpenSearch and a reranker. No generation-model tokens are spent finding context. The LLM receives a few thousand tokens of ranked, cited, permission-filtered passages and does the one thing only an LLM can do: compose the answer.
Precision here is itself a token optimization. When the right passage is in context on the first attempt, users do not re-ask the question three ways and agents do not loop. Onyx's published benchmarks show a 64-76% win rate on workplace-question quality versus ChatGPT, Claude, and Notion AI on a 220K-document corpus, and Thales saw the retrieval difference directly when comparing platforms on the same model: "The result given is better, even when they use the same underlying model."
Illustrative per-task economics at mid-2026 frontier pricing ($5 per million input tokens standard band):
| Cost driver | Agent combing through sources | One call to the Onyx RAG engine |
|---|---|---|
| Finding candidate content | LLM tool calls to list, search, and skim sources | OpenSearch hybrid query, zero LLM tokens |
| Reading content | 50K-200K+ tokens of full documents per task | 3K-8K tokens of ranked chunks |
| Relevance of tokens sent | Often under 5% relevant | Ranked and reranked for the question |
| Repeat cost | Full re-read on every task | Index amortized across all queries |
| Permissions | Enforced per-tool, if at all | Enforced at retrieval, before generation |
| Input cost per task | $0.25-$1.00+ | $0.02-$0.04 |
| Monthly input cost @ 100K tasks | $25K-$100K+ | $2K-$4K |
Numbers are illustrative and depend on corpus, model, and task mix. The 26x per-query gap measured in controlled research sits inside this range, and multi-step agent workflows multiply it by the number of steps that need context.
The retrieval-vs-combing distinction matters most for agents, because agents need context repeatedly, mid-task, across many steps. This is where most agent platforms quietly burn budgets: each "look something up" step becomes a fresh round of tool calls and document reads.
Craft, Onyx's agent workspace, is designed the other way. Craft agents run in a secure sandbox where they write code, build documents and web apps, and act in connected tools. When a Craft agent needs enterprise context, it does not open Slack and start reading. It invokes the built-in company-search skill, which gives the agent a CLI into Onyx's RAG engine from inside the sandbox. The call goes through scoped Craft APIs that enforce the signed-in user's document permissions, and what comes back is the same ranked, cited, few-thousand-token context that powers chat and search.
That one design choice changes the cost profile of complex agentic workflows:
The contrast with generic agent stacks is direct. An agent wired to raw MCP tools for Slack, Drive, and Confluence must comb: list, open, read, repeat, paying token price for every page it touches. A Craft agent asks a question and gets an answer, because someone already did the reading, once, at index time.
| Situation | Recommended setup | Why |
|---|---|---|
| Small team (<50 users) | Onyx Cloud with a mid-tier model default | Retrieval keeps even frontier-model usage cheap; no infrastructure to run |
| Mid-market (50-500) | Onyx Cloud or self-hosted, mixed model routing (cheap default, frontier for deep research) | After retrieval, model routing is where the next 2-5x of savings lives |
| Enterprise (500+) | Self-hosted Onyx, local embedding models, BYO LLM contracts | ~80% of Onyx enterprise revenue is self-hosted; embedding and high-volume workloads move off API billing |
| Regulated / air-gapped | Fully air-gapped Onyx with local LLMs (vLLM/Ollama) on your GPUs | Zero API token spend; UC San Diego runs this pattern for 37K+ users |
| Higher education | Self-hosted with local models, special education pricing | Cost control at large user counts plus FERPA-compatible data governance |
A RAG engine is the right cost architecture when your AI workload is grounded in a large, changing corpus where any single question needs a small fraction of it, when query or agent-task volume is high enough that per-task costs dominate, and when permissions must be enforced on what AI can retrieve. That describes nearly every enterprise deployment.
Reading full sources at query time is still the right tool in narrow cases: analyzing one contract end to end, reviewing a fixed bundle of files where every part matters. The research is consistent that full context buys some accuracy when relevance density is high. The mistake is letting that pattern become the default for enterprise questions where relevance density is a fraction of a percent, and paying long-context premium rates for it on every task.
Building the pipeline yourself is the option to be most skeptical of: production connectors, permission syncing, chunking, embedding, hybrid retrieval, and reranking are each real engineering projects, and every month of build time is a month of paying combing-model token bills in the interim.
If your AI bill is growing faster than your usage justifies, look at where context comes from. Systems that read sources at query time re-buy the same understanding on every task; systems built on a RAG engine buy it once. Onyx is the strongest fit when you want that engine with control over the rest of the cost structure: open-source (MIT) so you can audit the pipeline, model-agnostic so each query runs on an appropriately priced model, self-hostable so embedding and high-volume inference move off API billing, and one shared index behind search, chat, deep research, and Craft agents so nothing pays twice. Teams with tiny corpuses and low query volumes may not need the machinery; the economics diverge as volume grows.
Retrieval replaces reading. Finding relevant content happens in the search index (OpenSearch hybrid search plus a reranker) at zero LLM token cost, and only 3K-8K tokens of ranked passages reach the model, versus 50K-200K+ tokens when an agent opens and reads documents itself. Controlled research measured semantic RAG at roughly 1/26th the per-query token cost of long-context prompting, and multi-step agent workflows multiply the gap.
Connectors pull content from each source with its native structure, then the pipeline extracts text and metadata, chunks documents into retrieval-sized passages, enriches chunks with surrounding context, and embeds them into a hybrid OpenSearch index (dense vectors + BM25) along with permissions synced from the source. This runs once per document version, with incremental near-real-time sync afterward.
No. Indexing uses embedding models, which cost a small fraction of generation-model tokens, and the cost is paid once per document version rather than per query. Self-hosted Onyx deployments run embedding models locally at zero marginal API cost.
Through the built-in company-search skill, which gives the sandboxed agent a CLI into Onyx's search APIs. The agent makes a cheap retrieval call and receives ranked, cited, permission-filtered context, instead of combing through Slack, Drive, or Confluence with per-document tool calls. The APIs enforce the signed-in user's document permissions, so agents can only retrieve what that user can read.
No. Long context helps when everything in the prompt is relevant. Enterprise questions typically use under 1% of the corpus, where retrieval wins on cost, latency, and accuracy, and providers charge premium rates above 200K tokens (Gemini and GPT-5.5 both roughly double pricing in the long-context band). Research also shows well-chosen retrieved context outperforming much larger full contexts because irrelevant tokens dilute relevant ones.
Yes. Onyx supports local inference through Ollama, vLLM, and LM Studio for both embeddings and generation, alongside 100+ cloud LLMs. Fully air-gapped deployments run everything on your own hardware; UC San Diego serves 37,000+ users this way.
No. Caching discounts repeated identical context, which helps stable system prompts. Enterprise queries hit different documents per user and per question, and content changes continuously, so caches rarely hit. Retrieval reduces the tokens you send; caching discounts tokens you re-send. Use both.
Related Insights
Self-Hosted RAG in 2026: The Complete Guide to Running Retrieval-Augmented Generation On Your Own Infrastructure
How to deploy retrieval-augmented generation on your own infrastructure. Compare self-hosted RAG platforms (Onyx, Open WebUI, LibreChat, AnythingLLM, RAGFlow, Verba) and frameworks (LlamaIndex, LangChain, Haystack), with recommended stacks for small, mid-market, and air-gapped enterprise deployments.
Best Enterprise RAG Platforms for 2026: A Buyer's Guide
Compare 11 enterprise RAG platforms across architecture, connectors, deployment, security, and pricing. Includes turnkey, cloud, and open-source options with current 2026 pricing and analyst data.
Best Enterprise Search Platforms for Engineering Teams (2026)
Compare the 8 best enterprise search platforms for engineering teams in 2026. Find answers across docs, tickets, chat, PRs, and issues. Pricing, self-hosting, APIs, MCP, and what each is built for.