DEV Community

Cover image for A Cost Checklist for AI Agent API Integrations
Eric Thompson
Eric Thompson

Posted on

A Cost Checklist for AI Agent API Integrations

On a common baseline, standard dense-vector RAG costs about 1.1 cents per query. Hybrid search, reranking and query rewriting cost roughly the same; with per-token reranking, sending fewer chunks makes it about 16% cheaper. The expensive architectures are the ones that call the model more than once or send far more text:

Agentic, multi-step retrieval: about 2.9 cents, 2.6 times the baseline
GraphRAG local search: about 2.0 cents, 1.8 times
Long context with prompt caching: about 1.9 cents, 1.7 times
GraphRAG global search: about 17.7 cents, 16 times
Long context without caching: about 30 cents, 28 times

The rule behind every number is the same: cost per query tracks how many tokens the LLM reads, and how many times it is called. Retrieval infrastructure itself is a rounding error at this scale.

These are illustrative estimates on November 2026 list prices; each calculation is shown below. Whether the extra cost is worth it depends on whether the more complex architecture actually answers your questions better, which only your own evaluation set can tell you.

The seven architectures and the common baseline

All seven answer the same kind of question over the same company knowledge base. They differ in how they find the relevant text and how much of it the model reads.

Dense vector search. Embed the question, find the five most similar chunks, send them to the model. The baseline.
Hybrid search. Combine dense vectors with keyword-style sparse vectors, so exact terms such as product codes and names are matched too.
Retrieve and rerank. Retrieve 20 candidates, re-score them with a reranking model, and send only the best three.
Query rewriting (multi-query). A small model rewrites the question three ways, each version is searched, and the results are merged.
Agentic retrieval. The model decides what to search for, reads the results, searches again if needed, then answers. Modeled here as three steps.
Long context, no retrieval. Send the whole knowledge base with every question. Only possible when the knowledge base fits in the model's context window.
GraphRAG. Build a knowledge graph of entities, relationships and community summaries ahead of time, then answer from the graph. Local search answers questions about specific entities; global search answers broad questions across the whole collection.
The common baseline: a 200 million-token support knowledge base (400,000 chunks, a 2.86 GB index) answered with Claude Sonnet 5.5. For long context, a separate, much smaller 150,000-token knowledge base is used, since a 200 million-token corpus cannot fit in any context window.

Prices used in the comparison

Every architecture is priced with the same list prices, checked in November 2026.

Model prices (sourced)

From Anthropic's pricing page (Anthropic):
Claude Sonnet 5.5: $2 per million input tokens, $10 per million output tokens. Five-minute cache writes $2.50, one-hour cache writes $4, cache reads $0.10 per million. No long-context premium: the 1 million-token context window is billed at standard prices. Batch processing halves input and output prices.
Claude Haiku 5.5: $0.10 input and $0.50 output per million tokens for prompts up to 100,000 tokens. Prompts over 100,000 tokens are billed at five times those rates.

Retrieval prices (sourced, from our RAG infrastructure article)

Embeddings: OpenAI text-embedding-3-small at $0.02 per million tokens
Vector search: Pinecone, 1 read unit per GB of namespace per query, $16 per million read units
Reranking: Cohere at $2.00 per 1,000 searches for Rerank 4 Fast; Rerank 5 reportedly moved to per-token billing in October 2026 at $0.02 per million tokens for Fast. Verify on Cohere's own pricing page.

A note on caching

At $0.10 per million, a cached token costs one-twentieth of an uncached one on Sonnet 5.5. That changes the economics of any architecture that sends the same large block of text repeatedly. The cache only helps if the same prefix is reused before it expires, five minutes or one hour depending on the write option.

Cost per query, architecture by architecture (illustrative)

Generation formula used throughout: input tokens × $2 ÷ 10⁶ + output tokens × $10 ÷ 10⁶.

1. Dense vector search: about $0.0110

Vector read: 2.86 read units × $16 ÷ 10⁶ = $0.00005
Generation: 3,500 input (5 chunks + 1,000 prompt tokens) and 400 output = $0.007 + $0.004 = $0.011
Total: $0.01105

2. Hybrid search: about $0.0110

Sparse values add about 800 bytes per record, growing the index to 3.18 GB: read cost $0.00005
Generation unchanged: $0.011
Total: $0.01105. The cost is the same; the benefit is better matching of exact terms.

