Skip to main content
FriendliAI provides OpenAI-compatible tool calling with two core guarantees:
  • Broad model coverage: Works across most chat‑capable models. No custom parsers required.
  • High accuracy: Ensures reliable tool-call responses that align with your provided schemas.

What Is Tool Calling

Tool calling (also called function calling) connects LLMs to external systems, enabling real‑time data access and action execution—a capability essential for agentic workflows.
Function calling

Broad Model Coverage

FriendliAI supports tool calling for a wide range of open‑source and commercial models.
You can browse available models on our Models page and try them out with the Playground.

Tool Calling with FriendliAI

Tool Calling Parameters

To enable tool calling, use the tools, tool_choice, and parallel_tool_calls parameters. By default, the model decides whether to call a function and which one to use. With the tool_choice parameter, you can explicitly instruct the model to use a specific function.
  • none: Disable the use of tools.
  • auto: Enable the model to decide whether to use tools and which ones to use.
  • required: Force the model to use a tool, but the model chooses which one.
  • Named tool choice: Force the model to use a specific tool. It must be in the following format:

Response Schema

FriendliAI follows the OpenAI function calling schema. Tool calls are returned in choices[].message.tool_calls[] with each item containing a function.name and JSON‑stringified function.arguments. After executing a tool, append a new message with role: tool, the matching tool_call_id, and the tool result in content.

Simple Example

The example below walks through five steps:
  1. Define a tool (get_weather) that retrieves weather information.
  2. Ask a question that triggers tool use.
  3. Let the model select the tool.
  4. Execute the tool.
  5. Generate the final answer using the tool result.
Open In Colab
1

Tool Definition

Define a function that the model can call (get_weather) with a JSON Schema.The function requires the following parameters:
  • location: The location to look up weather information for.
  • date: The date to look up weather information for.
This definition is included in the tools array and passed to the model.
2

Calling the Model

When a user asks a question, this request is passed to the model as a messages array. For example, the request “What’s the weather like in Paris today?” would be passed as:
Call the model using the tools and messages defined above.
3

Executing the Tool

The API caller runs the tool based on the function call information of the model. For example, the get_weather function is executed as follows:
Result:
4

Adding Tool Responses

Add the tool’s response to the messages array and pass it back to the model.
  1. Append tool call information
  2. Append the tool’s execution result
This ensures the model has all the necessary information to generate a response.
5

Generating the Final Response

The model generates the final response based on the tool’s output:
Final output:

Advanced Examples

Follow these blog posts to learn more about how to use tool calling with FriendliAI:
Last modified on July 20, 2026