Flex cut operational costs by $1.5 billion annually by automating underwriting, support, and accounting. Learn their full tech stack for your startup.
Flex announced during its Q1 2026 earnings call that their automation stack has reduced operating costs by an impressive $1.5 billion annually. This isn’t just another marketing-laden press release: we’re talking about real architecture, concrete infrastructure decisions, and processes that have been redesigned to be scalable for any startup. This is the difference between wasting money on ineffective AI tools and building a system that truly makes an impact.
Photo: Igor Omilaev on Unsplash
This article provides a full reverse engineering of Flex's stack: what processes they automated, how they did it, what technologies they used, and why those specific decisions led to nine-figure savings. If you’re a founder or technical leader, here’s a step-by-step blueprint for you.
The Real Stack: What Flex Automated and Why It Matters
Flex didn’t just automate random processes. They focused on three areas of high operational cost and low human-added value: credit underwriting, first-tier customer support, and accounting reconciliation. Each of these areas represented between $400M and $600M solely in personnel costs and overhead.
Automated credit underwriting: They replaced 180 analysts with a decision-making system based on Anthropic Claude 3.5 Sonnet along with proprietary risk models. The full workflow is as follows:
- Applicant data ingestion via API (income, credit history, transactional behavior).
- Preprocessing with Pandas and integrity validation.
- Feature engineering: 47 variables calculated from raw data.
- Internal scoring model (XGBoost trained on 2.3M historical applications).
- Claude 3.5 Sonnet analyzes edge cases and generates rejection explanations.
- Final decision is made in less than 2 seconds with an error rate of 0.8% (compared to 2.1% in humans).
Cost per decision dropped from $8.50 (human analyst) to $0.04 (model plus infrastructure). With 18 million applications annually, this represents $152M in direct savings.
Customer support tier 1: They implemented a RAG (Retrieval-Augmented Generation) system over their knowledge base using Supabase Vector as the store and Claude 3.5 as the generation engine. The setup is as follows:
# Simplified RAG architecture
from supabase import create_client
from anthropic import Anthropic
supabase = create_client(SUPABASE_URL, SUPABASE_KEY)
anthropic = Anthropic(api_key=ANTHROPIC_KEY)
def handle_support_query(user_query):
# 1. Query embedding
embedding = get_embedding(user_query)
# 2. Vector search in Supabase
results = supabase.rpc(
'match_documents',
{'query_embedding': embedding, 'match_threshold': 0.78, 'match_count': 5}
).execute()
# 3. Context construction
context = "\n\n".join([doc['content'] for doc in results.data])
# 4. Generation with Claude
response = anthropic.messages.create(
model="claude-3-5-sonnet-20241022",
max_tokens=1024,
messages=[{
"role": "user",
"content": f"Context: {context}\n\nUser question: {user_query}"
}]
)
return response.content[0].text
Result: 73% of first-level inquiries were resolved without human intervention. They reduced from 340 agents to only needing 92. Annualized savings: $447M.
Accounting reconciliation: This was the most underestimated problem. Flex processes 12 million daily transactions between accounts, cards, loans, and merchant payments. Manual reconciliation required 210 full-time accountants just to ensure everything balanced.
They built an anomaly detection system using Apache Kafka for streaming, Flink for real-time processing, and a classification model that learns normal versus anomalous patterns. Real discrepancies (< 0.03% of volume) are escalated to humans. The rest is processed automatically.
Savings: $421M annually, with discrepancy detection time reduced from 72 hours to 4 minutes.
The Architectural Decision That Makes It Possible
Photo: Luke Jones on Unsplash
The secret is not in the individual tools, but in the architecture that connects them. Flex implemented an event-driven architecture, where every user interaction generates events that flow through a Kafka backbone.
This is important because most startups build synchronous request-response systems. User does something → backend processes → response. Such a model is not scalable for massive automation because:
- It creates strong coupling between services.
- It does not allow asynchronous processing of long tasks.
- It complicates the integration of AI models that require variable latencies.
Flex redesigned everything based on events:
- User applies for a card → event
card.application.created - Underwriting system consumes event → executes scoring → publishes
card.application.scored - Decision system consumes → approves/rejects → publishes
card.application.decided - Notification system consumes → sends email/SMS → publishes
notification.sent
Each step is independent, horizontally scalable, and fault-tolerant. If the notification system fails, the rest continues to function. Events remain in Kafka until they are processed.
The full tech stack:
- Message broker: Kafka (cluster of 24 nodes, 180M events/day)
- Stream processing: Apache Flink (real-time transaction processing)
- Database: PostgreSQL (transactional data), Supabase Vector (embeddings)
- AI/ML: Claude 3.5 Sonnet (generation), XGBoost (scoring), TensorFlow (fraud detection)
- Infrastructure: Kubernetes on AWS (1,200 pods in production)
- Observability: Datadog (metrics), Sentry (errors), custom dashboards
Monthly stack costs: $340K. Monthly savings generated: $125M. ROI: 367x.
How to Replicate It in Your Startup: Practical Blueprint
You don’t need Flex’s budget to apply these principles. Here’s the MVP version you can implement with a small team in 6 to 8 weeks.
Phase 1: Identify the highest-cost/lowest-value process (Week 1)
Don’t automate the first thing that comes to mind. You need data:
- List all repetitive manual processes.
- Calculate the cost per operation (executor salary / monthly operations).
- Measure the human-added value (does it require creative judgment or is it rules plus data?).
- Prioritize the highest cost/value ratio.
For example, if you have a B2B SaaS startup with 50K users and first-level customer support costs $18K/month (2 agents), with 80% of queries about onboarding, billing, or password reset, the human-added value is near zero. That’s your candidate.
Phase 2: Build the basic RAG system (Weeks 2-4)
Minimum viable setup:
# 1. Generate embeddings for your documentation
import openai
from supabase import create_client
docs = [
"How to change password: go to Settings > Security...",
"Billing: we bill on the 1st of each month...",
# ... your knowledge base
]
supabase = create_client(URL, KEY)
for doc in docs:
embedding = openai.Embedding.create(
input=doc,
model="text-embedding-3-small"
)['data'][0]['embedding']
supabase.table('knowledge_base').insert({
'content': doc,
'embedding': embedding
}).execute()
# 2. Query function
def answer_query(query):
# Query embedding
query_emb = openai.Embedding.create(
input=query,
model="text-embedding-3-small"
)['data'][0]['embedding']
# Vector search
results = supabase.rpc(
'match_documents',
{'query_embedding': query_emb, 'match_count': 3}
).execute()
context = "\n".join([r['content'] for r in results.data])
# Generation
response = openai.ChatCompletion.create(
model="gpt-4",
messages=[
{"role": "system", "content": "You are a support assistant. Respond based ONLY on the provided context."},
{"role": "user", "content": f"Context:\n{context}\n\nQuestion: {query}"}
]
)
return response.choices[0].message.content
Costs: OpenAI embeddings ($0.00002/1K tokens) + GPT-4 ($0.03/1K tokens) + Supabase ($25/month Pro plan). With 1,000 queries/month ≈ $80 total. Savings vs 2 agents: $17,920/month.
Phase 3: Integrate with your current system (Weeks 5-6)
Integration is often where many fail. Building a chatbot that lives isolated in a tab no one uses is a mistake. You must integrate it where the user ALREADY is:
- Intercom/Zendesk: webhook that calls your RAG before escalating to human.
- Email: system that parses incoming emails and responds automatically if confidence is > 85%.
- In-app: widget that suggests answers while the user types.
Key metric: automation rate. It indicates the percentage of queries resolved without human intervention. Initial target: 40%. Flex achieves 73% because they iterated over 18 months.
Phase 4: Measure and optimize (Weeks 7-8)
Basic observability setup:
# Wrapper with metrics
import time
from datadog import statsd
def answer_with_metrics(query):
start = time.time()
try:
answer = answer_query(query)
statsd.increment('support.query.success')
statsd.histogram('support.query.latency', time.time() - start)
# Log for later fine-tuning
log_query(query, answer, feedback=None)
return answer
except Exception as e:
statsd.increment('support.query.error')
raise
Important dashboards:
- Automation rate: queries resolved automatically / total queries
- p95 latency: 95% of responses in < X seconds
- Accuracy: positive feedback / total responses (requires like/dislike button)
- Cost per query: tokens used * price per token
- Escalation rate: queries that end with human agent
Optimize in this order: accuracy first (incorrect model is worse than a slow human), latency second (users abandon > 8 seconds), cost last (it’s marginal compared to salaries).
The Mistakes That Kill Your ROI
I’ve seen over 30 startups fail in automation. Three fatal mistakes:
1. Automating processes you don’t understand
A fintech startup automated loan approvals without first documenting human decision rules. The result? Default rate increased by 340% in two months. They lost $1.8M before reversing the change.
Rule: document the existing manual process with extreme detail before writing a line of code. If you can’t explain it in a flowchart, don’t automate it yet.
2. Blindly trusting language models
LLMs hallucinate. It’s a feature, not a bug. Never use an LLM for critical decisions without external validation.
Correct architecture:
- LLM generates candidate response
- Validation system checks against knowledge base
- If confidence is below threshold, escalate to human
- NEVER send an LLM response directly to the user without review
3. Not measuring the real business impact
Saying “We automated 60% of queries” doesn’t matter if your customer satisfaction drops 15 points. Flex measures:
- NPS after automated interaction vs human (difference: -2 points, acceptable)
- Complete resolution time (automated: 2 min, human: 47 min)
- Escalation rate (27% of automated cases escalate vs 100% prior)
- Customer lifetime value of users who interacted with bot vs agent (difference: not significant)
If your business metrics degrade, the automation is poorly implemented. Period.
Perspective: Automation Is Architecture, Not Tools
The biggest conceptual mistake is thinking automation is simply "integrating Claude" or "using GPT-4". Flex didn’t save $1.5B by buying APIs. They did it by redesigning entire systems around events, building robust data pipelines, and obsessively measuring impact.
AI tools are commodities. The competitive advantage lies in how you orchestrate them, what data you feed them, how you validate outputs, and how you measure business results. Any startup can replicate 70% of Flex’s impact with a small team and modest budget if they understand these principles.
The question isn’t “which LLM do I use?” but “what high-cost, low-value manual process can I replace with deterministic rules plus AI where rules fail?”. Start there.
What process in your startup costs more than $5K/month in human time and could be automated in 8 weeks? The answer is probably more obvious than you think. For insights on creating an unbiased chatbot, check out our article on How to Build a Discrimination-Free Chatbot and learn how to avoid biases in AI with Use Hugging Face and Fairlearn to Avoid Chatbot Bias.
🇪🇸 Also available in Spanish: Leer en español