3. Retrieve 20, rerank, send 3: $0.0092 to $0.0110

Vector read: $0.00005
Reranking: $0.002 per search at the older per-search price, or about $0.0002 for 10,000 tokens at the reported per-token price
Generation with 3 chunks: 2,500 input and 400 output = $0.005 + $0.004 = $0.009
Total: $0.01105 (per-search reranking) or $0.00925 (per-token reranking)
The reranker pays for itself by cutting two chunks from every prompt.

4. Query rewriting: about $0.0112

Three rewrites by Haiku 5.5: 300 input × $0.10 ÷ 10⁶ + 100 output × $0.50 ÷ 10⁶ = $0.00008
Three vector reads: $0.00014
Generation: $0.011
Total: $0.01122. Using Sonnet for the rewrites instead would add about $0.0016.

5. Agentic retrieval: about $0.0291

Three model steps reading 1,500, 3,500 and 5,500 input tokens (10,500 total) and writing 800 output tokens: $0.021 + $0.008 = $0.029
Two vector reads: $0.0001
Total: $0.02909, 2.6 times the baseline. Each extra step re-reads everything gathered so far.

6. Long context: $0.019 to $0.304

Uncached: 150,050 input tokens and 400 output = $0.3001 + $0.004 = $0.3041
Cached: 150,000 cached tokens × $0.10 ÷ 10⁶ = $0.015, plus the question and output = $0.0191
Each time the cache must be rebuilt, one 150,000-token write at $2.50 per million costs $0.375. With steady traffic this is rare; with sparse traffic it can dominate.

7. GraphRAG: $0.020 to $0.177

Local search: about 8,000 tokens of entities, relationships and source text plus 400 output = $0.016 + $0.004 = $0.020
Global search: 20 map calls over community summaries (50,000 input, 6,000 output in total) = $0.10 + $0.06, plus a reduce call (6,000 in, 500 out) = $0.017. Total: $0.177
GraphRAG query costs depend heavily on configuration. Microsoft notes that parameter and window settings "can significantly affect costs (by many multiples)" (Microsoft, Aug 2024).

Indexing and fixed costs that per-query numbers hide

Per-query cost is only half the picture. Some architectures move cost into indexing, and some carry fixed monthly charges whatever the traffic.
One-time indexing for the 200 million-token baseline (illustrative)
Dense and hybrid: embedding at $0.02 per million tokens with 15% overlap = about $4.60, plus about $11 of initial vector writes (from our RAG infrastructure article). Hybrid adds sparse encoding, usually cheap, and about 11% more storage.
Rerank, query rewriting, agentic: no extra indexing; they reuse the same index.
Long context: no index at all, but only workable for small knowledge bases.
GraphRAG: an LLM reads every chunk to extract entities and relationships, then writes community summaries. Assuming 1,500 input and 500 output tokens per chunk, plus 50% for summarization, indexing 400,000 chunks costs about $2,400 at Sonnet 5.5 batch prices, or about $120 at Haiku 5.5 batch prices. Microsoft describes graph building as the step that drives most of GraphRAG's cost.

Re-indexing

Content changes. Dense and hybrid indexes update one chunk at a time for pennies. A knowledge graph may need entity resolution and community summaries rebuilt when documents change, so its re-indexing cost scales with how often your content moves.

Fixed monthly costs

Vector database minimum: for example, Pinecone's $50 a month, which covers the read cost of everything up to about 1 million baseline queries
Long-context cache upkeep: at low traffic, the cache expires between questions and each rebuild costs 0.375fora150,000-tokenprompt.Aone-hourcachewrite(4 per million) costs $0.60 but survives quieter periods.
Engineering: agentic retrieval and GraphRAG are more complex to build, debug and evaluate. That cost often exceeds the per-query difference at moderate volumes.

Monthly cost at three traffic levels (illustrative)

At 10,000 queries a month, the choice of architecture moves the bill by a few hundred dollars; at 1 million, by hundreds of thousands. These figures are per-query costs multiplied out, excluding fixed charges and indexing.

10,000 queries a month

Dense, hybrid or per-search rerank: about $110
Rerank with per-token pricing: $92
Query rewriting: $112
Long context, cached: $191
GraphRAG local: $200
Agentic: $291
GraphRAG global: $1,770
Long context, uncached: $3,041

