How to Build an AI Loan Underwriting Agent

May 7, 2025

Jonathan Kleiman

Customer Success at Stack AI

Every day a customer waits for loan approval increases chances of abandonment, slows deal velocity, and ultimately hinders operations and growth. 

With some loan approval processes lasting as long as 90 days, your company may become an easy target for more agile competition and a fast-moving market.

AI can’t replace your underwriters, but it can speed up their judgment to improve productivity and assess creditworthiness. 

This can reduce the time taken to understand which clients are a good fit for your institution and which increase your exposure, impacting pricing and risk management.

In this guide, you’ll learn how to build an AI loan underwriting agent with Stack AI, a no-code AI builder platform. 

See how to upload the financial documents of a prospect, get a detailed breakdown of core metrics, and receive AI-generated insights for decisioning.

How to Build an AI Loan Underwriting Agent

Here's a step-by-step walkthrough on how to build an AI loan underwriting agent using the Stack AI platform.

  1. Upload financial documents

First, register a free account for Stack AI. From the dashboard, select New Project -> Workflow Builder. Select the New Project template.

First, we’ll add support for uploading financial documents. On the left menu, expand the Inputs section, drag and drop a Files node onto the canvas.

  1. Extract data from documents with Gemini

The Gemini models are known for their massive context window, enabling them to work with up to 1 million tokens at a time (~512 pages of text). Beyond this, they’re multimodal, meaning they can handle data extraction tasks from uploaded files. 

This is useful if you plan to use a lot of historical financial data to generate a more accurate report, without pre-processing the data with OCR.

Click the Settings icon on the OpenAI LLM.

Click the provider dropdown and select Google.

Expand the model dropdown and choose Gemini 2.5 Pro.

Scroll down the settings to increase the Max Output Tokens to 60,000. This will let the model generate as much data as needed to extract all the transactions and financial information from uploaded documents.

Tip: you can double-click the number and type the value manually.

Connect the Files node to the Google node.

This isn’t the last step of our reasoning workflow. Hover the connection between the Google LLM and the Output nodes and click the delete icon to remove it.

The model needs instructions to understand what to do. Paste the following text into the Instructions input field:

You are a financial document analysis assistant. Your role is to read and interpret uploaded documents (such as bank statements, invoices, and financial reports) and extract relevant financial information.

You do not calculate totals or perform any mathematical reasoning. Your focus is strictly on identifying and extracting data points clearly and consistently.

Follow these steps for each document:

1. Identify the type of document:

- Example types: bank statement, pay stub, invoice, tax return, credit report

2. Extract all relevant financial data, including:

- Dates

- Descriptions or payees

- Individual transaction amounts (mark as income or expense)

- Running balances (if included)

- Account or document metadata (e.g., account holder, statement period, institution)

3. Categorize transactions into the following types:

- Income (e.g., salary, direct deposits, refunds)

- Expenses (e.g., purchases, transfers, rent)

- Fees or overdrafts (e.g., service charges, late fees)

4. Extract timeline indicators:

- First and last transaction dates (do not calculate the length, just extract the endpoints)

5. If multiple documents are provided:

- Extract each document’s content individually

- Note the document type and distinguish clearly between them

Your output should be a plain-text summary that clearly presents the extracted content. Use bullet points or short paragraphs. Do not use tables, JSON, or formatting code.

Include:

- Document types identified

- Extracted transactions with categories

- Notable metadata (e.g., statement period, institution, account holder)

- Any dates or markers useful for timeline analysis

- Notes about unreadable sections or missing data, if any

You are not making any loan recommendations or risk assessments. Your only task is to extract and label raw data for others to use.

Notice that this model will not run any calculations: traditional LLMs such as Gemini 2.5 usually hallucinate mathematical results. Its purpose is merely data extraction. We’ll address calculations in the next section.

Delete the text currently in the Input field of the Google node and paste the following:

User Financial Data:

Type a forward slash after the text and select the Files input from the dropdown.

  1. Summarize financial data

The OpenAI o4 Mini, a reasoning model, is a much better match for calculations and math. We’ll be using it to transform the extracted data to provide insights and metrics that support the next stages of the reasoning.

