4D Blog

Home Product 4D 21 and AI Kit: Redefining how applications Think and Act

4D 21 and AI Kit: Redefining how applications Think and Act

October 14, 2025

Product

With 4D 21, AI takes a giant leap forward. At the heart of this evolution is AI Kit’s tool calling, a massive addition that transforms the way you integrate AI into your applications.

Tool calling allows you to extend the model’s capabilities by registering your own methods or functions, which the AI can call automatically when relevant. This means that instead of manually handling every interaction, the chat helper automatically invokes your handlers, giving you both flexibility and control.

Why This Matters

Our implementation puts developers in control. You decide what tools exist and what data is shared, there is no direct access for the AI to your database. You declare tools, define their parameters, and determine exactly what data to return. This safeguards your data while allowing the AI to work with the outputs of your choice.

Tool calling also opens the door to Retrieval-Augmented Generation (RAG). In RAG, the model doesn’t rely solely on its own knowledge. Instead, it can dynamically retrieve information from external sources, such as your 4D database, before generating a response. The result is answers that are not only intelligent and natural, but grounded in your real-world business context.

AI tool calling Invocation in Conversations

A key innovation in AI Kit is letting the assistant automatically invoke tools during conversations. A tool is a custom function registered by the developer that can be triggered by the model when certain conditions are met. This makes your assistant far more dynamic, capable of performing specialized tasks without manual intervention.

For example, you could create a tool to return information about a person, cancel invoices, send emails, validate orders — essentially turning your assistant into a new interface for interacting with the services your 4D app provides. And the best part? This can happen purely through a prompt-based UI, which is exactly how the next generation of users expects to interact with software.

Example: Creating a “GetPeopleInfo” Tool

Here’s a practical example showing how to register and use a tool with AI Kit:

  • First, create a Tool_GetPeopleInfo class that describes the tool:
// --- Tool Definition ---
property tool:={}

Class constructor
  // We describe the "GetPeopleInfo" tool in json format:
  This.tool.name:="GetPeopleInfo"
  This.tool.description:="It returns information about the person based on their first and last name."
  This.tool.parameters:={type: "object"; properties: {}}
  This.tool.parameters.properties.firstname:={type: "string"; description: "First name of the person sought"}
  This.tool.parameters.properties.lastname:={type: "string"; description: "Last name of the person sought"}
	
Function handler($info : Object) : Text
	$result:=ds.People.query("Firstname=:1 and Lastname=:2"; $info.firstname; $info.lastname)
	// Returns the person information
	return $result.length>0 ? JSON Stringify($result[0].toObject()) : "This person is unknown"
  • Then register the tool with the chat helper:
var $client:=cs.AIKit.OpenAI.new($openAIKey)
var $chatHelper:=$client.chat.create("you are an HR assistant.")

// --- Tool Registration ---
// We register the tool with the chat helper.
// This allows the model to automatically invoke it when a request matches.
$chatHelper.registerTool(cs.Tool_GetPeopleInfo.new())

var $result:=$chatHelper.prompt("What is Faye Back's address?")
//$result.choice.message.text="Faye Back's address is Earl Boulevard (178), Lanesville, 12450, USA.

When the user asks, “What is John Smith’s address?“, the model decides to call the “GetPeopleInfo” tool because it has access to the tool definition. The handler function is automatically called by AIKit with the provided parameters. The model receives the response, integrates it into the conversation, and returns the formatted response. All of this happens without manual coding for each query.

Beyond the Example: Expanding Use Cases

The potential of tool calling goes far beyond retrieving data. Here are a few examples of what you can do:

  • Cancel invoices based on a user request.

  • Send automated emails with custom content.

  • Validate orders before processing.

  • Trigger workflows within your 4D app.

These tools allow your assistant to become a powerful interface for your app’s functionality, a natural language UI for your services. This isn’t just a nice-to-have: it’s how the next generation expects to interact with software.

conclusion

The AI tool calling in 4D 21’s AI Kit empowers you to seamlessly extend the model’s capabilities with your own logic. By bridging AI with your 4D methods or functions, you can give the assistant direct access to your data and processes, making its responses not only smarter but also perfectly adapted to your business needs. Note that not all models support this functionality.

Discuss

Tags 21, 4D AIKit, AI, AI Tool Calling, Artificial Intelligence, OpenAI

Latest related posts

  • December 3, 2025

    Give AI to a 30 years old 4D application

  • November 28, 2025

    ORDA – Handle an event-driven logic during database operations

  • November 27, 2025

    ORDA – Permissions – Restrict / allow web access to the resources in one click

Fabrice Mainguené
Fabrice Mainguené
• Product Owner •Fabrice Mainguené joined 4D Program team in November, 2016. As a Product Owner, he is in charge of writing the user stories then translating it to functional specifications. His role is also to make sure that the feature implementation delivered is meeting the customer need.After obtaining a Bachelor degree in Computer Science at CNAM, Fabrice joined a small software publishing company as a Windev developer. Then he worked for different companies in industry and trade areas as a Windev and web developer as well as technical advisor on new features.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • AI
  • 4D View Pro
  • 4D Write Pro
  • 4D for Mobile
  • Email
  • Development Mode
  • 4D Language
  • ORDA
  • User Interface / GUI
  • Qodly Studio
  • Server
  • Maintenance
  • Deployment
  • 4D Tutorials
  • Generic
  • 4D Summit sessions and other online videos

Tags

4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R10 21 Administration AI Artificial Intelligence Build application CI/CD Class Client/Server Code editor Collections Formula Listbox Logs Mail Microsoft 365 Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor

Tags

4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R10 21 Administration AI Artificial Intelligence Build application CI/CD Class Client/Server Code editor Collections Formula Listbox Logs Mail Microsoft 365 Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor
Subscribe to 4D Newsletter

© 2025 4D SAS - All rights reserved
Terms & Conditions | Legal Notices | Data Policy | Cookie Policy | Contact us | Write for us


Subscribe to 4D Newsletter

* Your privacy is very important to us. Please click here to view our Policy

Contact us

Got a question, suggestion or just want to get in touch with the 4D bloggers? Drop us a line!

* Your privacy is very important to us. Please click here to view our Policy