← Back to Home

FMP Tools Documentation

Vercel AI SDK Integration

Learn how to integrate FMP Tools with Vercel AI SDK to create AI-powered financial applications.

Overview

The Vercel AI SDK integration provides a seamless way to add financial data capabilities to your AI applications. With just a few lines of code, you can enable your chatbots and assistants to access real-time financial data.

Prerequisites

Before you begin, make sure you have:

  • FMP API Key - Get your free API key from Financial Modeling Prep (10% discount on paid plans)
  • OpenAI API Key - Required for the AI model (get from OpenAI Platform)
  • Node.js 18+ - Required for Vercel AI SDK
  • zod - Version ^3.25.76 (required for schema validation)

Installation

Install the required packages:

⚠️ Version Requirements:

  • zod: Must be version ^3.25.76

Quick Start

1. Set Environment Variables

Create a .env.local file in your project root:

.env.local

2. Create API Route

app/api/chat/route.ts

3. Create Chat Component

components/chat.tsx

4. Use in Your App

app/page.tsx

Available Tools

FMP Tools provides comprehensive financial tools organized into categories:

📊 Quote Tools

  • getStockQuote - Real-time stock quotes and price data

🏢 Company Tools

  • getCompanyProfile - Comprehensive company profiles and information
  • getCompanySharesFloat - Company shares float and liquidity data
  • getCompanyExecutiveCompensation - Executive compensation information

💰 Financial Tools

  • getBalanceSheet - Balance sheet statements (annual/quarterly)
  • getIncomeStatement - Income statements (annual/quarterly)
  • getCashFlowStatement - Cash flow statements (annual/quarterly)
  • getKeyMetrics - Key financial metrics and KPIs (annual/quarterly)
  • getFinancialRatios - Financial ratios and metrics (annual/quarterly)
  • getEnterpriseValue - Enterprise value calculations (annual/quarterly)
  • getCashflowGrowth - Cash flow growth analysis (annual/quarterly)
  • getIncomeGrowth - Income growth analysis (annual/quarterly)

📈 Market Tools

  • getMarketPerformance - Overall market performance data
  • getSectorPerformance - Sector performance data
  • getGainers - Top gaining stocks
  • getLosers - Top losing stocks
  • getMostActive - Most actively traded stocks

🏛️ Economic Tools

  • getTreasuryRates - Treasury rates and yields
  • getEconomicIndicators - Economic indicators including GDP, CPI, unemployment, inflation, retail sales, consumer sentiment, durable goods, housing starts, vehicle sales, and more

📋 ETF Tools

  • getETFHoldings - Holdings for a specific ETF
  • getETFProfile - ETF profile and information

📅 Calendar Tools

  • getEarningsCalendar - Upcoming earnings calendar
  • getEconomicCalendar - Economic calendar events

🏛️ Congressional Tools

  • getSenateTrading - Recent Senate trading activity by symbol
  • getHouseTrading - Recent House trading activity by symbol
  • getSenateTradingByName - Senate trading by politician name
  • getHouseTradingByName - House trading by politician name
  • getSenateTradingRSSFeed - Senate trading RSS feed with pagination
  • getHouseTradingRSSFeed - House trading RSS feed with pagination

🏢 Institutional Tools

  • getInstitutionalHolders - Institutional holders for a company

👤 Insider Tools

  • getInsiderTrading - Insider trading data for a company

📊 Stock Tools

  • getMarketCap - Market capitalization for a company
  • getStockSplits - Historical stock splits for a company
  • getDividendHistory - Dividend history and payments for a company

View detailed tool categories →

Advanced Configuration

Custom Tool Selection

You can select specific tools instead of using all available tools:

app/api/chat/route.ts

Custom Model Configuration

app/api/chat/route.ts

Using Individual Tools

Example Conversations

Here are some example conversations you can have with your AI assistant:

Stock Analysis

User: "What's the current stock price of Apple and show me their latest financial ratios?"

Assistant: "Let me get that information for you. I'll check Apple's current stock quote and their latest financial ratios."

Market Research

User: "What are the top gaining stocks today and what's the overall market performance?"

Assistant: "I'll check the current market performance and identify the top gaining stocks for you today."

Economic Data

User: "What are the current treasury rates and the latest GDP data?"

Assistant: "Let me fetch the current treasury rates and the most recent GDP data for you."

Tool Parameters

Each tool accepts specific parameters. Here are some common ones:

  • symbol - Stock/ETF symbol (e.g., "AAPL", "SPY")
  • period - For financial statements: "annual" or "quarter"
  • from - Start date in YYYY-MM-DD format
  • to - End date in YYYY-MM-DD format
  • name - For economic indicators: specific indicator name

Error Handling

The tools include built-in error handling and validation:

  • Input Validation: All tools use Zod schemas to validate input parameters
  • API Error Handling: Graceful handling of FMP API errors and rate limits
  • User-Friendly Messages: Clear error messages for debugging and user feedback

Performance Considerations

  • Tool Selection: Only include the tools you need to reduce complexity
  • Rate Limiting: Be mindful of FMP API rate limits in production
  • Caching: Consider implementing caching for frequently requested data

Next Steps

Related Resources