Goals
- Use tool calling to build your own AI agent with Friendli Serverless Endpoints
- Check out the examples below to see how you can interact with state-of-the-art language models while letting them search the web, run Python code, etc.
- Feel free to make your own custom tools!
Getting Started
- Head to https://friendli.ai, and create an account.
- Grab a Friendli Token to use Friendli Serverless Endpoints within an agent.
Step 1. Playground UI
Experience tool calling on the Playground!

- On your left sidebar, click the ‘Serverless Endpoints’ option to access the playground page.
- You will see models that can be used as Serverless Endpoints. Choose the one you want and select the endpoint.
- Click ‘Tools’ button, select Search tool, and enter a query to see the response. 😀
Step 2. Tool Calling
Search interesting information using theweb:search
tool.
This time, let’s try it by writing python code.
- Add the user’s input as an
user
role message. - Add the
web:search
tool to the tools option.
Step 3. Multiple tool calling
Use multiple tools at once to calculate “How long it will take you to buy a house in the San Francisco Bay Area based on your annual salary”. Here is the available built-in tools.math:calculator
(tool for calculating arithmetic operations)web:search
(tool for retrieving data through the web search)code:python-interpreter
(tool for writing and executing python code)
Example Answer sheet
Step 4. Build a custom tool
Build your own creative tool. We will show you how to make a custom tool that retrieves temperature information. (Completed code snippet is provided at the bottom)- Define a function for using as a custom tool
-
Send a function calling inference request
- Add the user’s input as an
user
role message. - The information about the custom function (e.g.,
get_temperature
) goes into the tools option. The function’s parameters are described in JSON schema. - The response includes the
arguments
field, which are values extracted from the user’s input that can be used as parameters of the custom function.
- Add the user’s input as an
-
Generate the final response using the tool calling results
- Add the
tool_calls
response as anassistant
role message. - Add the result obtained by calling the
get_weather
function as atool
message to the Chat API again.
- Add the
-
Complete Code Snippet