Enable AI models to use external functions and services by defining tool schemas or connecting to Model Context Protocol (MCP) servers. This allows AI to interact with databases, APIs, file systems, and more.
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.
Copy
Ask AI
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"}'
# 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"