← Back to Home

FMP Tools Documentation

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:

app/api/chat/route.ts

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:

app/api/chat/route.ts

Security

Validate Inputs

Always validate user inputs before passing to tools:

Secure API Keys

Never expose API keys in client-side code:

.env.local

Monitoring and Debugging

Log Tool Usage

Track which tools are being used:

.env.local

Monitor Error Rates

Track errors to identify issues:

Summary

  1. Choose the right tools for your use case
  2. Implement proper rate limiting to avoid API limits
  3. Handle errors gracefully with user-friendly messages
  4. Optimize for performance with caching and lazy loading
  5. Monitor your application to identify issues early
  6. Test thoroughly before deploying to production

Next Steps