Blog
All Blog Posts | Next Post | Previous Post
Add AI superpower to your Delphi & C++Builder apps part 1
Wednesday, May 21, 2025

Image generated by OpenAI
Many software developers view AI primarily as a tool to boost productivity and improve their software development skills. But theres another powerful angle: using AI to enhance and extend the functionality of the applications we build. Thats exactly what weve been exploring over the past yearspecifically from the perspective of Delphi and C++Builder developers. In this blog series, well walk you through, step by step, the tools and techniques weve already developed for you to leverage. At the same time, we hope to spark a lively discussion and inspire new ideas about how AI can help us build software with functionality that feels out of this world. In this first article, well start with a small but essential step: how to use LLMs from within your applications. In the next part, well dive into LLM function calling and how it can enable deep integrations with your apps.
Integrating LLMs via REST API with TMS AI Studio's TTMSMCPCloudAI
Component
The surge in Large Language Models (LLMs) such as ChatGPT, Claude, Mistral, and others has revolutionized how applications interact with language. Whether you want to translate content, summarize data, or build intelligent assistants, these models provide a consistent and scalable interface through REST APIs.
In this article, well explore how you can abstractly and efficiently work with a wide range of LLM serviceslike OpenAI, DeepSeek, Claude, Gemini, Perplexity, Grok, Ollama, Mistral using the powerful TTMSMCPCloudAI
component from TMS AI Studio.
A Unified Approach to LLM Integration
Each cloud LLM provider offers slightly different API semantics, authentication methods, and payload structures. However, at a higher level, their interfaces boil down to a simple pattern:
-
Send text input ("prompt")
-
Receive generated text response ("completion")
This is commonly referred to as the Completion REST API.
With TTMSMCPCloudAI
, you dont need to worry about low-level details. The component abstracts away REST communication, authentication, and request building, so you can focus purely on integrating language capabilities into your app.
Supported AI services include at this moment:
OpenAI (ChatGPT)
Leading AI research and deployment company, creator of GPT-4 and ChatGPT.-
Gemini (Google AI)
Google's flagship multimodal AI family developed by Google DeepMind. -
Claude (Anthropic)
Anthropics family of helpful, harmless, and honest AI assistants. -
Grok (xAI)
AI developed by Elon Musks xAI, integrated with X (formerly Twitter). -
DeepSeek
Open-source and commercial LLMs focused on code and reasoning tasks. -
Mistral
European AI company offering open-weight LLMs like Mistral and Mixtral. -
Ollama
A local runtime for running LLMs on your own machine with a simple CLI. -
Perplexity AI
An AI-powered answer engine combining web search and conversational AI.
Common Use Cases
You can use these models for a variety of natural language processing tasks:
-
Translation between languages
-
Summarization of documents or datasets
-
Information retrieval from user input
-
Conversational agents and chatbots
-
And much more you'll uncover in the next article on function calling!
All these use cases follow the same underlying pattern: send context → receive a response. This makes them perfect candidates for abstraction.
Step-by-Step Integration Workflow
The typical workflow using the TTMSMCPCloudAI
component looks like this:
-
Request an API key from the LLM provider (e.g., OpenAI, Anthropic).
-
Select your model (e.g.,
gpt-4
,claude-3-7-sonnet
,mistral-medium
). -
Set the prompt context, and optionally the system role (instructions for the models behavior).
-
Send the request via HTTPS POST.
-
Receive and process the generated response text.
All of this is encapsulated cleanly by the component, making it straightforward to switch between providers or models.
Code Example: Ask Claude About Development Tools
Here's a practical example of how to call Anthropic's Claude model using TTMSMCPCloudAI
in a Delphi or C++Builder application:
Once Execute
is called, the request is sent, and the response text will be available via the result event or property for further use in your application.
And of course it is reassuring to see that the LLM responds with Delphi as its first recommendation 😉:
Why Use TTMSMCPCloudAI
?
- Rapid Development: Eliminate the boilerplate of REST clients and JSON handling.
- Flexibility: Switch between LLM providers without rewriting logic.
- RAD Integration: Seamlessly integrates into the Delphi or C++Builder apps built for Windows, macOS, Linux, iOS, Android.
- Cross-platform: Build once, deploy anywhere.
Get started
As LLMs become increasingly critical in building intelligent applications, having a robust and unified abstraction like TTMSMCPCloudAI
allows you to stay focused on the logic and user experiencenot the plumbing.
In upcoming articles, well dive deeper into function calling, RAG, agents, MCP servers & clients.
If you have an active TMS ALL-ACCESS license, you have access to the TMS AI Studio that uses the TTMSMCPCloudAI
component but also has everything on board to let you build MCP servers and clients.
Bruno Fierens
Related Blog Posts
-
Add AI superpower to your Delphi & C++Builder apps part 1
-
Add AI superpower to your Delphi & C++Builder apps part 2: function calling
-
Add AI superpower to your Delphi & C++Builder apps part 3: multimodal LLM use
-
Add AI superpower to your Delphi & C++Builder apps part 4: create MCP servers
-
Add AI superpower to your Delphi & C++Builder apps part 5: create your MCP client
-
Add AI superpower to your Delphi & C++Builder apps part 6: RAG
-
Introducing TMS AI Studio: Your Complete AI Development Toolkit for Delphi
-
Automatic invoice data extraction in Delphi apps via AI
-
Creating an n8n Workflow to use a Logging MCP Server

This blog post has received 12 comments.


Bruno Fierens

In other words, the history of user messages are just one after the other in the Context (i.e. TStrings) and sent to LLM as is?
Joe


Bruno Fierens

I''ve tested something I was doing directly with OpenAI API (via delphi open source libraries) - where I send the history of the system, user and assistant messages. I send back in the same ORDER. Then I used your TTMSFNCCloudAI component. It makes a difference. The LLM needs to know the order of the messages and also each message role. Without the order and role, the application I''m developing doesn''t work.
I very much would like to purchase your component (multiple services, better support etc).
It''s my opinion that grouping all user messages together will LIMIT the effectiveness of the LLM.
Joe


Bruno Fierens

Just curious if you and your team will make TTMSFNCCloudAI handle the order and type of message (User, Assistant, System etc)?
Wondering what the progress is on that?
Joe


Bruno Fierens

Mehrdad Esmaili

Wijnnobel Wilfred


Bruno Fierens

"messages": [
{
"role": "system",
"content": "You are helpful assistant."
},
{
"role": "user",
"content": "Good morning!"
},
{
"role": "assistant",
"content": "Good morning! How can I assist you today?"
},
{
"role": "user",
"content": "I just needed your reply to get a messages example for the OpenAI completions API"
},
{
"role": "assistant",
"content": "I see! No problem."
},
{
"role": "user",
"content": "Thanks"
}
]
Wijnnobel Wilfred
All Blog Posts | Next Post | Previous Post
Does the component automatically add "user" prompts to the history?
Joe