Sending your entire codebase to GPT-4 on every request is bleeding your budget. FlowSquad vectorises your code once and answers from embeddings — 85% fewer tokens per query.
The problem starts with a well-intentioned shortcut. When developers first integrate an LLM into their workflow — asking it to explain code, generate tests, or answer architecture questions — the simplest implementation sends as much context as possible. If the question is about a payment module, send the whole payments folder. If it's about an API, send the entire API layer. If you're not sure what's relevant, send everything.
This approach — sometimes called "prompt stuffing" or naive context injection — produces decent results but at catastrophic token costs. Here's the math:
Obviously most teams don't send the entire codebase, but even sending a relevant subsystem — say, 150,000 tokens — at 500 queries/day produces a monthly bill of approximately $22,500. This is how teams end up with $12,000–$30,000/month LLM bills within weeks of enabling AI features.
Vector search is the production-grade solution to context management. Instead of deciding "what code is relevant to this question?" at query time by sending everything, you pre-index your codebase into a vector database, then retrieve only the semantically relevant chunks when a query arrives.
The process works in two phases:
text-embedding-3-small or a local Ollama embedding model)The quality of answers is equal to or better than naive injection for most queries, because the irrelevant context in naive approaches actually degrades LLM focus. A model given exactly what it needs performs better than one buried in noise.
FlowSquad's VectorDB integration supports two backends: ChromaDB for on-premise and air-gapped deployments, and Pinecone for cloud deployments that benefit from managed vector infrastructure.
# FlowSquad vectordb configuration (config.yaml)
vectordb:
provider: chromadb # or "pinecone"
chromadb:
host: localhost
port: 8000
collection_prefix: "flowsquad_"
embedding_model: "all-MiniLM-L6-v2" # local model, zero egress cost
pinecone:
api_key: "${PINECONE_API_KEY}"
environment: "us-east-1-aws"
index_name: "flowsquad-prod"
dimension: 1536 # matches OpenAI text-embedding-3-small
indexing:
chunk_size: 512 # tokens per chunk
chunk_overlap: 64 # overlap for context continuity
top_k_retrieval: 10 # chunks retrieved per query
reindex_on_push: true # auto-reindex on git push
When ChromaDB is used with a local embedding model (such as all-MiniLM-L6-v2), the embedding step itself costs zero tokens — it runs on your infrastructure. This means indexing a 500k-line codebase has no API cost at all. Only the final LLM completion call — with its ~4,000-token context — is billed.
FlowSquad's LLM cost tracker provides per-model, per-user, per-feature cost visibility with daily and monthly aggregations. Here's what the numbers look like in practice for a team running 200 AI queries per day:
| Approach | Model | Avg Tokens/Query | Cost/Query | Monthly Cost (200 queries/day) |
|---|---|---|---|---|
| Naive injection | GPT-4 Turbo | 80,000 | $0.80 | $4,800 |
| Naive injection | Claude 3.5 Sonnet | 80,000 | $0.24 | $1,440 |
| FlowSquad VectorDB | GPT-4 Turbo | 4,200 | $0.042 | $252 |
| FlowSquad VectorDB | Claude 3.5 Sonnet | 4,200 | $0.013 | $78 |
| FlowSquad VectorDB | Ollama/Llama 3.1 (local) | 4,200 | $0.00 | $0 |
The table above shows a 95% cost reduction for GPT-4 Turbo when switching from naive injection to FlowSquad's vectorised approach. Teams with air-gapped deployments using Ollama achieve zero marginal LLM cost per query — paying only infrastructure costs.
FlowSquad's Multi-LLM support lets you mix providers intelligently — routing simple queries to a cheaper model (Claude Haiku, GPT-3.5, or local Ollama) and reserving expensive models (GPT-4 Turbo, Claude 3.5 Sonnet) for complex generation tasks like HLD/LLD design or full test suite generation.
A typical FlowSquad deployment for a 15-person team results in:
gpt-3.5-turbo for story decomposition and AskProduct queries, and gpt-4-turbo only for HLD generation and security analysis. This tiered routing reduces costs by a further 40% without measurable quality degradation on routine tasks.The LLM cost tracker intercepts every API call made through FlowSquad's LLM layer and records the model used, token counts (input and output), user identity, feature/function that triggered the call, and the resulting cost based on current provider pricing. Data is aggregated in real-time and available via the FlowSquad admin dashboard with daily, weekly, and monthly views, filterable by user, team, project, or LLM provider.
FlowSquad supports incremental indexing — only the files that changed in a commit are re-chunked and re-embedded. For a typical PR (10–50 files changed), incremental re-indexing takes 30–90 seconds. Full re-indexing (triggered manually or on a schedule) is recommended after large refactors or dependency upgrades and takes 15–30 minutes for a 500k-line codebase.
FlowSquad supports export/import of vector indexes between backends. You can export your ChromaDB index to a portable format and import it into Pinecone (or vice versa) without re-running the embedding step. This is useful for teams migrating from on-premise to cloud deployment. Note that if the embedding model changes between backends, a full re-index is required.
For cloud deployments: OpenAI text-embedding-3-small (recommended for cost/quality balance), text-embedding-3-large (higher quality, higher cost), and Amazon Titan Embeddings. For local/on-premise: all-MiniLM-L6-v2, nomic-embed-text via Ollama, and any Ollama-compatible embedding model. The embedding model is configured once per FlowSquad project and cannot be changed without re-indexing.
Yes. FlowSquad's Multi-LLM routing allows you to define routing rules in the platform configuration. Rules can be based on feature type (e.g., always use GPT-4 for HLD generation), query complexity score (estimated token count of the expected output), user role (analysts get GPT-3.5, admins get GPT-4), or explicit user selection. All routing decisions are logged for cost attribution purposes.