Skip to content

Guides

Tool calling

Let the model call functions you define: how each protocol writes it, one complete round trip, and what happens across protocols.

Tool calling (also called function calling) works like this: you first tell the model which functions are available. When it needs one, the model replies “please call this function with these arguments”. Your program runs the function and hands the result back, and the model uses it to give its final answer.

NoviaHub passes the tool fields to the model, and when a request has to be converted to another protocol, it rewrites them in that protocol’s format. How well a model uses tools, and which tool types it supports, depends on the model itself; see the vendor’s documentation.

Protocol Define tools Control whether tools are called
OpenAI Chat Completions tools tool_choice, parallel_tool_calls
OpenAI Responses tools tool_choice, parallel_tool_calls, max_tool_calls
Anthropic Messages tools tool_choice
Gemini tools (with functionDeclarations inside) toolConfig

All of these are passed to the model in the original protocol’s format.

One complete round trip (Chat Completions)

Section titled “One complete round trip (Chat Completions)”

Step 1: send the request with the tool definitions.

终端窗口
curl https://noviahub.com/v1/chat/completions \
-H "Authorization: Bearer $NOVIAHUB_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4-flash",
"messages": [{"role": "user", "content": "What is the weather in Paris right now?"}],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather in a city",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string", "description": "City name"}},
"required": ["city"]
}
}
}],
"tool_choice": "auto"
}'

Step 2: check whether the model wants a tool. If it decides to call one, choices[0].message in the response contains tool_calls. Each entry has the function name function.name, the arguments function.arguments (a JSON string) and an id.

Step 3: run the function and give the result back. Append two messages to the original messages, in this order:

  1. The assistant message the model returned, unchanged (including tool_calls).
  2. A message with role set to tool: put the id from step 2 in tool_call_id and the function’s result in content.

Then send the request again, and the model answers using the tool result. If it asks for another tool, repeat steps 2 and 3.

When you call a model through a protocol other than its own, NoviaHub converts the tool format automatically. We confirmed these cases in tests:

Your request Protocol the model actually uses What NoviaHub converts
Chat Completions tools, tool_choice: "auto" Anthropic (such as Claude models) function.parameters becomes input_schema, and tool_choice becomes {"type": "auto"}
Anthropic tools OpenAI Chat (such as DeepSeek models) input_schema becomes function.parameters
Gemini functionDeclarations OpenAI Chat They become function entries in tools

The response is converted too. For example, when you call a Claude model through Chat Completions, the tool_use Claude returns becomes Chat-format tool_calls, for both streaming and non-streaming responses.

For more conversion details and limits, see Protocol conversion.

  • The clearer a tool’s description and its parameter descriptions, the more likely the model calls it correctly.
  • function.arguments is text generated by the model. Parse it as JSON and validate it before use; never run it directly.
  • If you rely on tools, prefer models whose vendor states they support tool calling.