liveBook · Manning

Chapter 13: Building AI-powered applications

What you will learn in chapter 13 of AI for Everyday IT

This chapter introduces integrating generative AI into applications through APIs, especially function calling that turns model output into structured input for application logic.

After this chapter you will be able to

What it builds on

Section by section

Introduction

This chapter introduces integrating generative AI into applications through APIs, especially function calling that turns model output into structured input for application logic.

Key terms: generative AI, REST APIs, AI integration, function calling, predefined functions, application logic, structured data, OpenAI, OpenAI function calling, Microsoft Copilot

13.1 Function calling

This section introduces OpenAI function calling as a way for an application to receive structured AI output and safely execute its own functions.

Key terms: function calling, OpenAI API, function specifications, JSON, parameters, security measures, validate inputs, handle errors, application code, OpenAI GPT Actions

13.1.1 Chatting with the OpenAI API

This section compares the Chat Completions and Assistants APIs and explains why the Assistants API is used to build context-aware AI copilots.

Key terms: Chat Completions API, Assistants API, messages, conversation threads, tools, function calling, AI copilot, conversation context, developer goals, instructions

13.1.2 Building a database copilot

This section frames a database copilot proof of concept and explains how system, user, and assistant roles provide database context and structure its conversations with the OpenAI API.

Key terms: copilot, database copilot, proof of concept (POC), Northwind sample database, OpenAI API, local agents, firewall changes, production data, API payload, system role

13.1.3 Implementing function calling

This section explains how an application uses OpenAI function calling to generate, validate, and safely execute database SQL in response to a user question.

Key terms: function calling, OpenAI API, JSON, security, validation, error handling, database copilot, get_sql_query, examine_sql, SQL query

13.2 The functions

This section introduces the end-to-end function-calling workflow for a natural-language database assistant and emphasizes database safety safeguards.

Key terms: function calling, examine_sql, Invoke-DbaQuery, OpenAI API, REST, PowerShell, read-only database accounts, query validation, dangerous queries, SQL Server

13.2.1 What matters in AI function design

This section explains how well-defined AI functions produce structured JSON that an application can parse, validate, and use predictably for database-related tasks.

Key terms: functions, API payload, structured JSON, function calling, SQL query, examine_sql, parsed SQL query, Invoke-DbaQuery, REST API, Python requests

13.3 Validating SQL queries with examine_sql

Introduces the examine_sql function as an ad hoc AI validation step that identifies whether generated SQL is valid and potentially dangerous before it affects a database.

Key terms: examine_sql, generated SQL queries, valid, potentially dangerous, database security, database integrity, JSON object, explanation, get_sql_query, ad hoc chat completions

13.3.1 Defining what makes a query dangerous

This subsection defines application-specific rules for recognizing dangerous SQL so examine_sql can keep AI-generated queries safe.

Key terms: dangerous, examine_sql, DELETE, UPDATE, WHERE clauses, database schema, natural language, function calls

13.3.2 Generating a user-friendly response

This subsection explains that, after a SQL query is generated, validated, and executed, the assistant turns its results into a conversational response while function calling provides a safer interface to database operations.

Key terms: generate, validate, execute, conversational response, function calling, AI models, database operations, security risks, flexibility

13.3.3 AI-powered SQL assistance in action

This section illustrates how function calling can power a practical AI workflow by automating HR training-data cleanup from vendor CSV files into a SharePoint list.

Key terms: function calling, Azure OpenAI Service, Power App, SharePoint Online, SharePoint list, vendor CSV files, SharePoint Online document library, testing and refining, deployment and documentation, automation opportunities

13.4 Practical applications and security considerations

This section introduces real-world uses of function calling beyond databases and highlights the need for strong security practices.

Key terms: function calling, natural requests, currency conversion, data extraction, image processing, security practices

13.4.1 Example: AI-powered currency conversion

This subsection illustrates function calling with an AI-powered Python currency converter and highlights how external functions and structured data expand AI application capabilities.

Key terms: OpenAI API, forex_python, function calling, currency conversion, external data, custom functions, typed values, structured labels, action items, structured data

13.4.2 Security considerations for function calling

This section explains how to secure AI function-calling applications by treating model output as untrusted and applying layered safeguards before production.

Key terms: input validation, strict type checking, whitelisting, parameterized queries, string concatenation, path validation, access controls, minimum permissions, read-only accounts, human review

13.5 Prompts used in this chapter

This section provides an editorial prompt for organizing and revising chapter content with AI.

Key terms: case study, GPT Actions, appendix, summary bullets

13.6 Summary

This summary recaps how AI-powered applications use function calling, context-aware copilots, automation integrations, and security controls to make IT workflows safer and more effective.

Concepts explained in this chapter

← Chapter 12: AI in DevOps engineering Chapter 14: Conflict resolution and crisis management →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.