Tool Calling
Tool calling in ASI:One allows models to go beyond text generation by invoking external functions with the right parameters. This enables integration with APIs, tools, or your own code to retrieve live data, perform tasks, or trigger actions based on user input.
Overview
Tool calling connects your own code to ASI:One. When given access to defined tools, the model can choose to call them based on the conversation context. You then execute the corresponding code, return the results, and the model incorporates the output into its final reply.
It works on both /v1/chat/completions and /v1/responses. The examples on this page use /v1/chat/completions; see On the Responses API for what changes on the other endpoint.
A basic tool-calling request:
cURL
Python
Example response
The model replies with the tool call rather than an answer:
Sample tools
The walkthrough below uses a real get_weather tool. Implement it in your own codebase:
Complete tool execution cycle
The full cycle, using the weather example. Every step below builds on this setup:
Step 1: Initial request with tools
Send the tool definition alongside the user’s message:
Step 2: Parse tool calls from the response
The model responds with a tool call to parse:
Step 3: Execute tools and format results
Execute the tool and format the result. get_weather is the function defined in
Sample tools above:
Step 4: Send results back to the model
Send the tool result back to the model:
Step 5: Receive the final answer
The model now answers, incorporating the tool result:
Tool result handling
Here are key guidelines to ensure correct behavior and prevent common errors.
Preserving Tool Call IDs
Each tool call comes with a unique id that must be preserved when sending results back.
Message History Order
The message history must maintain this exact order:
- Original user message
- Assistant message with
tool_calls(content should be null or empty) - Tool result messages (one for each tool_call, identified by
tool_call_id)
Content Formatting
Tool results must be JSON-stringified within the content field.
Error Handling
If a tool fails, send back a result message indicating the error.
Tool definition
Functions are specified using the tools parameter in each API request, where each tool is described as a function object.
Each function is defined using a schema that tells the model what the function does and what input arguments it requires. The schema includes the following key fields:
-
name(string) : A unique, descriptive identifier for the tool (e.g.,get_weather_forecast,send_email). Use underscores or camelCase formatting. Avoid spaces or special characters. -
description(string) : A detailed explanation of what the tool does and when it should be used. Clear, specific descriptions improve the model’s ability to use the function correctly. -
parameters(object) : Defines the input parameters the tool expects.-
type(string) : Usually set to"object"to represent input parameters. -
properties(object) : Lists each input parameter and its details: -
type(string): The data type (e.g.,string,integer,boolean,array). -
description(string): A clear explanation of the parameter’s purpose and expected format. Example:"City and country, e.g., 'Paris, France'" -
enum(optional): An array of allowed values, useful when inputs must be restricted. Example:"enum": ["celsius", "fahrenheit"] -
required(array of strings) : Lists the parameter names that must be included when calling the function.
-
The get_weather definition used throughout this page is a minimal example of
that shape. Descriptions are the part worth spending time on: the model chooses
which tool to call, and what to pass it, from your prose alone.
Additional configurations
ASI:One provides several options to control how and when tools are called, as well as how strictly the model adheres to your function schemas.
Tool choice
By default, the model determines when and how many tools to use. You can control this behavior with the tool_choice parameter:
- Auto (default): The model may call zero, one, or multiple functions.
- Required: The model must call at least one function.
- Forced Function: Force the model to call a specific function.
- None: Prevent the model from calling any functions.
Parallel tool calling
By default, the model may call multiple functions in a single turn. To restrict it
to one at a time, send parallel_tool_calls, which both endpoints take:
Handle multiple tool_calls in one response whichever endpoint you use. A model
that can gather several pieces of information at once will usually do so, and
that is normally what you want.
Strict mode
Setting strict to true makes the model follow your schema exactly rather than
treating it as a strong suggestion. Enable it unless you have a reason not to.
Two things are required alongside it:
additionalPropertiesmust befalseon every object insideparameters.- Every key in
propertiesmust be listed inrequired.
Here is the same get_weather tool with strict mode on, plus an optional units
parameter to show what that second requirement means in practice:
Strict mode leaves no room for a parameter the model may simply omit. Widen an
optional one to accept "null", list it in required like any other, and treat
null as “not supplied” in your own code.
On the Responses API
Everything above uses /v1/chat/completions. Tool calling works the same way on
/v1/responses, with three differences:
-
Tools may use the flat shape.
/v1/responsesaccepts OpenAI’s Responses form, wherename,descriptionandparameterssit at the top level of the tool object instead of inside a nestedfunctionobject. The nested Chat Completions shape is accepted too, so an existing tool definition keeps working. -
Only
functiontools are supported. Any other tool type is rejected with a400.
tool_choice, strict and parallel_tool_calls behave identically on both
endpoints.
Next steps
- Structured Data - Make the model’s reply conform to a JSON schema
- Chat Completions API - How tool calls arrive when you stream the reply
- Planner Mode - Let ASI:One plan and run multi-step work against agents and tools
- Using ASI:One with LangChain - Bind tools with
@toolinstead of raw JSON schemas