Skip to content

The Gemini API wrapper for Delphi utilizes advanced models developed by Google to provide robust capabilities, including interactive chat, text embeddings, code generation, image and video prompting, audio analysis and transcription, fine-tuning, caching, and integration with Google Search.

License

Notifications You must be signed in to change notification settings

MaxiDonkey/DelphiGemini

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DelphiGemini – Google Gemini API Wrapper for Delphi

Delphi async/await supported GitHub GetIt – Available GitHub


New


Two simple illustrative examples of synchronous text generation.

Tip

To obtain a Google API key, please refer to the following link.


  • Non streamed example :

      // uses Gemini, Gemini.Types, Gemini.Helpers
      // Client: IGemini;
    
      Client := TGeminiFactory.CreateInstance('GEMINI_API_KEY');
    
      // Json Payload
      var Params: TProc<TInteractionParams> :=
        procedure (Params: TInteractionParams)
        begin
          Params
            .Model('gemini-3-flash-preview')
            .Input('From which version of Delphi were multi-line strings introduced?' );
        end;
    
      Memo1.Lines.Add('Please wait...');
    
      //Synchronous example (non streamed)
      var Value := Client.Interactions.Create(Params);
    
      try
        for var Output in Value.Outputs do
          if Output.&Type = TContentType.text then
            Memo1.Lines.Text := Memo1.Text + Output.Text;
      finally
        Value.Free;
      end;

  • Streamed example

      // uses Gemini, Gemini.Types, Gemini.Helpers;
      // Client: IGemini;
    
      Client := TGeminiFactory.CreateInstance('GEMINI_API_KEY');
    
      // Json Payload
      var Params: TProc<TInteractionParams> :=
        procedure (Params: TInteractionParams)
        begin
          Params
            .Model('gemini-3-flash-preview')
            .Input('From which version of Delphi were multi-line strings introduced?' )
            .Stream;
        end;
    
      // Stream Callback
      var StreamCallBack: TInteractionEvent :=
        procedure (var Event: TInteractionStream; IsDone: Boolean; var Cancel: Boolean)
        begin
          if (not IsDone) and Assigned(Event) then
            begin
              if Event.EventType = content_delta then
                if Event.Delta.&Type = TContentType.Text then
                  begin
                    Memo1.Lines.Text := Memo1.Text + Event.Delta.Text;
                    Application.ProcessMessages;
                  end;
            end;
        end;
    
      //Synchronous example (streamed)
      Client.Interactions.CreateStream(Params, StreamCallBack);


Summary

Introduction

Built with Delphi 12 Community Edition (v12.1 Patch 1)
The wrapper itself is MIT-licensed.
You can compile and test it free of charge with Delphi CE; any recent commercial Delphi edition works as well.


Delphi wrapper for the Google Gemini API, covering both direct generation generatedContent and advanced agentic workflows interactions.

This project provides a clear and structured Delphi abstraction over the public Gemini APIs, with native support for synchronous, asynchronous, and streaming execution.


Important

This is an unofficial library. Google does not provide an official Delphi SDK for Gemini. This repository contains Delphi implementation over Google Gemini public API.


Philosophy and Scope

The wrapper is built around a clear and intentional separation between Gemini’s two main endpoints, which serve fundamentally different purposes.

GenerateContent

  • direct generation
  • stateless execution
  • text and multimodal inputs
  • simple SSE streaming
  • limited built-in tools

This endpoint is well suited for immediate generation scenarios, interactive user interfaces, and straightforward processing pipelines.


Interactions

  • resource-oriented API
  • server-side persistent conversations
  • agents and advanced tools
  • structured outputs (JSON schema)
  • orchestration and background execution
  • event-based SSE streaming

This endpoint is designed for more complex workflows such as agent-based systems, research tasks, structured extraction, automation, and multi-step processing.

This distinction shapes the entire documentation structure and all provided examples.


Documentation – Overview

The documentation is organized as a set of independent Markdown files, each covering a specific functional area.

Main Entry Points

  • GenerateContent Text and multimodal generation, synchronous and asynchronous calls, streaming, payload construction, and basic tools.

  • Interactions Stateful conversations, agents, tools, structured outputs, orchestration, and advanced streaming


Going Further

Some cross-cutting or advanced features are intentionally documented outside the main sections to keep the core documentation focused and readable.

A dedicated entry point groups these topics: Going Further

This section links to documents covering:

  • Model discovery
  • Embeddings
  • Caching
  • Batch processing
  • Video generation (Veo)
  • Image generation (Imagen 4)
  • File management
  • Vector stores
  • Vectorized documents and fileSearch (Interactions)

Each topic is documented in its own Markdown file.


Functional Coverage

Area Supported
Text generation
Multimodal (image, audio, video, PDF)
SSE streaming
Persistent conversations
Agents
Structured outputs
Batch processing
File management
Vector search / fileSearch
Video generation (Veo)
Image generation (Imagen 4)

Project Status

  • The Google Gemini API is evolving rapidly
  • The Interactions endpoint is still in beta on Google’s side
  • The wrapper follows a pragmatic approach:
    • document what is stable
    • isolate what is evolving
    • avoid unnecessary duplication of the official documentation

License

This project is licensed under the MIT License.

About

The Gemini API wrapper for Delphi utilizes advanced models developed by Google to provide robust capabilities, including interactive chat, text embeddings, code generation, image and video prompting, audio analysis and transcription, fine-tuning, caching, and integration with Google Search.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages