Tool calling
Tool calling follows each protocol's official format: OpenAI tools and tool_calls, Anthropic tools with tool_use / tool_result, Gemini functionDeclarations with functionCall / functionResponse.
curl https://modelportal.ai/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "MODEL_ID",
"messages": [{"role": "user", "content": "What is the weather in Shanghai today?"}],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Look up the weather for a city",
"parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}
}
}]
}'
When the model decides to call a tool, choices[0].message.tool_calls holds the function name and arguments. Run the function, append the result as a role: "tool" message with its tool_call_id, and send the request again.
How the platform handles it
- A request with tool definitions is routed only to endpoints that declare tool calling; if none do, you get 400
unsupported_parameter. Capability tags and the endpoint list on the model page show which endpoints qualify. - If the serving endpoint speaks another protocol, the platform converts it, and you still receive tool calls in the format of the protocol you used.
- In multi-turn tool use over the Anthropic protocol, when you send back signed thinking blocks, later requests go only to the endpoint that produced the signature. If it is unavailable you get 422 with the reason code
session, asking you to start a new session.