How to Integrate Anthropic for wealth management with Cloudflare Workers for multi-agent systems

By Cyprian AaronsUpdated 2026-04-21
anthropic-for-wealth-managementcloudflare-workersmulti-agent-systems

Anthropic gives you the reasoning layer for wealth-management workflows: portfolio summaries, client-facing explanations, suitability checks, and document analysis. Cloudflare Workers gives you the edge runtime to route requests, orchestrate agents, and keep latency low when multiple services need to cooperate.

The useful pattern here is not “one model does everything.” It’s a multi-agent system where one agent handles market/context retrieval, another drafts advice or explanations, and a Worker coordinates the handoff with tight request control.

Prerequisites

  • Python 3.10+
  • anthropic Python SDK installed
  • cloudflare Python SDK installed
  • A Cloudflare account with Workers enabled
  • An Anthropic API key
  • A deployed Worker endpoint or a local Worker dev setup
  • Basic familiarity with HTTP JSON payloads and environment variables

Install the Python packages:

pip install anthropic cloudflare requests python-dotenv

Set environment variables:

export ANTHROPIC_API_KEY="your_anthropic_key"
export CLOUDFLARE_API_TOKEN="your_cloudflare_api_token"
export CLOUDFLARE_ACCOUNT_ID="your_account_id"
export WORKER_BASE_URL="https://your-worker.your-subdomain.workers.dev"

Integration Steps

  1. Create the Anthropic client for wealth-management reasoning

    Start by initializing the Anthropic SDK in Python. In a wealth-management system, this client typically powers client summaries, policy explanations, and agent-to-agent reasoning.

import os
from anthropic import Anthropic

anthropic_client = Anthropic(api_key=os.environ["ANTHROPIC_API_KEY"])

def generate_wealth_summary(client_profile: dict) -> str:
    prompt = f"""
    You are a wealth management assistant.
    Summarize this client profile for an advisor:
    {client_profile}
    Focus on risk tolerance, liquidity needs, concentration risk, and next actions.
    """
    response = anthropic_client.messages.create(
        model="claude-3-5-sonnet-latest",
        max_tokens=400,
        messages=[{"role": "user", "content": prompt}],
    )
    return response.content[0].text
  1. Define the Worker as the orchestration layer

    Cloudflare Workers should own routing, rate limiting, and agent selection. In practice, your Worker receives a request from your app, decides which specialist agent to call, then returns a structured response.

    If you are deploying from Python tooling, use the Cloudflare API to upload or manage the Worker. The actual runtime code still runs in JavaScript/TypeScript on Cloudflare’s edge.

import os
from cloudflare import Cloudflare

cf = Cloudflare(api_token=os.environ["CLOUDFLARE_API_TOKEN"])
account_id = os.environ["CLOUDFLARE_ACCOUNT_ID"]

def list_workers_scripts():
    scripts = cf.workers.scripts.list(account_id=account_id)
    return scripts

print(list_workers_scripts())
  1. Have the Worker call an Anthropic-powered agent endpoint

    A common pattern is: Worker receives a request from your app, then forwards it to an internal Python service that calls Anthropic. That keeps your edge logic thin while preserving deterministic routing.

    Here is a Python service that acts like an agent backend behind the Worker:

from flask import Flask, request, jsonify
from anthropic import Anthropic
import os

app = Flask(__name__)
client = Anthropic(api_key=os.environ["ANTHROPIC_API_KEY"])

@app.post("/agent/wealth-summary")
def wealth_summary():
    payload = request.json
    response = client.messages.create(
        model="claude-3-5-sonnet-latest",
        max_tokens=300,
        messages=[{
            "role": "user",
            "content": f"Create an advisor summary for this portfolio data:\n{payload}"
        }],
    )
    return jsonify({
        "summary": response.content[0].text,
        "agent": "wealth-summary"
    })
  1. Call the Worker from your application and route between agents

    Your application should talk to the Worker first. The Worker can then decide whether to invoke a research agent, compliance agent, or portfolio-summary agent based on intent.

    From Python, you can verify that the Worker endpoint is reachable and returns structured JSON:

import os
import requests

worker_url = os.environ["WORKER_BASE_URL"]

payload = {
    "client_id": "c_10293",
    "intent": "portfolio_review",
    "portfolio": {
        "equities_pct": 62,
        "bonds_pct": 28,
        "cash_pct": 10,
        "single_name_concentration": 0.31,
        "risk_profile": "moderate"
    }
}

resp = requests.post(f"{worker_url}/route", json=payload, timeout=20)
print(resp.status_code)
print(resp.json())
  1. Add structured handoff between multiple agents

    For multi-agent systems in wealth management, use explicit schemas so each agent knows what it owns. One agent can produce facts; another can turn those facts into client-ready language; a third can check compliance constraints.

from pydantic import BaseModel
from typing import Literal

class AgentTask(BaseModel):
    task_type: Literal["research", "summary", "compliance"]
    client_id: str
    input_text: str

def send_task_to_worker(task: AgentTask):
    resp = requests.post(
        f"{worker_url}/agent-task",
        json=task.model_dump(),
        timeout=20,
    )
    resp.raise_for_status()
    return resp.json()

task = AgentTask(
    task_type="compliance",
    client_id="c_10293",
    input_text="Review proposed allocation change for suitability concerns."
)

print(send_task_to_worker(task))

Testing the Integration

Run a simple end-to-end test: send portfolio data to the Worker route and confirm you get back an Anthropic-generated summary.

import os
import requests

worker_url = os.environ["WORKER_BASE_URL"]

test_payload = {
    "client_id": "demo_001",
    "intent": "portfolio_review",
    "portfolio": {
        "equities_pct": 70,
        "bonds_pct": 20,
        "cash_pct": 10,
        "notes": ["High tech exposure", "Upcoming retirement in 7 years"]
    }
}

response = requests.post(f"{worker_url}/route", json=test_payload)
print("status:", response.status_code)
print("body:", response.json())

Expected output:

{
  "status": 200,
  "body": {
    "agent": "wealth-summary",
    "summary": "The portfolio is equity-heavy with elevated concentration risk...",
    "trace_id": "tr_01H..."
  }
}

If you get a 200 with an agent field and a non-empty summary, the integration path is working.

Real-World Use Cases

  • Advisor copilot

    • One agent summarizes portfolio risk.
    • Another generates plain-English talking points for advisor calls.
    • The Worker routes by intent and logs every step for auditability.
  • Client servicing triage

    • A frontline agent classifies inbound requests like beneficiary changes or withdrawal questions.
    • Anthropic drafts responses.
    • Cloudflare Workers handles request shaping and throttling at the edge.
  • Compliance pre-checks

    • One agent reviews proposed trades against policy rules.
    • Another explains why something may be unsuitable.
    • The Worker coordinates approvals before anything reaches production systems.

Keep learning

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

Related Guides