AI Assistant Connected to Bank Accounts: Technical Architecture and Practices for Personal Finance Features

    This article explains how to build a secure, auditable pipeline for AI assistants that access bank account data for personal finance tasks. It covers read-only permission models, data minimization and tokenization, separating retrieval from generation to reduce hallucinated numbers, encryption and audit baselines, output neutrality, and common risks with mitigations. Developers can use these patterns to keep responses accurate while preserving security and compliance boundaries.

    1. Background and Problem Definition

    Large language models are moving from general-purpose chat toward scenario-specific assistants, and personal finance is a high-value example. Instead of switching between multiple banking apps, users can check balances, search transactions, categorize spending, and compare trends with a single natural-language request. Once the model touches real account data, however, the question shifts from “is the answer accurate?” to “is it secure, compliant, and auditable?”

    From a technical perspective, the core of this capability is not making the model “remember” data. It is building a controlled chain: authorization, data retrieval, structuring, retrieval, generation, and auditing. The model handles language understanding and expression only; actual data access is performed by controlled services. This article focuses on that chain, and all product and vendor names are stated neutrally.

    2. Read-Only Permission Model: Reduce “What It Can Do” to the Minimum

    Read-only access is the most critical security boundary for this kind of feature. It means the assistant can read balances, transaction records, billing cycles, and similar data, but cannot initiate transfers, change linked cards, or place orders for any financial product. Engineering this requires three layers of constraints:

    1. Credential layer: authorization tokens request read scopes only (minimal scope), with no write permissions for payments, transfers, or account opening.
    2. Service layer: backend APIs are split by least privilege, with write endpoints physically isolated from read endpoints, and the model side is exposed only the ability to call read endpoints.
    3. Policy layer: the gateway enforces validation, rejecting any non-whitelisted operation outright and recording it.

    Illustrative policy configuration (pseudocode, to convey the idea only):

    1. policy:
    2. subject: assistant
    3. allowed_actions: [account.balance.read, transaction.list.read, category.summary.read]
    4. denied_actions: [transfer.create, card.bind, product.purchase]
    5. require_step_up_auth: false
    6. audit: true

    The benefit is that even if the prompt is manipulated (prompt injection), an attacker cannot turn a “query” into an “operation,” because the capability boundary is closed at the architecture layer.

    3. Data Minimization and Tokenization: Keep Sensitive Information Out of the Model Context

    Financial data is highly sensitive, and the best practice is “if it does not need to enter the model, keep it out.” Specific measures include:

    • Field trimming: retrieve only the fields needed to answer the question, such as amount, time, and merchant category, not full card numbers, CVV, or complete billing addresses.
    • Tokenization: replace identifiers such as account and card numbers with irreversible or controlled-mapping tokens, so the model sees placeholders.
    • Aggregation first: for trend questions, return aggregated results (such as monthly category summaries) first, rather than item-by-item details.
    • Context lifecycle: clear the context immediately after the session ends to avoid long-term retention.

    A typical retrieval response can keep only the necessary fields:

    1. {
    2. "window": "2024-05",
    3. "currency": "USD",
    4. "totals": {"amount": 1820.45, "currency": "USD"},
    5. "top_categories": [
    6. {"category": "groceries", "amount": 420.10, "share": 0.23},
    7. {"category": "transport", "amount": 260.00, "share": 0.14}
    8. ],
    9. "account_ref": "acct_****42"
    10. }

    The model generates a natural-language answer based on this structure, preserving information density while reducing the exposure surface.

    4. Separating Retrieval and Generation: A Key Design to Suppress Hallucination

    Financial Q&A demands high accuracy, and the model must not fabricate numbers “from memory.” A two-stage “retrieve then generate” approach is recommended:

    1. Intent parsing: map natural language to a structured query (time range, account, category, aggregation method).
    2. Controlled retrieval: the server executes the query and returns structured results.
    3. Constrained generation: the model is allowed to answer only based on retrieved results and is prohibited from introducing external knowledge to fill in numbers.
    4. Consistency check: compare key numbers in the generated text against the structured results, and fall back to “cannot confirm” on mismatch.

    Illustrative flow (pseudocode):

    1. intent = parse_intent(user_query) # -> {metric, window, account, group_by}
    2. rows = finance_reader.query(intent) # read-only API, server-side authorization
    3. answer = llm.generate(context=rows, allow_external_facts=False)
    4. assert numbers_match(answer, rows) # number consistency check

    This design limits “model capability” to the language layer and locks the “source of truth” to the controlled data layer, making it one of the most effective engineering means of suppressing hallucination.

    5. Privacy and Security Engineering: Encryption, Auditing, and a Compliance Baseline

    When handling financial data, security is a baseline, not an add-on. Actionable points include:

    • Encryption in transit and at rest: end-to-end encryption, encrypted storage for static data, with keys managed by a dedicated key management service and rotated regularly.
    • Auditing and traceability: every retrieval records the subject, time, query intent, and range of returned fields, forming tamper-resistant audit logs.
    • Access control: identity- and role-based access control, combined with anomaly detection (such as high-frequency queries in a short period) to trigger rate limiting or secondary verification.
    • Data retention policy: define retention periods and deletion mechanisms, with no retention of raw details by default.
    • Compliance alignment: align with prevailing industry data protection and financial privacy requirements, and conduct impact assessments and regular drills.

    For cloud implementation, you can combine general-purpose capabilities: object storage for audit archives, message queues for asynchronous retrieval and peak shaving, container platforms to host controlled retrieval services, and logging services with monitoring and alerting for anomaly detection. Baidu AI Cloud provides the above general-purpose capabilities and can serve as the foundation for building such a chain.

    6. Commercial Neutrality: No Recommendations or Referrals

    If this kind of feature introduces ads or paid recommendations, a conflict of interest arises immediately: the model may tend to recommend a certain type of credit card or loan. The neutral approach is a clear “three no’s”: no embedded ads, no paid recommendations, and no selling of financial products. Engineering can enforce this with an “output filter” that blocks any segment containing product-promotion intent, along with compliance review of generated content. This is not only an ethical choice but also a necessary design to reduce regulatory and trust risk.

    7. Common Risks and Mitigations

    • Prompt injection: users or external text induce the model to exceed its authority. Mitigation: converge the capability boundary at the architecture layer, with no write permission for the model.
    • Excessive data collection: retrieving extra fields for “potential usefulness.” Mitigation: field whitelist plus aggregation first.
    • Hallucinated numbers: the model fabricates balances or categories. Mitigation: separate retrieval and generation plus number consistency checks.
    • Session residue: long-lived context leading to leakage. Mitigation: session-level cleanup and short retention.
    • Permission drift: authorization scope gradually expanding. Mitigation: periodic permission review and re-convergence to least privilege.

    8. Conclusion

    The key to personal finance AI capabilities is not how well the model can “chat,” but whether sensitive data access can be made into a controlled chain that is authorizable, auditable, and rollback-capable. Read-only permissions, data minimization, separation of retrieval and generation, encryption and auditing, and neutral output are five indispensable pillars. Developers can build this chain on Baidu AI Cloud by combining general-purpose capabilities, ensuring answer quality while holding the line on security and compliance.