Core concepts
Tool & function calling
Models can call tools to fetch data or take actions. The engine supports native function schemas as well as in-stream tool detection.
Native function schemas
Declare functions in a tools array. When the model decides to use one, it stops generating text and returns the function name and arguments for you to execute.
json
{
"name": "run_javascript",
"description": "Executes JavaScript in a sandbox",
"parameters": {
"type": "object",
"properties": {
"code": { "type": "string", "description": "JS script text" }
},
"required": ["code"]
}
}The tool loop
The orchestration follows a simple loop:
- Match — the engine detects a tool call in the stream.
- Execute — generation halts and the requested tool runs.
- Format — the result is wrapped as a system message.
- Resume — the result is appended to context and generation continues.
json
{ "role": "system", "content": "[TOOL RESULT: Weather in New Delhi is 32°C]" }Built-in tools
Standard dialogue completions can also trigger built-in tools by emitting a structured call in the stream:
json
{ "tool": "WebSearch-1", "query": "current weather in New Delhi" }WebSearch-1— live web search and synthesis.search_internet— general internet lookup.run_javascript— execute code in a sandbox.
Streaming notifications
When streaming, a tool_call event is emitted so your UI can show that a tool is running before the final answer arrives. See /docs/streaming.