Tool Calling
The Siraya Model Router supports Anthropic-compatible function calling, allowing models to call tools and functions.
Example request
import os
import anthropic
client = anthropic.Anthropic(
api_key="<API_KEY>",
base_url='https://llm.siraya.ai'
)
message = client.messages.create(
model='claude-sonnet-4.5',
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)
import Anthropic from '@anthropic-ai/sdk';
const anthropic = new Anthropic({
apiKey: "<API_KEY>",
baseURL: 'https://llm.siraya.ai',
});
const message = await anthropic.messages.create({
model: 'claude-sonnet-4.5',
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));
Tool call response format
When the model makes tool calls, the response includes tool use blocks:
{
"id": "msg_281347a700a9a785a2bae2c8",
"content": [
{
"thinking": "The user is asking about the weather in San Francisco. I have access to the get_weather function which can provide this information. \n\nLet me check the required parameters:\n- location: required - I have this: \"San Francisco, CA\"\n- unit: optional - not specified by the user, so I'll leave it out and let the function use its default\n\nI should call the get_weather function with San Francisco as the location.",
"type": "thinking"
},
{
"id": "tooluse_rL4Jn2CRP0CPH49jfn0ugV",
"input": {
"location": "San Francisco, CA"
},
"name": "get_weather",
"type": "tool_use"
}
],
"model": "claude-sonnet-4.5",
"role": "assistant",
"stop_reason": "tool_use",
"stop_sequence": null,
"type": "message",
"usage": {
"input_tokens": 645,
"output_tokens": 156
}
}