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:
2. Create API Route
3. Create Chat Component
4. Use in Your App
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 informationgetCompanySharesFloat
- Company shares float and liquidity datagetCompanyExecutiveCompensation
- 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 datagetSectorPerformance
- Sector performance datagetGainers
- Top gaining stocksgetLosers
- Top losing stocksgetMostActive
- Most actively traded stocks
🏛️ Economic Tools
getTreasuryRates
- Treasury rates and yieldsgetEconomicIndicators
- 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 ETFgetETFProfile
- ETF profile and information
📅 Calendar Tools
getEarningsCalendar
- Upcoming earnings calendargetEconomicCalendar
- Economic calendar events
🏛️ Congressional Tools
getSenateTrading
- Recent Senate trading activity by symbolgetHouseTrading
- Recent House trading activity by symbolgetSenateTradingByName
- Senate trading by politician namegetHouseTradingByName
- House trading by politician namegetSenateTradingRSSFeed
- Senate trading RSS feed with paginationgetHouseTradingRSSFeed
- 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 companygetStockSplits
- Historical stock splits for a companygetDividendHistory
- 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:
Custom Model Configuration
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 formatto
- End date in YYYY-MM-DD formatname
- 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
- View Tool Categories - Explore all available tools
- Check Examples - See practical implementations
- Best Practices - Learn best practices for building robust applications
- Error Handling - Learn about comprehensive error handling
- API Documentation - Learn about direct API access
- GitHub Repository - Source code and issues
Related Resources
- Vercel AI SDK Documentation - Official Vercel AI SDK docs
- OpenAI Platform - OpenAI API documentation
- Financial Modeling Prep - Get free API key (10% discount on paid plans)
- FMP API Documentation - FMP API documentation
Getting Started
Tool Reference
Advanced
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:
2. Create API Route
3. Create Chat Component
4. Use in Your App
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 informationgetCompanySharesFloat
- Company shares float and liquidity datagetCompanyExecutiveCompensation
- 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 datagetSectorPerformance
- Sector performance datagetGainers
- Top gaining stocksgetLosers
- Top losing stocksgetMostActive
- Most actively traded stocks
🏛️ Economic Tools
getTreasuryRates
- Treasury rates and yieldsgetEconomicIndicators
- 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 ETFgetETFProfile
- ETF profile and information
📅 Calendar Tools
getEarningsCalendar
- Upcoming earnings calendargetEconomicCalendar
- Economic calendar events
🏛️ Congressional Tools
getSenateTrading
- Recent Senate trading activity by symbolgetHouseTrading
- Recent House trading activity by symbolgetSenateTradingByName
- Senate trading by politician namegetHouseTradingByName
- House trading by politician namegetSenateTradingRSSFeed
- Senate trading RSS feed with paginationgetHouseTradingRSSFeed
- 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 companygetStockSplits
- Historical stock splits for a companygetDividendHistory
- 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:
Custom Model Configuration
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 formatto
- End date in YYYY-MM-DD formatname
- 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
- View Tool Categories - Explore all available tools
- Check Examples - See practical implementations
- Best Practices - Learn best practices for building robust applications
- Error Handling - Learn about comprehensive error handling
- API Documentation - Learn about direct API access
- GitHub Repository - Source code and issues
Related Resources
- Vercel AI SDK Documentation - Official Vercel AI SDK docs
- OpenAI Platform - OpenAI API documentation
- Financial Modeling Prep - Get free API key (10% discount on paid plans)
- FMP API Documentation - FMP API documentation