Best Practices
Essential best practices for building robust applications with FMP Tools.
Overview
Follow these best practices to build reliable, performant, and user-friendly applications with FMP Tools.
Tool Selection
Choose Only What You Need
Import only the tools you need to reduce bundle size and improve performance:
Group Related Tools
Combine tools that work well together:
Rate Limiting
Set Appropriate Limits
Use maxSteps or stopWhen to prevent excessive API calls:
Implement Caching
Cache frequently requested data to reduce API calls:
Error Handling
Always Implement Error Boundaries
Wrap your chat components with error boundaries:
Provide User-Friendly Messages
Show clear, actionable error messages:
User Experience
Loading States
Always show loading indicators during tool execution:
Clear Feedback
Let users know when tools are being used:
Performance Optimization
Lazy Load Tools
Load tools only when needed:
Optimize Model Configuration
Use appropriate model settings:
Security
Validate Inputs
Always validate user inputs before passing to tools:
Secure API Keys
Never expose API keys in client-side code:
Monitoring and Debugging
Log Tool Usage
Track which tools are being used:
Monitor Error Rates
Track errors to identify issues:
Summary
- Choose the right tools for your use case
- Implement proper rate limiting to avoid API limits
- Handle errors gracefully with user-friendly messages
- Optimize for performance with caching and lazy loading
- Monitor your application to identify issues early
- Test thoroughly before deploying to production
Next Steps
- Error Handling - Learn about comprehensive error handling
- Examples - See these practices in action
- Vercel AI SDK Integration - Learn about the integration