FI Calculator Guide
The FI Calculator is one of IndepAI’s most powerful tools. It calculates your path to Financial Independence based on your income, expenses, savings, and expected returns.
How It Works
Section titled “How It Works”The FI Calculator uses the following formula:
FI Number = Annual Expenses × FI MultiplierWhere the FI Multiplier is typically 25 (based on the 4% safe withdrawal rate):
FI Multiplier = 100 / Withdrawal Rate = 100 / 4 = 25To calculate years to FI, we use compound growth:
Years to FI = ln((FI Number × r + Savings) / (Current × r + Savings)) / ln(1 + r)Where r is the real return rate (nominal return - inflation).
Basic Usage
Section titled “Basic Usage”curl -X POST https://indepai.app/api/v1/calculator \ -H "Content-Type: application/json" \ -d '{ "currentAge": 30, "annualIncome": 80000, "annualExpenses": 40000, "currentSavings": 100000 }'Input Parameters
Section titled “Input Parameters”| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
currentAge | number | Yes | - | Your current age (18-100) |
annualIncome | number | Yes | - | Gross annual income |
annualExpenses | number | Yes | - | Total annual expenses |
currentSavings | number | Yes | - | Current invested assets |
targetWithdrawalRate | number | No | 4 | Safe withdrawal rate (%) |
expectedReturn | number | No | 7 | Expected annual return (%) |
inflationRate | number | No | 2 | Expected inflation rate (%) |
email | string | No | - | Email to associate with calculation |
saveResult | boolean | No | true | Save for analytics |
Response Fields
Section titled “Response Fields”| Field | Description |
|---|---|
fiNumber | Target amount needed for FI |
yearsToFI | Years until FI is reached |
fiAge | Age when you’ll reach FI |
fiDate | Projected FI date (ISO 8601) |
savingsRate | Current savings rate (%) |
monthlySavings | Monthly savings amount |
annualSavings | Annual savings amount |
currentProgress | Current progress toward FI (%) |
yearlyProjections | Year-by-year wealth projections |
Advanced Examples
Section titled “Advanced Examples”Different Withdrawal Rates
Section titled “Different Withdrawal Rates”For early retirement (more conservative 3% rate):
{ "currentAge": 28, "annualIncome": 100000, "annualExpenses": 35000, "currentSavings": 200000, "targetWithdrawalRate": 3}This increases your FI Number to 33.3× expenses instead of 25×.
Aggressive Returns
Section titled “Aggressive Returns”If you expect higher returns (e.g., 100% stocks):
{ "currentAge": 25, "annualIncome": 60000, "annualExpenses": 30000, "currentSavings": 50000, "expectedReturn": 10, "inflationRate": 2}Conservative Scenario
Section titled “Conservative Scenario”Planning for lower returns and higher inflation:
{ "currentAge": 35, "annualIncome": 90000, "annualExpenses": 45000, "currentSavings": 150000, "expectedReturn": 5, "inflationRate": 3}Understanding the Projections
Section titled “Understanding the Projections”The yearlyProjections array shows your wealth trajectory:
{ "yearlyProjections": [ { "year": 0, "age": 30, "netWorth": 100000, "totalContributions": 100000, "totalGains": 0, "progressPercent": 10.0, "fiReached": false }, { "year": 1, "age": 31, "netWorth": 145000, "totalContributions": 140000, "totalGains": 5000, "progressPercent": 14.5, "fiReached": false } // ... continues until FI + buffer ]}Use Cases
Section titled “Use Cases”1. Building a FIRE Calculator Widget
Section titled “1. Building a FIRE Calculator Widget”async function calculateFI(userInput) { const response = await fetch("https://indepai.app/api/v1/calculator", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(userInput), });
const result = await response.json();
if (result.success) { return { targetAmount: result.data.fiNumber, yearsRemaining: result.data.yearsToFI, retirementAge: result.data.fiAge, savingsRate: result.data.savingsRate, }; }
throw new Error(result.error);}2. Scenario Comparison
Section titled “2. Scenario Comparison”Compare different scenarios:
const scenarios = [ { name: "Current", expenses: 40000 }, { name: "Frugal", expenses: 30000 }, { name: "Comfortable", expenses: 50000 },];
const results = await Promise.all( scenarios.map((s) => fetch("https://indepai.app/api/v1/calculator", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ currentAge: 30, annualIncome: 80000, annualExpenses: s.expenses, currentSavings: 100000, }), }).then((r) => r.json()) ));
// Display comparison tableresults.forEach((r, i) => { console.log(`${scenarios[i].name}: FI in ${r.data.yearsToFI} years`);});3. Charting Progress
Section titled “3. Charting Progress”Use the yearlyProjections to create a growth chart:
const { data } = await result.json();
// For Chart.js or similarconst chartData = { labels: data.yearlyProjections.map((p) => p.age), datasets: [ { label: "Net Worth", data: data.yearlyProjections.map((p) => p.netWorth), }, { label: "Contributions", data: data.yearlyProjections.map((p) => p.totalContributions), }, { label: "FI Target", data: data.yearlyProjections.map(() => data.fiNumber), borderDash: [5, 5], }, ],};Error Handling
Section titled “Error Handling”Common validation errors:
{ "success": false, "error": "Validation error", "code": "VALIDATION_ERROR", "details": [ { "path": "currentAge", "message": "Must be between 18 and 100" }, { "path": "annualExpenses", "message": "Must be greater than 0" } ]}Handle them gracefully:
const result = await response.json();
if (!result.success) { if (result.code === "VALIDATION_ERROR") { result.details.forEach((err) => { showFieldError(err.path, err.message); }); } else { showGeneralError(result.error); } return;}Rate Limits
Section titled “Rate Limits”The calculator endpoint has these limits:
| Tier | Requests/Day |
|---|---|
| Starter | 1,000 |
| Pro | 10,000 |
Check rate limit headers:
X-RateLimit-Limit: 100X-RateLimit-Remaining: 95X-RateLimit-Reset: 1705312800Related Endpoints
Section titled “Related Endpoints”- Portfolio Health - Analyze your investments
- City Recommendations - Find cheaper places to live
- Tax Calculator - Understand tax implications