# Tools and function calls

> Deepgram workshops › UC Berkeley AI workshop 2026 › Tools and function calls
> Web version: https://workshops.deepgram.com/events/uc-berkeley-2026/tools
> About 8 min.

A voice agent that can only talk is a chatbot with a mic and speakers. A voice agent that can call tools is an assistant. That's the single biggest jump you can make in capability.

### Learn why tools make your agent more capable {#why-tools}

**Goal:** Give your agent one tool it can call, and hear it use the result in its reply.

Without tools, your agent is limited to whatever the LLM already knows. It can talk about your company, but it can't look up an account. It can describe a calendar, but it can't book a meeting.

Tools let the model decide *"to answer this, I need to run a function and use the result."* The flow has four steps:

1. You define the functions.
2. Deepgram routes the call request back to you.
3. You execute the function and send the result back.
4. The model works that result into its reply.

### Define the function {#define-the-function}

Add your functions to the `think` settings under `functions`. Each function gets four parts:

- A name.
- A description, which the LLM reads to decide when to call it.
- A parameter schema in JSON Schema format.
- A `client_side` flag.

@tab python Python
```python
think = ThinkSettingsV1(
    provider=ThinkSettingsV1Provider_OpenAi(
        type="open_ai",
        model="gpt-4o-mini",
        temperature=0.7,
    ),
    prompt=(
        "You are a helpful AI assistant. Keep your responses brief. "
        "When the user asks for the current time, call the "
        "get_current_time function and read the result back to them."
    ),
    functions=[
        ThinkSettingsV1FunctionsItem(
            name="get_current_time",
            description="Returns the current local time as an ISO-8601 string.",
            parameters={
                "type": "object",
                "properties": {},
            },
            client_side=True,
        ),
    ],
)
```

@tab javascript JavaScript
```javascript
const think = {
  provider: {
    type:        "open_ai",
    model:       "gpt-4o-mini",
    temperature: 0.7,
  },
  prompt:
    "You are a helpful AI assistant. Keep your responses brief. " +
    "When the user asks for the current time, call the " +
    "get_current_time function and read the result back to them.",
  functions: [
    {
      name:        "get_current_time",
      description: "Returns the current local time as an ISO-8601 string.",
      parameters:  {
        type:       "object",
        properties: {},
      },
      client_side: true,
    },
  ],
};
```
:::

Keep three details in mind:

- The `description` matters. The LLM uses it to decide when to call the function, and vague descriptions lead to over-calling or under-calling.
- The `parameters` schema follows JSON Schema. For a no-argument function, an empty `properties` object is fine.
- `client_side: true` means *you* run the function. Deepgram sends you a `FunctionCallRequest` and waits for your response.

### Handle the call request {#handle-the-call}

Watch for `FunctionCallRequest` messages in your message handler. For each requested call, run the function and send back a `FunctionCallResponse`:

@tab python Python
```python
from datetime import datetime
from deepgram.agent.v1.types import AgentV1SendFunctionCallResponse

# Inside on_message:
elif message_type == "FunctionCallRequest":
    for call in getattr(message, "functions", []):
        if call.name == "get_current_time":
            result = datetime.now().isoformat(timespec="seconds")
            print(f">> Tool call: {call.name}() -> {result}")
            agent.send_function_call_response(
                AgentV1SendFunctionCallResponse(
                    id=call.id,
                    name=call.name,
                    content=result,
                ),
            )
```

@tab javascript JavaScript
```javascript
// Inside the message handler:
case "FunctionCallRequest":
  for (const call of message.functions ?? []) {
    if (call.name === "get_current_time") {
      const result = new Date().toISOString();
      console.log(`>> Tool call: ${call.name}() -> ${result}`);
      agent.sendFunctionCallResponse({
        id:      call.id,
        name:    call.name,
        content: result,
      });
    }
  }
  break;
```
:::

The model receives your `content` string as the function's return value and uses it to generate the spoken reply.

### Test it {#test-it}

Restart your agent and ask *"what time is it?"*

**You should see:** the agent's thinking event fire, the tool-call log line print in your terminal, and the agent speak the time back.

If the function is called too eagerly or not eagerly enough, change the prompt. Tell the LLM more explicitly when to call it, for example *"only call get_current_time if the user explicitly asks for the current time."*

### Going further {#going-further}

Once one function works, adding more is easy. Try one of these directions:

- **Look up data:** call your own backend API to fetch user-specific info.
- **Take an action:** send a Slack message, create a calendar event, file a ticket.
- **Compose multiple tools:** a single conversation can call several functions in sequence.

You can also use `client_side: false` for built-in helpers if Deepgram exposes them for your use case. Most real agents use client-side functions that call your own code.
