How to Integrate Anthropic for investment banking with Cloudflare Workers for multi-agent systems
Combining Anthropic with Cloudflare Workers gives you a clean split between reasoning and execution. Anthropic handles the analyst-grade language tasks — deal summaries, risk memos, IC prep, diligence extraction — while Workers sit at the edge and coordinate multi-agent workflows with low latency and tight control over routing.
For investment banking, that means you can build systems that ingest a pitch deck, fan out to specialized agents for comps, sector context, and red-flag detection, then return a structured memo fast enough to be useful in live workflows.
Prerequisites
- •Python 3.10+
- •An Anthropic API key
- •A Cloudflare account with:
- •Workers enabled
- •
wranglerinstalled and authenticated
- •A deployed Worker endpoint or local Worker dev server
- •
httpxinstalled for calling the Worker from Python - •
anthropicSDK installed
pip install anthropic httpx
npm install -g wrangler
wrangler login
Integration Steps
- •Set up your Anthropic client for banking analysis
Use Anthropic for the reasoning layer. In banking systems, keep prompts narrow and structured so outputs are easy to route downstream.
import os
from anthropic import Anthropic
client = Anthropic(api_key=os.environ["ANTHROPIC_API_KEY"])
def analyze_deal_note(note: str) -> str:
response = client.messages.create(
model="claude-3-5-sonnet-latest",
max_tokens=800,
temperature=0.2,
messages=[
{
"role": "user",
"content": f"""
You are an investment banking analyst.
Extract:
1. company summary
2. transaction type
3. key risks
4. follow-up questions
Return JSON only.
Note:
{note}
"""
}
],
)
return response.content[0].text
- •Create a Cloudflare Worker that routes tasks to specialized agents
Workers are the orchestration layer here. One request can fan out into multiple agent jobs: one for valuation context, one for risk review, one for document extraction.
import requests
WORKER_URL = "https://your-worker.your-subdomain.workers.dev"
def dispatch_task(task_type: str, payload: dict) -> dict:
resp = requests.post(
WORKER_URL,
json={
"task_type": task_type,
"payload": payload,
},
timeout=30,
)
resp.raise_for_status()
return resp.json()
A typical Worker endpoint can be configured to accept these task types:
- •
summarize_deal - •
extract_covenants - •
compare_comps - •
generate_ic_questions
That lets you keep agent routing outside your core application logic.
- •Combine Anthropic analysis with Worker-based multi-agent fanout
This is the useful pattern: let Anthropic produce structured intent, then let Workers fan out work to specialized agents based on that intent.
import json
def build_multi_agent_pipeline(deal_text: str) -> dict:
# Step 1: initial bank-grade analysis from Anthropic
analysis_text = analyze_deal_note(deal_text)
analysis = json.loads(analysis_text)
# Step 2: route tasks through Cloudflare Worker
results = {}
if "key risks" in analysis:
results["risk_agent"] = dispatch_task(
"risk_review",
{"text": deal_text, "focus": analysis["key risks"]},
)
results["summary_agent"] = dispatch_task(
"deal_summary",
{"text": deal_text},
)
results["questions_agent"] = dispatch_task(
"ic_questions",
{"text": deal_text, "analysis": analysis},
)
return {
"analysis": analysis,
"agent_results": results,
}
In production, this pattern keeps the LLM output deterministic enough to drive orchestration without hardcoding business logic into prompts.
- •Add a lightweight Worker-side callback flow for async multi-agent jobs
For longer-running banking workflows — like processing a data room or a CIM — use async callbacks so the Worker can finish quickly and send results back later.
import uuid
def submit_async_review(document_url: str) -> dict:
job_id = str(uuid.uuid4())
resp = requests.post(
f"{WORKER_URL}/jobs",
json={
"job_id": job_id,
"document_url": document_url,
"callback_url": "https://your-app.example.com/api/worker-callback",
"agents": ["summary", "risk", "market"],
},
timeout=15,
)
resp.raise_for_status()
return {"job_id": job_id, "status": resp.json()["status"]}
Use this when you do not want the user request blocked by long-running agent execution.
- •Normalize outputs into a banking-friendly schema
Do not pass raw model text around your system. Convert everything into a schema that downstream tools can validate and store.
from dataclasses import dataclass
from typing import List
@dataclass
class BankingMemo:
company: str
transaction_type: str
risks: List[str]
questions: List[str]
summary: str
def parse_memo(data: dict) -> BankingMemo:
return BankingMemo(
company=data.get("company", ""),
transaction_type=data.get("transaction_type", ""),
risks=data.get("key_risks", []),
questions=data.get("follow_up_questions", []),
summary=data.get("summary", ""),
)
That gives you stable contracts between Anthropic outputs, Worker orchestration, and your internal systems.
Testing the Integration
Run a simple end-to-end test against both services:
if __name__ == "__main__":
sample_note = """
Target is a mid-market software company seeking growth capital.
Revenue is recurring but churn increased in Q2.
Management wants to explore a minority investment.
"""
result = build_multi_agent_pipeline(sample_note)
memo = parse_memo({
"company": result["analysis"].get("company", "Unknown"),
"transaction_type": result["analysis"].get("transaction type", ""),
"key_risks": ["churn increase", "execution risk"],
"follow_up_questions": ["What is net revenue retention?", "What is CAC payback?"],
"summary": result["analysis"].get("company summary", ""),
})
print(memo)
Expected output:
BankingMemo(
company='...',
transaction_type='minority investment',
risks=['churn increase', 'execution risk'],
questions=['What is net revenue retention?', 'What is CAC payback?'],
summary='...'
)
If the Worker endpoint is reachable and Anthropic returns valid JSON, you have the full loop working.
Real-World Use Cases
- •
Deal screening pipeline
- •Parse inbound teasers with Anthropic.
- •Route extracted signals through Workers to separate agents for sector fit, risk flags, and comp relevance.
- •Return a ranked shortlist to bankers.
- •
IC memo generation
- •Use Anthropic to draft sections like business overview and key risks.
- •Use Workers to orchestrate specialist agents that fetch market context, summarize diligence notes, and validate assumptions.
- •
CIM / data room review
- •Split documents across agents in Workers.
- •Use Anthropic on each chunk for extraction and synthesis.
- •Merge results into one normalized diligence report.
This setup works because each tool does one job well. Anthropic handles language-heavy banking work; Cloudflare Workers handle distribution, routing, and lightweight coordination at the edge.
Keep learning
- •The complete AI Agents Roadmap — my full 8-step breakdown
- •Free: The AI Agent Starter Kit — PDF checklist + starter code
- •Work with me — I build AI for banks and insurance companies
By Cyprian Aarons, AI Consultant at Topiax.
Want the complete 8-step roadmap?
Grab the free AI Agent Starter Kit — architecture templates, compliance checklists, and a 7-email deep-dive course.
Get the Starter Kit