Skip to main content

Function Calling

Function calling (also known as tool calling) lets AI models invoke external tools and APIs — fetching real-time data, performing calculations, or integrating with your existing systems.
Model Performance: Most chat models support function calling. Kimi K3 is recommended for agentic workflows and complex tool calling scenarios.

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

  1. Choose the Right Model: Among the models offered on Tinfoil API, Kimi K3 is recommended for function calling and agentic workflows
  2. Clear Descriptions: Write detailed function descriptions to help the model understand when to use each tool
  3. Parameter Validation: Always validate function parameters before execution
  4. Error Handling: Implement proper error handling for function calls
  5. Security: Never execute untrusted code - validate all function arguments
  6. Testing: Test your functions independently before integrating with the AI model

Model catalog

View all available models and their capabilities.

Python SDK

Complete Python SDK documentation with more examples.