Expand the LLMs section, drag and drop the OpenAI node onto the canvas.

Click the model selection dropdown and choose o4 Mini.

Connect the Google to the Open AI node.

o4 needs to know how to process data. Paste the following text into the Instructions input field and edit it to include any metrics or calculations proprietary to your underwriting process:

You are a Financial Summary Assistant. Your job is to take raw transaction data from an upstream extractor model and produce a concise, human-readable summary of key calculations and metrics. Your output must be plain text only—do not wrap it in JSON or any other code format.

For each input, include:

1. Core Calculations

• Total income

• Total expenses

• Net profit (income minus expenses)

• Average transaction value

• Total number of transactions

2. Category Breakdown

• For each category, show the total spend and its percentage of overall expenses

• Identify the top 3 categories by spend

3. Time-Series Trends

• Month-over-month (or week-over-week) changes in income, expenses, and net profit

• Call out the fastest-growing and fastest-shrinking categories

4. Anomalies & Flags

• Any individual transaction more than twice the average size for its category (flag with ID, amount, and category)

• Any period (month or week) where expenses exceeded income

5. Prose Summary

• A brief narrative (2–4 sentences) that highlights the biggest insights or concerns

Formatting rules:

- Use simple bullet points or short paragraphs—no JSON, XML, or code blocks.

- Round currency values to two decimal places.

- Express percentages to one decimal place (e.g. “12.3%”).

- If a metric can’t be computed (e.g. no transactions labeled “income”), state “N/A” for that item and note it briefly in your summary.

Delete the text inside the Prompt field. Pass the data from the Gemini model in the prompt of the o4 model:

Data:

Then, type a forward slash and select the Gemini model from the dropdown.

  1. Determine creditworthiness with AI

Now that we have a summary and calculations on a prospect’s financial history, we will use AI to determine creditworthiness, offering insights that will help you make decisions.

Expand the LLMs section on the left side, drag and drop another OpenAI node onto the canvas.

Select the o4 model from the dropdown.

Connect the newest LLM node to the previous OpenAI one and the Output node.

This model has a different task. Edit these suggested instructions to comply with your underwriting process and paste them in the Instructions input field:

You are a financial underwriting assistant. Your role is to assess summarized financial data for an individual and provide a thoughtful loan eligibility recommendation, along with reasoning and financial advice.

You are not making binding credit decisions. Instead, you simulate the reasoning a loan officer or financial advisor would perform when evaluating creditworthiness, affordability, and risk.

You always respond in plain English.

---

When you receive financial summary data, follow this reasoning process:

1. Check income vs. expenses:

- Evaluate whether the person has a monthly surplus.

- Comment on whether income appears stable and diversified.

- Mention if any large one-time sources (e.g., bonus, refund) were included.

2. Evaluate spending habits and financial behavior:

- Look for high expenses, cash flow strain, frequent ATM withdrawals, or large discretionary spending.

- Flag anything unusual (e.g., overdrafts, large transfers, emergency bills).

3. Review credit history and score:

- Comment on credit score range (e.g., “Good,” “Fair,” etc.).

- Evaluate account mix, length of credit history, and payment behavior.

- Note any red flags like missed payments, high utilization, or too many inquiries.

4. Assess outstanding debts:

- Review open loans and balances (e.g., auto, student, credit cards).

- Mention any concerns with debt-to-income (DTI) ratio or high utilization rates.

5. Determine affordability for a new loan:

- Estimate how much capacity remains to support new debt.

- Consider cash reserves and recent spending behavior.

6. Make a recommendation:

- Say whether the applicant is likely a good candidate for a personal loan or similar product.

- If risks exist, offer advice to improve their position (e.g., reduce utilization, increase savings).

- If already well-qualified, comment on strengths and options.

7. Keep your tone practical and professional:

- You are a helpful financial analyst or advisor.

- Don’t be overly technical or alarmist — offer balanced feedback.

---

Your output must include:

- A brief overall summary (1–2 sentences)

- Detailed reasoning for your recommendation

- Actionable advice, if appropriate (e.g., save more, reduce debt)

- Do not return any JSON or code — only plain English advice