100,000 queries a month

Dense, hybrid or per-search rerank: about $1,105
Rerank with per-token pricing: $925
Query rewriting: $1,122
Long context, cached: $1,910
GraphRAG local: $2,000
Agentic: $2,909
GraphRAG global: $17,700
Long context, uncached: $30,410

1 million queries a month

Dense, hybrid or per-search rerank: about $11,050
Rerank with per-token pricing: $9,246
Query rewriting: $11,217
Long context, cached: $19,100
GraphRAG local: $20,000
Agentic: $29,092
GraphRAG global: $177,000
Long context, uncached: $304,100

Mixing architectures

Most production systems route queries rather than pick one design. If 90% of questions are simple and use reranked retrieval, and 10% are complex and use agentic retrieval, the blended cost at per-token reranking prices is 0.9 × $0.00925 + 0.1 × $0.0291 = about $0.0112 per query, close to the baseline, while hard questions still get the stronger method.
Choosing an architecture: cost, quality and latency together
Start with the cheapest architecture that passes your evaluation set, and add complexity only where it fixes measured failures.

When each one earns its cost

Dense vector search: a good default for questions phrased like the documents themselves.
Hybrid search: when users search for exact identifiers, names, codes or jargon that embeddings blur together. Almost no extra cost.

Reranking: when the right chunk is usually in the top 20 but not the top 5. It often lowers total cost by letting you send fewer chunks.

Query rewriting: when users ask short, vague or oddly worded questions. Cheap if a small model does the rewriting.
Agentic retrieval: when answers need facts from several places combined, or follow-up searches based on what was found. Worth it for a minority of questions, not all.
Long context with caching: when the whole knowledge base is small (well under the context window), changes rarely and traffic is steady enough to keep the cache warm. Simple to build, no index to maintain.
GraphRAG local search: when questions are about relationships between specific entities, such as which suppliers are linked to which products.
GraphRAG global search: when users need summaries across an entire collection ("what are the main themes in these reports?"). Too costly for routine questions; consider it for a small, high-value share of traffic.

Latency matters too

Each extra model call adds seconds. Agentic retrieval and GraphRAG global search are slower as well as costlier, so they suit research-style tasks better than live chat. Microsoft reported both GraphRAG search modes taking about 20–24 seconds in its example.

Let evaluation decide

Run the same evaluation set (see our evaluation pipeline article) against two or three candidate architectures. Compare accuracy, cost per query and latency together. A design that is twice as expensive should be measurably better on the questions that matter.

Where CodingCops fits

CodingCops is a Chicago-headquartered software company founded in 2010 (Built In Chicago). Its company profile lists AI and machine learning, cloud and DevOps, custom software development, and dedicated engineering teams among its services (Outsource Accelerator), and it offers engagements for specific projects, short-term initiatives or long-term development (codingcops.com).
Comparing retrieval architectures on your own data is engineering and evaluation work that an external team can carry out. Whoever does it, ask for cost per query, accuracy and latency measured side by side on your evaluation set, not a recommendation based on what the vendor usually builds.

FAQs

What does a RAG query cost?

On our baseline, about 1.1 cents for standard dense-vector RAG with Claude Sonnet 5.5, almost all of it generation. Hybrid search, reranking and query rewriting stay close to that; agentic retrieval and GraphRAG cost more.

Does reranking add cost?

It can lower it. Reranking 20 results and sending 3 instead of 5 saves more on generation than the reranker costs, especially with per-token reranker pricing.

Is GraphRAG more expensive than vector RAG?

Yes, in both indexing and querying. Indexing our 200 million-token baseline costs about $120 to $2,400 depending on the model, versus about $5 to embed for vector search. Local search queries cost about 1.8 times the baseline; global search about 16 times.

Can I skip RAG and put everything in the context window?

Only for small knowledge bases. With prompt caching, a 150,000-token knowledge base costs about 1.9 cents per question at steady traffic; without caching, about 30 cents.

Why is agentic retrieval so much more expensive?

Each step calls the model again and re-reads everything gathered so far. Three steps cost about 2.6 times a single-pass query in our model.

How should I choose?

Start with the cheapest design that passes your evaluation set. Add hybrid search or reranking first, since they cost little, and route only hard questions to agentic or graph-based retrieval.

Top comments (0)