Tool Calling
Learn how to use function calling capabilities with Tinfoil’s AI models for enhanced functionality.
Function Calling
Function calling (also known as tool calling) allows AI models to interact with external tools and APIs, enabling them to perform actions beyond text generation. This powerful feature lets you build AI applications that can fetch real-time data, perform calculations, and integrate with your existing systems.
Model Performance: All chat models support function calling, but Qwen 2.5 72B offers exceptional tool calling capabilities and provides the most reliable results. While other models can handle function calling, Qwen is specifically optimized for complex tool workflows.
Basic Example
Here’s a simple example of how to implement function calling with a weather API:
Multiple Tools Example
You can define multiple tools for more complex workflows:
Best Practices
- Choose the Right Model: Qwen 2.5 72B provides the most reliable function calling capabilities
- Clear Descriptions: Write detailed function descriptions to help the model understand when to use each tool
- Parameter Validation: Always validate function parameters before execution
- Error Handling: Implement proper error handling for function calls
- Security: Never execute untrusted code - validate all function arguments
- Testing: Test your functions independently before integrating with the AI model
Common Use Cases
- API Integration: Fetch real-time data from external APIs
- Database Queries: Retrieve information from your databases
- Calculations: Perform complex mathematical operations
- File Operations: Read, write, or process files
- System Commands: Execute system operations (with proper security measures)
- Third-party Services: Integrate with external services and platforms
Model Comparison
Model | Function Calling Support | Reliability | Best For |
---|---|---|---|
Qwen 2.5 72B | ✅ Excellent | Very High | Complex tool workflows, multiple functions |
Mistral Small 3.1 24B | ✅ Good | High | Simple to moderate tool calling |
DeepSeek R1 70B | ✅ Basic | Moderate | Simple function calls, reasoning tasks |
Llama 3.3 70B | ✅ Basic | Moderate | Simple function calls, conversational AI |