How to Give AI Superpowers: Function Calling

Notes from the AI Study Group - AI Agents - Part 1 Workshop

AIFunction CallingAPIWorkshopAI Agents
Published: 2025-06-29

How do we access AI like ChatGPT in our applications or tools?

ChatGPT, Gemini, or any AI model cost $100M+ to develop. Currently, you might be using them through their chat platforms. But there is another way of using them.

You can bring them in your applications through code. You can access them on pay-per-usage basis. The way to bring it is called API.

APIs are like plumbing pipes or electric wires: they connect you to the main power supply. API key is the password. Keep it secure, never share or display it publicly.

API Superpowers

Batch Processing: Process 100 files in parallel instead of one by one. What takes a full day manually happens in minutes.

App Integration: Build AI directly into your applications. Your app calls AI, gets responses, and continues working.

Function Calling: AI calls your functions and accesses different applications on your behalf.

What if AI could take actions instead of just chatting?

AI Function Calls, Tool Calls, and Agentic AI all describe the same thing: giving AI the ability to use external tools and take actions beyond chat.

Regular AI can only respond with text. Function calling lets AI execute code, access APIs, and interact with your computer systems. Instead of just knowing about things, AI can actually do things.

The Grocery Shopping Analogy

Think of telling someone to go to DMart with and buy 1 kg tomatoes, 2kg Onions and Brinjal 3kg." You write location and items in a structured way someone else can understand:

``` Store: DMart Items: - Tomatoes: 1kg - Onions: 2kg
- Brinjal: 3kg

```

Now, consider doing the same thing on Swiggy. You have to type your home address, and select this item list. A developer will have to write the code or function to take action on your behalf: select a person, give them this shopping list, give them your address, and deliver groceries to your doorstep. A lot of it is developed by the developer, in code. But you still manually need to select the item list and saved address.

What if you have an AI chatbot, whom you can say "do it for me" like you say to a person: "Please place an order for 1kg tomatoes, 2kg onions, and 3kg brinjal." AI converts your unstructured request into structured data that Swiggy's system understands.

But someone still needs to write the code that connects AI to Swiggy. That's what developing functions means: building these bridges between natural language and applications.

How AI Understands Your Intent

When you ask AI to do something, it:

  1. Understands the intent from your natural language
  2. Extracts key information from your request
  3. Selects the right tool based on intent descriptions
  4. Converts to structured parameters that your code can execute

AI reads the descriptions of all available tools and matches your request to the most relevant function. Better descriptions help AI make smarter choices about which tool to use.

How do you actually build this?

What You Need

Core Function: Your Python code that does the actual work

``` def order_groceries(items, quantity, home_address, store="swiggy"): # Your code connects to Swiggy API return order_confirmation

```

Function Description (Structured Instructions for AI): Tell AI what your function does in a format it understands (JSON Schema - a structured way of writing that AI comprehends):

``` { "name": "order_groceries", "description": "Order groceries from delivery app", "parameters": { "items": "List of grocery items to order", "quantity": "Amount of each item", "home_address": "Delivery address for the groceries", "store": "Delivery platform, defaults to swiggy" } }

```

Let's consider another example: How Alexa works

Before AI: To play a song, you open Spotify, search for indie music, pick a track, and hit play.

With Function Calling: "Alexa, play indie songs."

What the developer built first:

1. The Function:

``` def play_music(genre, platform="spotify"): spotify_api = connect_to_spotify() playlist = spotify_api.search(genre + " music") spotify_api.play(playlist) return f"Playing {genre} playlist on {platform}"

```

2. The Instructions for AI:

``` { "name": "play_music", "description": "Play music from streaming platforms", "parameters": { "genre": "Music genre like indie, rock, jazz", "platform": "Streaming service, defaults to spotify" } }

```

What happens when you say "Alexa, play indie songs":

Step 1: Voice to Text "play indie songs"

Step 2: AI Understanding

  • Intent: "play music"
  • Genre: "indie"
  • Content: "songs"

Step 3: Tool Selection AI reads available function descriptions and selects play_music as the best match for "play music" intent.

Step 4: Parameter Extraction AI converts natural language to structured call: play_music(genre="indie")

Step 5: Function Execution Your code runs, connects to Spotify, searches for indie music, and plays it.

Step 6: Response AI responds: "Playing indie playlist"

Developer has written the code once and shared through Alexa with others. And people use this multiple times a day now.

Why should you care about learning this?

Amazon spent over 25 billion dollars developing Alexa. You can now build something similar to Alexa, in a day or a week, based on what we have learned during our workshop. This represents the democratization of AI development: what required massive teams and budgets is now accessible to anyone willing to learn.

So, what more can you do with what you have learned today - create tools or function calls that can augment AI to:

  • Reading and replying to emails automatically
  • Generating action items from meeting recordings
  • Ordering food through voice commands
  • Processing business data and generating reports
  • Automating repetitive tasks in your daily life

The Connected Life: Imagine AI handling everything: reading emails, ordering food, managing calendar, paying bills, shopping for groceries. AI connected to all your systems, taking actions on your behalf through voice or text. This life is possible to build now.

And for you, this is a step closer to becoming an AI builder.

How did I actually learn all this?

I didn't understand function calling until now. Although I have created a few fun projects before which leveraged this capability.

I thought, by setting the topic for this workshop, I will be serious to learn. Entire week, I spent reading about what agentic AI, function call, AI agents, tool calls, all this means. Reading different documents. Feeding them to AI. Asking AI to help me learn. Explain the details. But I still got superficial understanding.

Then, I built a few more AI projects using function calls. I started understanding a bit more practically.

When I introduced it during today's workshop. Through the conversations, I understood a bit more.

Post workshop, when I sat with my mom and explained it to her in simple terms in Marwari and when she could also understand it. Finally I was able to understand it clearly.

Does it mean, I am good at it? Not at all. Unless I build 5 different projects providing different capabilities to AI, I don't think, I will be able to grasp the concept thoroughly.

Learning Approach

Build stuff using function calling. Leverage AI to learn and code. Share with others. You'll become a powerful AI builder or leverage AI better in your life.

Use AI as your learning partner:

  • Ask AI to explain concepts you don't understand
  • Request AI to write code and schemas for you
  • Have AI debug your functions and fix errors
  • Get AI to suggest improvements and optimizations

The scary-looking code, JSON schemas, and technical structure become simple when you use AI as your coding partner. Ask AI to write functions and schemas for you.

Build, Share, Iterate

  1. Build simple tools for your own problems
  2. Share them with friends and get feedback
  3. Iterate and improve based on real usage
  4. Tackle bigger, more complex challenges

This cycle turns you from someone who uses AI into someone who builds with AI.

Function calling unlocks possibilities that seemed impossible just months ago. The democratization of AI development means powerful tools are now accessible to anyone willing to learn and build.

The first project is always tough, learning is tough. But the second project becomes a bit easier, and the 5th project becomes much more easy. So, build a lot.

Build to learn and learn to build - (Quote from deeplearning.ai)


If you think you don’t know how to code yet, everyone can code with the use of AI, check out this tweet by Andrew NG, where he mentions how his entire team is building apps: https://x.com/AndrewYNg/status/1929906213208113409

And a very nice talk that gives a very good overview about AI building: