# Tool Calling

**The Infron supports Anthropic-compatible function calling**, allowing models to call tools and functions.

Example request

{% tabs %}
{% tab title="Python" %}

```python
import os
import anthropic
 
client = anthropic.Anthropic(
    api_key="<API_KEY>",
    base_url='https://llm.onerouter.pro'
)
 
message = client.messages.create(
    model='claude-sonnet-4-5@20250929',
    max_tokens=1024,
    tools=[
        {
            'name': 'get_weather',
            'description': 'Get the current weather in a given location',
            'input_schema': {
                'type': 'object',
                'properties': {
                    'location': {
                        'type': 'string',
                        'description': 'The city and state, e.g. San Francisco, CA'
                    },
                    'unit': {
                        'type': 'string',
                        'enum': ['celsius', 'fahrenheit'],
                        'description': 'The unit for temperature'
                    }
                },
                'required': ['location']
            }
        }
    ],
    messages=[
        {
            'role': 'user',
            'content': 'What is the weather like in San Francisco?'
        }
    ],
)
 
print('Response:', message.content)
```

{% endtab %}

{% tab title="TypeScript" %}

```typescript
import Anthropic from '@anthropic-ai/sdk';
 
const anthropic = new Anthropic({
  "<API_KEY>,
  baseURL: 'https://llm.onerouter.pro',
});
 
const message = await anthropic.messages.create({
  model: 'claude-sonnet-4-5@20250929',
  max_tokens: 1024,
  tools: [
    {
      name: 'get_weather',
      description: 'Get the current weather in a given location',
      input_schema: {
        type: 'object',
        properties: {
          location: {
            type: 'string',
            description: 'The city and state, e.g. San Francisco, CA',
          },
          unit: {
            type: 'string',
            enum: ['celsius', 'fahrenheit'],
            description: 'The unit for temperature',
          },
        },
        required: ['location'],
      },
    },
  ],
  messages: [
    {
      role: 'user',
      content: 'What is the weather like in San Francisco?',
    },
  ],
});
 
console.log('Response:', JSON.stringify(message.content, null, 2));
```

{% endtab %}
{% endtabs %}

**Tool call response format**

When the model makes tool calls, the response includes tool use blocks:

```json
{
  "id": "msg_bdrk_01TfRsaKQknpW7KvJ6GmRe14",
  "content": [
    {
      "id": "toolu_bdrk_018NGGhvJPRVPzme1rkv61JF",
      "input": {
        "location": "San Francisco, CA"
      },
      "name": "get_weather",
      "type": "tool_use"
    }
  ],
  "model": "claude-sonnet-4-5@20250929",
  "role": "assistant",
  "stop_reason": "tool_use",
  "stop_sequence": null,
  "type": "message",
  "usage": {
    "cache_creation_input_tokens": 0,
    "cache_read_input_tokens": 0,
    "input_tokens": 615,
    "output_tokens": 56,
    "server_tool_use": null,
    "service_tier": null,
    "cache_creation": {
      "ephemeral_1h_input_tokens": 0,
      "ephemeral_5m_input_tokens": 0
    }
  }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://infronai.gitbook.io/docs/llm-apis/anthropic-compatible-api/tool-calling.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
