FMP Tools Documentation
OpenAI Agents Integration
Learn how to integrate FMP Tools with OpenAI Agents to create autonomous AI agents with financial data capabilities.
Overview
The OpenAI Agents integration allows you to build sophisticated AI agents that can access real-time financial data. Perfect for creating autonomous financial analysis tools, investment research assistants, and market monitoring systems.
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 OpenAI Agents
- @openai/agents - Version 0.1.0 or 0.1.1 only (other versions are not compatible)
- zod - Version ^3.25.76 (required for schema validation)
Installation
Install the required packages:
⚠️ Important Version Requirements:
@openai/agents
: Must be exactly version 0.1.0 or 0.1.1zod
: Must be version ^3.25.76
Quick Start
1. Set Environment Variables
Create a .env.local
file in your project root:
2. Basic Usage with OpenAI Agents
3. Create Agent 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
Using Specific Tool Categories
Using Individual Tools
Custom Agent Configuration
Example Use Cases
Financial Analysis Assistant
Market Research Bot
Company Research Specialist
Tool Structure
All tools in the OpenAI provider are structured as arrays, making them easy to combine and filter:
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
Version Compatibility
OpenAI Agents Version Requirements
⚠️ Critical: FMP Tools only works with specific versions of @openai/agents
:
- ✅ Supported:
@openai/agents@0.1.0
and@openai/agents@0.1.1
- ❌ Not Supported: Any other versions (including newer versions)
Zod Version Requirements
⚠️ Important: The zod
package must be compatible with the schema validation:
- ✅ Supported:
zod@^3.25.76
orzod@^4.0.0
- ❌ Not Supported: Older versions of zod
Common Installation Issues
If you encounter errors like:
Invalid schema for function 'getStockQuote': schema must be a JSON Schema of 'type: "object"'
Module not found: @openai/agents
TypeError: Cannot read property 'tool' of undefined
Solution: Ensure you're using the exact versions specified above.
Performance Considerations
- Tool Selection: Only include the tools you need to reduce agent complexity
- Rate Limiting: Be mindful of FMP API rate limits in production
- Caching: Consider implementing caching for frequently requested data
Migration from Vercel AI
If you're migrating from the Vercel AI provider:
- Import Changes: Change from
fmp-ai-tools/vercel-ai
tofmp-ai-tools/openai
- Tool Usage: Tools are now arrays instead of objects
- Framework: Use OpenAI Agents instead of Vercel AI SDK
Next Steps
- View Vercel AI Provider - For Vercel AI SDK usage
- Check out Examples - See practical implementations
- Explore Tool Categories - Detailed tool documentation
- Error Handling Guide - Best practices for error handling
- API Documentation - Learn about direct API access
- GitHub Repository - Source code and issues
Related Resources
- OpenAI Agents Documentation - Official OpenAI Agents 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
OpenAI Agents Integration
Learn how to integrate FMP Tools with OpenAI Agents to create autonomous AI agents with financial data capabilities.
Overview
The OpenAI Agents integration allows you to build sophisticated AI agents that can access real-time financial data. Perfect for creating autonomous financial analysis tools, investment research assistants, and market monitoring systems.
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 OpenAI Agents
- @openai/agents - Version 0.1.0 or 0.1.1 only (other versions are not compatible)
- zod - Version ^3.25.76 (required for schema validation)
Installation
Install the required packages:
⚠️ Important Version Requirements:
@openai/agents
: Must be exactly version 0.1.0 or 0.1.1zod
: Must be version ^3.25.76
Quick Start
1. Set Environment Variables
Create a .env.local
file in your project root:
2. Basic Usage with OpenAI Agents
3. Create Agent 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
Using Specific Tool Categories
Using Individual Tools
Custom Agent Configuration
Example Use Cases
Financial Analysis Assistant
Market Research Bot
Company Research Specialist
Tool Structure
All tools in the OpenAI provider are structured as arrays, making them easy to combine and filter:
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
Version Compatibility
OpenAI Agents Version Requirements
⚠️ Critical: FMP Tools only works with specific versions of @openai/agents
:
- ✅ Supported:
@openai/agents@0.1.0
and@openai/agents@0.1.1
- ❌ Not Supported: Any other versions (including newer versions)
Zod Version Requirements
⚠️ Important: The zod
package must be compatible with the schema validation:
- ✅ Supported:
zod@^3.25.76
orzod@^4.0.0
- ❌ Not Supported: Older versions of zod
Common Installation Issues
If you encounter errors like:
Invalid schema for function 'getStockQuote': schema must be a JSON Schema of 'type: "object"'
Module not found: @openai/agents
TypeError: Cannot read property 'tool' of undefined
Solution: Ensure you're using the exact versions specified above.
Performance Considerations
- Tool Selection: Only include the tools you need to reduce agent complexity
- Rate Limiting: Be mindful of FMP API rate limits in production
- Caching: Consider implementing caching for frequently requested data
Migration from Vercel AI
If you're migrating from the Vercel AI provider:
- Import Changes: Change from
fmp-ai-tools/vercel-ai
tofmp-ai-tools/openai
- Tool Usage: Tools are now arrays instead of objects
- Framework: Use OpenAI Agents instead of Vercel AI SDK
Next Steps
- View Vercel AI Provider - For Vercel AI SDK usage
- Check out Examples - See practical implementations
- Explore Tool Categories - Detailed tool documentation
- Error Handling Guide - Best practices for error handling
- API Documentation - Learn about direct API access
- GitHub Repository - Source code and issues
Related Resources
- OpenAI Agents Documentation - Official OpenAI Agents docs
- OpenAI Platform - OpenAI API documentation
- Financial Modeling Prep - Get free API key (10% discount on paid plans)
- FMP API Documentation - FMP API documentation