Extend Neosantara capabilities by enabling it to interact with external tools and functions.
Provide NeosantaraAI with tools and a user prompt
tools
parameter.NeosantaraAI decides to use a tool
tool_calls
object within its response, containing the name of the tool to be called and the arguments (input) for that tool.finish_reason
of tool_calls
.Execute the tool and return results
tool_calls
response.user
message with a tool
role, containing the tool_call_id
and the content
of the tool’s output.NeosantaraAI uses tool result to formulate a response
Single Tool Example
get_weather
function with the provided input, and return the result in a new user
message:Parallel Tool Use
tool_calls
blocks are included in a single assistant message, and all corresponding tool
results must be provided in the subsequent user message, each with its tool_call_id
.Missing Information
get_weather
tool, if you ask “What’s the weather?” without specifying a location, the model is likely to respond with a clarifying question instead of making a tool call.Sequential Tools
get_location_from_ip
tool to get the user’s location based on their IP, then passing that location to the get_weather
tool:get_location_from_ip
.tool
message with location.get_weather
with “Bandung, West Java”.tool
message with weather.JSON Mode
tool_choice
to {"type": "function", "function": {"name": "your_tool_name"}}
to explicitly instruct the model to use that tool.function
’s parameters
define the exact JSON schema the model should adhere to.record_summary
tool to describe an image following a particular JSON format. Note that this requires a model with vision capabilities (e.g., vision-emas-2045
).tool_calls
block:tools
parameter and tool call/result messages).tools
array in API requests (tool names, descriptions, and parameter schemas).tool_calls
generated by the model in assistant messages.tool
messages (containing tool_call_id
and content
) sent by your application.usage
metrics.