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.
GenerationConfig
Generation configuration: sampling and output limits for a generateContent request. Unset values are left out of the request, so the model's defaults apply.
Example
config := GenerationConfig->New()->SetTemperature(0.2)->SetMaxOutputTokens(256);
content := Content->New("user")->AddPart(TextPart->New("Name three rivers."));
candidates := Model->GenerateContent(Model->GEMINI_2_5_FLASH(), content, Nil, Nil, Nil, config, Nil, EndPoint->GetApiKey());Operations
AddStopSequence #
Adds a stop sequence; generation stops at the first one produced
method : public : AddStopSequence(stop_sequence:String) ~ GenerationConfigParameters
| Name | Type | Description |
|---|---|---|
| stop_sequence | String | stop sequence |
Return
| Type | Description |
|---|---|
| GenerationConfig | self reference |
SetCandidateCount #
Sets the number of candidates to generate
method : public : SetCandidateCount(candidate_count:Int) ~ GenerationConfigParameters
| Name | Type | Description |
|---|---|---|
| candidate_count | Int | candidate count |
Return
| Type | Description |
|---|---|
| GenerationConfig | self reference |
SetMaxOutputTokens #
Sets the maximum number of output tokens
method : public : SetMaxOutputTokens(max_output_tokens:Int) ~ GenerationConfigParameters
| Name | Type | Description |
|---|---|---|
| max_output_tokens | Int | token limit |
Return
| Type | Description |
|---|---|
| GenerationConfig | self reference |
SetSeed #
Sets the decoding seed
method : public : SetSeed(seed:Int) ~ GenerationConfigParameters
| Name | Type | Description |
|---|---|---|
| seed | Int | seed |
Return
| Type | Description |
|---|---|
| GenerationConfig | self reference |
SetTemperature #
Sets the sampling temperature
method : public : SetTemperature(temperature:Float) ~ GenerationConfigParameters
| Name | Type | Description |
|---|---|---|
| temperature | Float | temperature, typically 0.0 to 2.0 |
Return
| Type | Description |
|---|---|
| GenerationConfig | self reference |
SetTopK #
Sets the top-k sampling limit
method : public : SetTopK(top_k:Int) ~ GenerationConfigParameters
| Name | Type | Description |
|---|---|---|
| top_k | Int | number of most probable tokens considered |
Return
| Type | Description |
|---|---|
| GenerationConfig | self reference |
SetTopP #
Sets the nucleus sampling threshold
method : public : SetTopP(top_p:Float) ~ GenerationConfigParameters
| Name | Type | Description |
|---|---|---|
| top_p | Float | cumulative probability, 0.0 to 1.0 |
Return
| Type | Description |
|---|---|
| GenerationConfig | self reference |
ToJson #
Gets the configuration as the 'generationConfig' JSON object
method : public : ToJson() ~ JsonElementReturn
| Type | Description |
|---|---|
| JsonElement | JSON object holding only the values that were set |