Monitoring Token, Embedding and Vector Storage Costs
This lesson explains how to monitor AI-specific cost drivers that traditional ML does not have: tokens per request, embedding computation and vector database storage.
Learning outcomes
After completing this lesson, you will be able to:
- Track token usage patterns by application and tenant.
- Control embedding computation costs.
- Reduce vector storage cost.
Token usage patterns
Track InputTokenCount and OutputTokenCount per model and, through application inference profiles or logged metadata, per application, feature and tenant. Watch tokens per request over time: steady growth usually means prompts, retrieved context or conversation history are growing. Compare cost per successful outcome (for example, per resolved ticket), not only per request.
Token patterns
Embedding computation
Embedding models charge per input token, so embedding costs depend on how much text is embedded. Costs spike when whole corpora are re-embedded, which happens after changing the embedding model or chunking strategy, or when pipelines re-ingest documents that have not changed.
Incremental knowledge base syncs process only changed documents. Custom pipelines can hash documents and skip unchanged ones. Caching the embeddings of repeated queries avoids re-embedding them, and batch inference reduces the cost of large backfills.
The following diagram compares the figures of a custom RAG pipeline before and after three changes to embedding and hosting.

Embedding costs
Vector storage
Vector store cost grows with the number of vectors, their dimensions, index overhead and replicas. OpenSearch Serverless is billed in OpenSearch Compute Units for indexing and search plus storage; managed domains by instance and storage. Reduce cost with fewer dimensions (for example, 512 instead of 1,024 with Titan Text Embeddings V2), byte or binary quantisation, larger chunks where quality allows, deleting stale vectors, and Amazon S3 Vectors for large, infrequently queried collections. The following table summarises the cost patterns.
| Cost driver | Monitor | Optimize |
|---|---|---|
| Tokens per request | Token count metrics per application | Prompt trimming, caching, routing |
| Embedding computation | Embedding token usage, ingestion job sizes | Incremental sync, skip unchanged, batch |
| Vector storage and compute | Index size, OCUs or instance usage | Fewer dimensions, quantisation, S3 Vectors, clean-up |
| Replicas and shards | Query rate vs. capacity | Right-size replicas to query load |
A nightly re-ingestion
A custom RAG pipeline re-embeds all 3 million chunks every night, and its OpenSearch domain stores 1,536-dimension vectors with two replicas, although query volume is low.
- Hash each document and re-embed only new or changed ones: nightly embedding volume falls by about 98%.
- Re-embed once with Titan Text Embeddings V2 at 512 dimensions after evaluation shows recall is maintained.
- Reduce to one replica to match the low query rate.
Embedding cost and vector storage both fall sharply. Monitoring embedding token usage would have revealed the wasteful nightly re-ingestion months earlier.
How can re-embedding unchanged documents be avoided?
Show answer
With incremental sync, or by hashing content to detect changes.
Exam Tips
Remember for the exam
- Track tokens per request per application to spot prompt growth.
- Avoid re-embedding unchanged documents: incremental sync or hashing.
- Fewer dimensions and quantisation reduce vector storage cost.
- Large, rarely queried vector sets: S3 Vectors.
- Match replicas to query load.