Function calling & tools
Tool calling lets a model return a structured function request when it needs one; your app runs the function and passes the result back. CrossModel supports both OpenAI- and Anthropic-style tool definitions.
Chat Completions
{
"model": "deepseek/deepseek-v4-pro",
"messages": [
{ "role": "user", "content": "What's the temperature in Shanghai today?" }
],
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get current weather for a city.",
"parameters": {
"type": "object",
"properties": {
"city": { "type": "string" }
},
"required": ["city"]
}
}
}
],
"tool_choice": "auto"
}The model may return tool_calls. After running the function, append the result as a role: "tool" message in your next request.
Responses
Responses puts function tools directly in the tools array:
{
"model": "openai/gpt-5-mini",
"input": "What's the temperature in Shanghai today?",
"tools": [
{
"type": "function",
"name": "get_weather",
"parameters": {
"type": "object",
"properties": {
"city": { "type": "string" }
},
"required": ["city"]
}
}
]
}The model may return a function_call item in output. After running the function, continue with function_call_output.
Messages
Anthropic Messages uses input_schema:
{
"model": "anthropic/claude-sonnet-4.6",
"max_tokens": 1024,
"messages": [
{ "role": "user", "content": "What's the temperature in Shanghai today?" }
],
"tools": [
{
"name": "get_weather",
"description": "Get current weather for a city.",
"input_schema": {
"type": "object",
"properties": {
"city": { "type": "string" }
},
"required": ["city"]
}
}
]
}The model may return a tool_use content block. After running the function, pass the result back as a tool_result content block.
Tips
- Keep tool names stable, using lowercase letters, digits, and underscores.
- Make the
descriptionsay clearly when the tool should be called. - Make
parameters/input_schemaas complete as possible so the model generates fewer invalid arguments. - When a tool fails, return the error as the tool result rather than dropping it from the context.