As for the prompt, we’ll pass the additional instructions set by the user in case your team wants to steer the reasoning process. Write the following into the Prompt input field:

Additional Instructions: Text input

Data: OpenAI 1

In front of Additional Instructions, type a forward slash and select Text Input. As for Data, type a forward slash again and select the previous OpenAI node’s output.

  1. Format the output into a report

With Stack AI, you can easily build a report by combining the results of multiple models into a single output. Click the Settings icon on the Output node.

Add a Template to the response by clicking the corresponding button.

We’ll display the summary of the extracted financial information along with the AI creditworthiness assessment. Use the header formatting to add the following to the template:

  • Summary of uploaded financial documents

  • AI reasoning

Type a forward slash below the first section and select the first OpenAI LLM node. Repeat the process for the second section (AI reasoning) but choose the last OpenAI LLM node instead.

The project’s architecture is complete. Click Publish to save these changes.

  1. Expand with financial APIs

This guide covers the basic functionality of an AI-driven creditworthiness scoring tool. Since AI works better with as much accurate data as possible, you can integrate your internal and third-party financial APIs to run custom calculations based on user data and use the results to generate a more comprehensive final report.

Stack AI integrates with custom services via its Data API node. You can set up API calls to infrastructure, such as Experian, Plaid, or others, seamlessly running calculations and checks to increase automation and productivity.

  1. Regulation, governance, security, and compliance

The financial industry is a highly-regulated ecosystem. Here’s how Stack AI can help you navigate these requirements from both a platform and project architecture perspective.

Stack AI has SOC 2, GDPR, and HIPAA compliance, meaning it has high data security and protection standards. You can process information privately and securely within the platform. It has enterprise-grade security controls, including role-based access (RBAC) for effective permission management and interface-level protection.

Stack AI projects offer robust data input and output methods, so you can connect any or all parts of the workflow to external databases and information storage systems. This is important as you can store decision-making processes, audit trails, and customer data in external sources.

Regarding observability and transparency, you can implement as many checks as necessary to enable human-in-the-loop frameworks and auditing. You can do so by:

  • Creating multiple Stack AI projects and having your underwriters trigger each section of the logic manually, weaving human and AI judgment into a single workflow

  • Enhancing your existing internal tools with a workflow interface that connects multiple Stack AI projects, with each midpoint as a human approval gate (your IT team can either embed the Stack AI interfaces or use the Stack AI API for programmatic access)

  • Adding multiple output nodes in Stack AI after LLM reasoning steps to store the output, creating an audit trail to troubleshoot data drift, faulty reasoning, or imprecision

The architecture suggested in this guide does not make binding decisions unless you connect it with deal greenlighting systems. Underwriters can use AI output to enrich their assessment or safely disregard it without business impact.

The Stack AI team is ready to answer any questions about privacy, security, and project architecture requirements with objective suggestions and solutions. Schedule a free demo to learn more.

  1. Configure the user interface

We’ll build a form interface that will let your team upload multiple financial documents, add instructions, and get the report once the project finishes running. Click the Export tab to start the configuration.

The form interface is selected by default. Start by naming and adding a description of your tool to improve user experience.

Make sure the files and additional instructions inputs are exposed in the interface. You can also change the alias and required status of each field to make the functionality clearer for your team.

Use the Security features to protect this interface from unauthorized use. You can set an access password, SSO, and embedding rules if you’re planning to integrate it with existing interfaces.

Click the Save Interface to make these changes available to your team.

Share it with your team by copying the link above the preview window and paste it in an email or in an internal communications channel.

  1. Track analytics

Keep track of tool performance for troubleshooting and optimization via the Analytics tab. You can track total users, runs, tokens and errors, along with a breakdown of past runs. Generate AI reports and download logs for deeper analysis.

Faster creditworthiness assessments

AI can reduce the time to assess creditworthiness, helping your team build deals that are more relevant and less risky. The added deal velocity will translate into growth, agility, and greater capacity to handle demand.

Start automating this and other financial use cases with a free Stack AI account.

Make your organization smarter with AI.

Deploy custom AI Assistants, Chatbots, and Workflow Automations to make your company 10x more efficient.