Prompt

What's the most cost-effective way to do document retrieval using an embedding API?

Latest observation

Jul 19, 2026 · OpenAI APIWeb search: off

The most cost-effective approach is usually:

1) Chunk documents once, embed offline, and store vectors

  • Split documents into sensible chunks.
  • Generate embeddings once for each chunk with a cheaper embedding model.
  • Store the vectors in a vector database or even flat files + ANN index.

This avoids re-embedding on every query, which is where most cost can accumulate.

2) Use a small, cheap embedding model

For most retrieval use cases, a smaller embedding model is enough. Pick the lowest-cost model that still gives acceptable retrieval quality for your corpus.

Cost savings come from:

  • lower per-token embedding price
  • faster processing
  • smaller vector storage footprint

3) Keep chunk sizes moderate

Very small chunks increase embedding count and storage. Very large chunks reduce retrieval quality.

A cost-effective balance is often:

  • ~200–500 tokens per chunk
  • some overlap if needed, but not too much

Overlap improves recall, but too much overlap multiplies cost.

4) Embed only what matters

Reduce cost before embedding:

  • strip boilerplate
  • remove duplicated sections
  • exclude images/footers/nav text if irrelevant
  • deduplicate near-identical documents

5) Use two-stage retrieval

A cheap and effective pattern:

  1. Retrieve top 20–100 chunks with embeddings
  2. Re-rank the short list with a more precise method or LLM only if needed

This keeps expensive downstream processing limited to a small candidate set.

6) Cache aggressively

If users ask repeated or similar questions:

  • cache query embeddings
  • cache retrieval results
  • cache document chunk embeddings permanently unless content changes

7) Choose the right search architecture

If your corpus is small, you may not need a sophisticated vector database.

  • Small corpus: in-memory vector search or SQLite + ANN can be enough
  • Large corpus: use a vector DB or ANN index like FAISS, HNSW, etc.

The cheapest system is the simplest one that meets latency and scale needs.

8) Consider hybrid retrieval

Combine:

  • lexical search (BM25)
  • embedding search

This can improve recall, letting you use fewer embedding hits and less expensive reranking.

Practical recommendation

For most teams, the most cost-effective setup is:

  • preprocess and deduplicate documents
  • chunk into ~300 tokens
  • embed once with a low-cost embedding model
  • store in FAISS/HNSW/vector DB
  • use top-k retrieval
  • rerank only the top few results if necessary
  • cache everything possible

If you want, I can also give you:

  1. a reference architecture,
  2. a cost breakdown formula, or
  3. a concrete implementation example in Python.

Observation history

Unlock observation history

Create a free Obsurfable account to unlock historical responses, model comparisons, and deeper brand intelligence.

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, and Meta AI.