Tool Calling
The OpenResponses API supports tool calling to give models access to external functions. Define tools in your request with a name, description, and JSON schema for parameters. When the model determines it needs a tool to answer the user's question, it returns a function_call output with the tool name and arguments for you to execute.
import requests
import json
url = "https://llm.siraya.ai/v1/responses"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer <API_KEY>",
}
data = {
"model": "gemini-2.5-pro",
"input": [
{
"type": "message",
"role": "user",
"content": "What is the weather like in New York?",
}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather in a location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA",
},
},
"required": ["location"],
},
},
}
],
"tool_choice": "auto",
}
response = requests.post(url, headers=headers, json=data)
response.raise_for_status()
result = response.json()
print(json.dumps(result, indent=2))
const response = await fetch('https://llm.siraya.ai/v1/responses', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer <API_KEY>`,
},
body: JSON.stringify({
model: 'gemini-2.5-pro',
input: [
{
type: 'message',
role: 'user',
content: 'What is the weather like in New York?',
},
],
tools: [
{
type: 'function',
function: {
name: 'get_weather',
description: 'Get the current weather in a location',
parameters: {
type: 'object',
properties: {
location: {
type: 'string',
description: 'The city and state, e.g. San Francisco, CA',
},
},
required: ['location'],
},
},
},
],
tool_choice: 'auto',
}),
});
Tool call response
When the model decides to call a tool, the response includes a function_call output:
{
"id": "resp_chatcmpl-vertexai-abcdefghijklmnopqrstuvwx",
"object": "response",
"created_at": 1774723206,
"status": "completed",
"model": "gemini-2.5-pro",
"output": [
{
"type": "function_call",
"id": "call_abcdefghijklmnopqrstuvwx",
"status": "completed",
"call_id": "call_abcdefghijklmnopqrstuvwx",
"name": "get_weather",
"arguments": "{\"location\":\"New York\"}"
}
],
"usage": {
"input_tokens": 23,
"output_tokens": 61,
"total_tokens": 84,
"output_tokens_details": {
"reasoning_tokens": 55
}
}
}
Tool choice options
auto- The model decides whether to call a toolrequired- The model must call at least one toolnone- The model cannot call any tools