v2026.6.4
All Bundles
Bundle Google Gemini API client. Supports text generation, multimodal inputs (image, audio, video), chat sessions, function calling, and caching. Set GOOGLE_API_KEY before use. Compile with -lib gemini.

Chat

Gemini chat session

Inherits: Content

Example

session := Chat->New("models/gemini-pro", EndPoint->GetApiKey());

content := session->SendPart(TextPart->New("What is the tallest mountain in the California?"), "user");
content->GetFirstPart()->ToString()->PrintLine();

content := session->SendPart(TextPart->New("How tall is it?"), "user");
content->GetFirstPart()->ToString()->PrintLine();

content := session->SendPart(TextPart->New("Why is it so tall?"), "user");
content->GetFirstPart()->ToString()->PrintLine();

content := session->SendPart(TextPart->New("Where is it located?"), "user");
content->GetFirstPart()->ToString()->PrintLine();
"======"->PrintLine();

session->ToString()->PrintLine();

Operations

GetAllParts #

Get all chat parts

method : public : GetAllParts() ~ Vector<Content>

Return

TypeDescription
Vector<Content>list of all chat parts

SendPart #

Send chat part

method : public : SendPart(part:Part, role:String) ~ Candidate

Parameters

NameTypeDescription
partPartprompt chat part
roleStringprompt role

Return

TypeDescription
Candidateprompt response

Example

session := Chat->New(Model->GEMINI_2_0_FLASH(), EndPoint->GetApiKey());
candidate := session->SendPart(TextPart->New("What is 2 + 2?"), "user");
candidate->GetAllText()->PrintLine();
candidate := session->SendPart(TextPart->New("Multiply that by 10."), "user");
candidate->GetAllText()->PrintLine();

SetSystemInstruction #

Sets a system instruction for this chat session.

method : public : SetSystemInstruction(instruction:Content) ~ Nil

Parameters

NameTypeDescription
instructionContentsystem instruction content (use TextPart for text instructions)

Example

session := Chat->New(Model->GEMINI_2_0_FLASH(), EndPoint->GetApiKey());
sys_instr := Content->New("system")->AddPart(TextPart->New("You are a concise assistant."));
session->SetSystemInstruction(sys_instr);
session->SendPart(TextPart->New("Hello!"), "user")->GetAllText()->PrintLine();

ToString #

String representation of the object

method : public : ToString() ~ String

Return

TypeDescription
Stringstring representation