This feature works for both API Access and Dedicated Models.
Tool calling, also known as function calling, enables AI models to interact with external systems by invoking predefined functions or APIs. This allows the model to access up-to-date information, perform specific actions, or integrate with other services, extending its capabilities beyond static knowledge. Deploy custom fine-tuned models with proprietary tool definitions for specialized use cases.
Here we provide a simple example of tool calling.
Use following request to create a function named get_weather.
curl -s -X POST 'https://api.redpill.ai/v1/chat/completions' \
-H 'Authorization: Bearer sk-xx' \
-H 'Content-Type: application/json' \
-d '{
"messages": [
{
"content": "What is the weather like in New York?",
"role": "user"
}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather in a specified city",
"parameters": {
"type": "object",
"properties": {
"city": {"type": "string"},
"metric": {"type": "string", "enum": ["celsius", "fahrenheit"]}
},
"required": ["city"]
}
}
}
],
"tool_choice": "auto",
"stream": false,
"model": "phala/qwen3-coder"
}'
Example response of tool calling request
Extract the tool id from the response, and in this example it would be chatcmpl-tool-471f2c795ab64a27ab671a9e302c94db.
Use the tool id extracted from previouse request to call the tool.
curl -s -X POST 'https://api.redpill.ai/v1/chat/completions' \
-H 'Authorization: Bearer sk-xx' \
-H 'Content-Type: application/json' \
-d '{
"messages": [
{"role": "user", "content": "What is the weather like in New York?"},
{
"role": "assistant",
"content": null,
"tool_calls": [
{
"id": "chatcmpl-tool-471f2c795ab64a27ab671a9e302c94db",
"type": "function",
"function": {
"name": "get_weather",
"arguments": "{\"city\": \"New York\", \"metric\": \"celsius\"}"
}
}
]
},
{
"role": "tool",
"content": "{\"city\": \"New York\", \"temperature\": 15, \"description\": \"clear sky\", \"metric\": \"celsius\"}",
"tool_call_id": "chatcmpl-tool-471f2c795ab64a27ab671a9e302c94db"
}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather in a specified city",
"parameters": {
"type": "object",
"properties": {
"city": {"type": "string"},
"metric": {"type": "string", "enum": ["celsius", "fahrenheit"]}
},
"required": ["city"]
}
}
}
],
"tool_choice": "auto",
"stream": false,
"model": "phala/qwen3-coder"
}'
Example response of invoke the tool
Supported Models
phala/deepseek-chat-v3-0324
phala/qwen3-coder
phala/llama-3.3-70b-instruct