Skip to main content

1. Use Cases

The Function Calling feature allows the model to call external tools to enhance its capabilities. This functionality enables the model to act as a brain that calls external tools (such as searching for external knowledge, checking itineraries, or specific domain tools), effectively addressing issues like hallucinations and knowledge timeliness.

2. How to Use

2.1 Add tools parameters via REST API

Include the following in the request body:
For example, a complete payload:

2.2 Use with OpenAI Library

This feature is compatible with OpenAI. When using the OpenAI library, add the corresponding tools parameter as tools=[corresponding tools]. For example:

3. Supported Models

Currently supported models include:
  • Deepseek Series:
    • deepseek-ai/DeepSeek-R1
    • deepseek-ai/DeepSeek-V3
    • deepseek-ai/DeepSeek-R1-Distill-Qwen-32B
    • deepseek-ai/DeepSeek-R1-Distill-Qwen-14B
    • deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B
  • Qwen Series:
    • Qwen/Qwen2.5-72B-Instruct
    • Qwen/Qwen2.5-32B-Instruct
    • Qwen/Qwen2.5-14B-Instruct
    • Qwen/Qwen2.5-7B-Instruct
  • GLM Series:
    • THUDM/GLM-Z1-32B-0414
    • THUDM/GLM-4-32B-0414
    • THUDM/GLM-4-9B-0414
Note: The list of supported models is continuously updated. Please refer to this document for the latest list of supported models.

4. Examples

4.1 Example 1: Extending numerical computation capabilities of large language models via function calling

This code introduces four functions: addition, subtraction, comparison, and counting repeated letters in a string, demonstrating how function calling can address areas where large language models struggle, such as token prediction.
The model will output:

4.2 Example 2: Extending the model’s understanding of external environments through function calling

This code demonstrates querying external information using one function via an external API.
The model will output: