v2026.11.2
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.

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.

Inherits: EndPoint

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) ~ GenerationConfig

Parameters

NameTypeDescription
stop_sequenceStringstop sequence

Return

TypeDescription
GenerationConfigself reference

SetCandidateCount #

Sets the number of candidates to generate

method : public : SetCandidateCount(candidate_count:Int) ~ GenerationConfig

Parameters

NameTypeDescription
candidate_countIntcandidate count

Return

TypeDescription
GenerationConfigself reference

SetMaxOutputTokens #

Sets the maximum number of output tokens

method : public : SetMaxOutputTokens(max_output_tokens:Int) ~ GenerationConfig

Parameters

NameTypeDescription
max_output_tokensInttoken limit

Return

TypeDescription
GenerationConfigself reference

SetSeed #

Sets the decoding seed

method : public : SetSeed(seed:Int) ~ GenerationConfig

Parameters

NameTypeDescription
seedIntseed

Return

TypeDescription
GenerationConfigself reference

SetTemperature #

Sets the sampling temperature

method : public : SetTemperature(temperature:Float) ~ GenerationConfig

Parameters

NameTypeDescription
temperatureFloattemperature, typically 0.0 to 2.0

Return

TypeDescription
GenerationConfigself reference

SetTopK #

Sets the top-k sampling limit

method : public : SetTopK(top_k:Int) ~ GenerationConfig

Parameters

NameTypeDescription
top_kIntnumber of most probable tokens considered

Return

TypeDescription
GenerationConfigself reference

SetTopP #

Sets the nucleus sampling threshold

method : public : SetTopP(top_p:Float) ~ GenerationConfig

Parameters

NameTypeDescription
top_pFloatcumulative probability, 0.0 to 1.0

Return

TypeDescription
GenerationConfigself reference

ToJson #

Gets the configuration as the 'generationConfig' JSON object

method : public : ToJson() ~ JsonElement

Return

TypeDescription
JsonElementJSON object holding only the values that were set