# Tool Calling

Tool calling allows you to connect models to external tools and systems. This is useful for many things such as empowering AI assistants with capabilities, or building deep integrations between your applications and the models.

The Chat Completions API supports function calling. You can describe the functions and arguments to make available to the LLM model. The model will output a JSON object containing arguments to call one or many functions. After calling any invoked functions, you can provide those results back to the model in subsequent Chat Completions API calls.

````{only} internal
Coming soon, Imagine SDK will incorporate tools to interact with Qualcomm systems.
````

:::{dropdown} {octicon}`tools;1em;sd-text-info` Helper utilities for the examples
Some of the examples below use some of the code from `funcs.py`. This code is shown here to help understand better these examples.

```{literalinclude} ../../examples/sync/function_calling/funcs.py
```
:::

## Single Tool

The following example shows how to use tool calling capabilities of the chat method. (based on /chat/completions api endpoint)


```{literalinclude} ../../examples/sync/function_calling/00_single_tool.py
```

## Single Tool with helper functions

The following example shows how to use tool calling capabilities of the chat method using helper functions to create the schema instead of explicitly defining it.


```{literalinclude} ../../examples/sync/function_calling/01_single_tool_with_utils.py
```

## Multi-turn tool calling

This is a multi-turn tool calling example.

```{literalinclude} ../../examples/sync/function_calling/02_multi_turn_tools.py
```

## Multiple-tools tool calling

This is a tool calling example where we pass in multiple tools.

```{literalinclude} ../../examples/sync/function_calling/03_multiple_tools.py
```

## Multiple-tools recursive tool calling

This is a tool calling example showcasing the recursive multiple tool calling scenario.

```{literalinclude} ../../examples/sync/function_calling/04_multiple_recursive.py
```
