How to Integrate Next.js for investment banking with Vercel AI SDK for multi-agent systems
Combining Next.js for investment banking with Vercel AI SDK gives you a clean path to build agent-driven banking workflows without turning your app into a ball of glue code. The practical win is simple: Next.js handles the client and server surfaces, while Vercel AI SDK orchestrates multi-agent reasoning, tool calls, and streaming responses for tasks like deal screening, risk triage, and analyst copilots.
Prerequisites
- •Python 3.11+
- •Node.js 18+ for the Next.js app
- •A Next.js investment banking project already scaffolded
- •Vercel AI SDK installed in your frontend/backend layer
- •Access to your model provider API key
- •A backend service that can expose banking data and agent tools
- •
pipandnpmconfigured in your environment
Integration Steps
- •
Install the Python sidecar dependencies
Keep the agent orchestration in Python if your internal tooling is already there. Use FastAPI to expose agent endpoints, then let Next.js call them through API routes or server actions.
from fastapi import FastAPI from pydantic import BaseModel app = FastAPI() class DealRequest(BaseModel): company: str sector: str revenue: float @app.post("/agent/triage") async def triage_deal(payload: DealRequest): return { "company": payload.company, "priority": "high" if payload.revenue > 500_000_000 else "medium", "recommended_agent": "valuation_agent" } - •
Create a multi-agent router for banking tasks
In practice, you want one router agent that delegates to specialist agents. That keeps underwriting, valuation, and compliance concerns separated.
from typing import Literal def route_request(sector: str, revenue: float) -> Literal["valuation", "risk", "compliance"]: if revenue > 1_000_000_000: return "valuation" if sector.lower() in {"financial services", "insurance"}: return "compliance" return "risk" def valuation_agent(company: str) -> dict: return {"agent": "valuation", "output": f"{company}: comparable multiples reviewed"} def risk_agent(company: str) -> dict: return {"agent": "risk", "output": f"{company}: credit and exposure flags checked"} def compliance_agent(company: str) -> dict: return {"agent": "compliance", "output": f"{company}: KYC/AML review queued"} - •
Expose the agent orchestration as an HTTP endpoint
This is the bridge between Next.js and the Python multi-agent system. Your Next.js app can call this endpoint from a route handler or server action.
from fastapi import FastAPI from pydantic import BaseModel app = FastAPI() class AgentInput(BaseModel): company: str sector: str revenue: float @app.post("/agent/run") async def run_agents(payload: AgentInput): route = route_request(payload.sector, payload.revenue) if route == "valuation": result = valuation_agent(payload.company) elif route == "risk": result = risk_agent(payload.company) else: result = compliance_agent(payload.company) return { "route": route, "result": result, "status": "ok" } - •
Call the Python agent service from Next.js using a server action
On the Next.js side, use a server action or route handler to call your Python service. If you are using Vercel AI SDK, this is where you wire in streaming UI updates and tool-driven responses.
import requests def send_to_agent_service(company: str, sector: str, revenue: float) -> dict: response = requests.post( "http://localhost:8000/agent/run", json={ "company": company, "sector": sector, "revenue": revenue, }, timeout=30, ) response.raise_for_status() return response.json() if __name__ == "__main__": print(send_to_agent_service("Northbridge Capital", "Asset Management", 750_000_000)) - •
Wire Vercel AI SDK into the request path for streaming multi-agent output
Use Vercel AI SDK’s
streamText,generateText, or tool calling flow on the Next.js side to turn agent outputs into a live analyst experience. The Python service stays focused on decision logic; the SDK handles response shaping and streaming.from dataclasses import dataclass @dataclass class AgentMessage: role: str content: str def build_ai_context(agent_result: dict) -> list[AgentMessage]: return [ AgentMessage(role="system", content="You are an investment banking copilot."), AgentMessage( role="user", content=f"Agent route: {agent_result['route']}. Result: {agent_result['result']['output']}" ), ] # In production, serialize this context and pass it to your Next.js/Vercel AI SDK layer.
Testing the Integration
Use a simple end-to-end test against your Python endpoint before wiring UI streaming.
import requests
payload = {
"company": "Northbridge Capital",
"sector": "Asset Management",
"revenue": 750000000
}
resp = requests.post("http://localhost:8000/agent/run", json=payload, timeout=30)
resp.raise_for_status()
data = resp.json()
print(data["route"])
print(data["result"]["output"])
Expected output:
valuation
Northbridge Capital: comparable multiples reviewed
Real-World Use Cases
- •
Deal screening copilot
Route inbound targets through valuation, risk, and compliance agents before an analyst sees them in the Next.js UI. - •
IC memo assistant
Pull data from internal systems, let agents summarize risks and upside cases, then stream a draft investment committee memo back to bankers. - •
KYC/AML triage dashboard
Use one agent to classify entity risk while another checks sanctions/watchlist hits, then surface the result inside a banker-facing workflow.
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