Skip to content

Tool Calling

Enable AI models to use external functions by defining tool schemas using OpenAI format. Models can then call these functions automatically based on user requests.

Terminal window
curl --location 'http://localhost:8080/v1/chat/completions' \
--header 'Content-Type: application/json' \
--data '{
"model": "openai/gpt-4o-mini",
"messages": [
{"role": "user", "content": "What is 15 + 27? Use the calculator tool."}
],
"tools": [
{
"type": "function",
"function": {
"name": "calculator",
"description": "A calculator tool for basic arithmetic operations",
"parameters": {
"type": "object",
"properties": {
"operation": {
"type": "string",
"description": "The operation to perform",
"enum": ["add", "subtract", "multiply", "divide"]
},
"a": {
"type": "number",
"description": "The first number"
},
"b": {
"type": "number",
"description": "The second number"
}
},
"required": ["operation", "a", "b"]
}
}
}
],
"tool_choice": "auto"
}'

Response includes tool calls:

{
"choices": [{
"message": {
"role": "assistant",
"tool_calls": [{
"id": "call_abc123",
"type": "function",
"function": {
"name": "calculator",
"arguments": "{\"operation\":\"add\",\"a\":15,\"b\":27}"
}
}]
}
}]
}

Connect to Model Context Protocol (MCP) servers to give AI models access to external tools and services without manually defining each function.

MCP Configuration Interface

  1. Go to http://localhost:8080
  2. Navigate to “MCP Clients” in the sidebar
  3. Click “Add MCP Client”
  4. Enter server details and save

Read more about MCP connections and advanced end to end tool execution in the MCP Features section.

Control how the AI uses tools:

Terminal window
# Force use of specific tool
"tool_choice": {
"type": "function",
"function": {"name": "calculator"}
}
# Let AI decide automatically (default)
"tool_choice": "auto"
# Disable tool usage
"tool_choice": "none"

Now that you understand tool calling, explore these related topics: