Tool Calling (Function Calling)
Tool calling allows models to invoke external functions, APIs, and tools during a conversation. The model decides when to call a function based on the userβs message and returns structured arguments you can use to execute the function in your application.The Morpheus Inference API is fully OpenAI-compatible β tool calling works exactly like OpenAIβs function calling API. If youβve used OpenAI tools before, you already know how to use this.
Supported Models
Most models on the Morpheus API support function calling. See the Available Models page for the full list β look for the Function Calling capability. Popular choices for tool calling:How It Works
- Define tools β Describe available functions with names, descriptions, and JSON Schema parameters
- Send request β Include tools in your chat completion request
- Model responds β The model either answers directly or returns a
tool_callsarray with function names and arguments - Execute functions β Run the requested functions in your application
- Return results β Send function results back to the model for a final response
Basic Example
Define a tool and let the model decide when to call it:- curl
- Python
- JavaScript
- TypeScript
Complete Tool Calling Loop
In a real application, you execute the function and send the result back to the model:- Python
- JavaScript
Response Format
When a model decides to call a tool, the response includes atool_calls array:
When
finish_reason is "tool_calls", the model is requesting function execution. The content field may contain a brief message or be null β always check for tool_calls first regardless of whether content is present.Multiple Tools
You can define multiple tools and the model will choose which to call:Tips
Write clear function descriptions
Write clear function descriptions
The model uses the
description field to decide when to call a function. Be specific about what the function does and when it should be used.Use detailed parameter descriptions
Use detailed parameter descriptions
Help the model provide the right arguments by describing each parameter clearly, including format expectations and valid values.
Handle the tool call loop
Handle the tool call loop
Always check
finish_reason β if itβs "tool_calls", execute the functions and send results back. The model may call multiple functions in sequence before giving a final answer.Next Steps
Available Models
See which models support function calling.
Chat Completions API
Full API reference for chat completions.
Vision Guide
Send images to vision-capable models.
Quickstart
Get started with your first API call.

