---
title: Function calling & tools
description: Tool-calling formats for Chat Completions, Responses, and Messages on CrossModel.
---

# 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

```json
{
  "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:

```json
{
  "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`:

```json
{
  "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

1. Keep tool names stable, using lowercase letters, digits, and underscores.
2. Make the `description` say clearly when the tool should be called.
3. Make `parameters` / `input_schema` as complete as possible so the model generates fewer invalid arguments.
4. When a tool fails, return the error as the tool result rather than dropping it from the context.
