Google Gemini AI
Integrate Google Gemini multimodal AI models into your Delphi, C++ Builder and .NET applications, with content generation, vision, structured outputs, embeddings and streaming.
Integrate Google Gemini multimodal AI models into your Delphi, C++ Builder and .NET applications, with content generation, vision, structured outputs, embeddings and streaming.
Google Gemini REST API client for content generation, vision, structured outputs, token counting and embeddings.
TsgcHTTP_API_Gemini
Gemini REST API over HTTPS
Windows, macOS, Linux, iOS, Android
Enterprise (AI add-on)
Set the API key in GeminiOptions, then build a TsgcGeminiClass_Request_GenerateContent and call CreateContent, or use the _CreateContent string helper for a quick one-shot prompt.
uses
sgcHTTP_API_Gemini;
var
Gemini: TsgcHTTP_API_Gemini;
Request: TsgcGeminiClass_Request_GenerateContent;
Response: TsgcGeminiClass_Response_GenerateContent;
begin
Gemini := TsgcHTTP_API_Gemini.Create(nil);
Gemini.GeminiOptions.ApiKey := 'YOUR_API_KEY';
// Typed content-generation request
Request := TsgcGeminiClass_Request_GenerateContent.Create;
Request.Model := 'gemini-2.0-flash';
Request.AddUserContent('What are the benefits of WebSockets?');
Response := Gemini.CreateContent(Request);
// Simple one-shot prompt via string helper
Memo1.Lines.Text := Gemini._CreateContent(
'gemini-2.0-flash',
'Summarise RFC 6455',
4096);
// Streaming — handle OnHTTPAPISSE per delta
Gemini.OnHTTPAPISSE := HandleSSE;
Gemini._CreateContentStream(
'gemini-2.0-flash',
'Explain quantum entanglement',
1024);
end;
procedure TForm1.HandleSSE(Sender: TObject;
const aEvent, aData: string;
var Cancel: Boolean);
begin
Memo1.Lines.Add(aEvent + ': ' + aData);
end;
// uses: sgcHTTP_API_Gemini
TsgcHTTP_API_Gemini *Gemini = new TsgcHTTP_API_Gemini(this);
Gemini->GeminiOptions->ApiKey = "YOUR_API_KEY";
// Typed content-generation request
TsgcGeminiClass_Request_GenerateContent *Request =
new TsgcGeminiClass_Request_GenerateContent();
Request->Model = "gemini-2.0-flash";
Request->AddUserContent("What are the benefits of WebSockets?");
TsgcGeminiClass_Response_GenerateContent *Response = Gemini->CreateContent(Request);
// Simple one-shot prompt via string helper
Memo1->Lines->Text = Gemini->_CreateContent(
"gemini-2.0-flash",
"Summarise RFC 6455",
4096);
// Streaming — OnHTTPAPISSE fires per delta
Gemini->OnHTTPAPISSE = HandleSSE;
Gemini->_CreateContentStream(
"gemini-2.0-flash",
"Explain quantum entanglement",
1024);
using esegece.sgcWebSockets;
var gemini = new TsgcHTTPAPI_Gemini();
gemini.GeminiOptions.ApiKey = "YOUR_API_KEY";
// Typed content-generation request
var request = new TsgcGeminiClass_Request_GenerateContent();
request.Model = "gemini-2.0-flash";
request.AddUserContent("What are the benefits of WebSockets?");
var response = gemini.CreateContent(request);
// Simple one-shot prompt via string helper
Console.WriteLine(gemini._CreateContent(
"gemini-2.0-flash",
"Summarise RFC 6455",
4096));
// Streaming via Server-Sent Events
gemini.OnHTTPAPISSE += (sender, ev, data, cancel) => Console.Write(data);
gemini._CreateContentStream(
"gemini-2.0-flash",
"Explain quantum entanglement",
1024);
Typed request / response classes for content generation, vision, structured outputs, token counting and embeddings, plus streaming and reliability controls.
CreateContent sends a typed TsgcGeminiClass_Request_GenerateContent and returns a parsed response. _CreateContent, _CreateContentWithSystem and _CreateContentStream are JSON-string shortcuts for quick prompts and streaming.
_CreateVisionContent sends a base64-encoded image with a text prompt, supporting image/jpeg, image/png, image/gif and image/webp media types for multimodal understanding.
Add function declarations and tools to TsgcGeminiClass_Request_GenerateContent so Gemini can invoke your functions and return structured tool calls inside the same generation request.
_CreateContentJSON applies a JSON schema to the request so the model returns structured JSON that matches your expected output format.
CountTokens sends a TsgcGeminiClass_Request_CountTokens to estimate quota usage and truncate prompts before generation. No text is produced by this call.
EmbedContent generates a dense floating-point vector for a piece of text using an embedding model such as text-embedding-004, for semantic search and retrieval pipelines.
_GetModels lists every available Gemini model and _GetModel retrieves details for a specific model identifier, so you can discover capabilities at runtime.
CircuitBreaker short-circuits requests after repeated failures; ReadTimeout and TLSOptions tune the HTTPS layer; OnHTTPAPIException surfaces failures; OnHTTPAPISSE streams server-sent events.
Authoritative sources for the protocols this component implements.
Deep-link to the component reference, grab the ready-to-run demo project, and download the trial.
| Online Help — Gemini Full property, method and event reference for this component. | Open | |
| Demo Project — Demos\AI\Gemini Ready-to-run example project. Ships inside the sgcWebSockets package — download the trial below. | Open | |
| User Manual (PDF) Comprehensive manual covering every component in the library. | Open |