Class GenerateContentConfig
-
- All Implemented Interfaces:
public abstract class GenerateContentConfig extends JsonSerializable
Optional model configuration parameters.
For more information, see `Content generation parameters `_.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public abstract classGenerateContentConfig.BuilderBuilder for GenerateContentConfig.
-
Field Summary
Fields Modifier and Type Field Description public final static StringMAX_READ_LENGTH_PROPERTY
-
Constructor Summary
Constructors Constructor Description GenerateContentConfig()
-
Method Summary
Modifier and Type Method Description abstract Optional<HttpOptions>httpOptions()Used to override HTTP request options. abstract Optional<Boolean>shouldReturnHttpResponse()If true, the raw HTTP response will be returned in the 'sdk_http_response' field. abstract Optional<Content>systemInstruction()Instructions for the model to steer it toward better performance. abstract Optional<Float>temperature()Value that controls the degree of randomness in token selection. abstract Optional<Float>topP()Tokens are selected from the most to least probable until the sum of their probabilities equals this value. abstract Optional<Float>topK()For each token selection step, the ``top_k`` tokens with the highest probabilities are sampled. abstract Optional<Integer>candidateCount()Number of response variations to return. abstract Optional<Integer>maxOutputTokens()Maximum number of tokens that can be generated in the response. abstract Optional<List<String>>stopSequences()List of strings that tells the model to stop generating text if one of the strings is encountered in the response. abstract Optional<Boolean>responseLogprobs()Whether to return the log probabilities of the tokens that were chosen by the model at each step. abstract Optional<Integer>logprobs()Number of top candidate tokens to return the log probabilities for at each generation step. abstract Optional<Float>presencePenalty()Positive values penalize tokens that already appear in the generated text, increasing the probability of generating more diverse content. abstract Optional<Float>frequencyPenalty()Positive values penalize tokens that repeatedly appear in the generated text, increasing the probability of generating more diverse content. abstract Optional<Integer>seed()When ``seed`` is fixed to a specific number, the model makes a best effort to provide the same response for repeated requests. abstract Optional<String>responseMimeType()Output response mimetype of the generated candidate text. abstract Optional<Schema>responseSchema()The `Schema` object allows the definition of input and output data types. abstract Optional<Object>responseJsonSchema()Optional. abstract Optional<GenerationConfigRoutingConfig>routingConfig()Configuration for model router requests. abstract Optional<ModelSelectionConfig>modelSelectionConfig()Configuration for model selection. abstract Optional<List<SafetySetting>>safetySettings()Safety settings in the request to block unsafe content in the response. abstract Optional<List<Tool>>tools()Code that enables the system to interact with external systems to perform an action outside of the knowledge and scope of the model. abstract Optional<ToolConfig>toolConfig()Associates model output to a specific function call. abstract Optional<Map<String, String>>labels()Labels with user-defined metadata to break down billed charges. abstract Optional<String>cachedContent()Resource name of a context cache that can be used in subsequent requests. abstract Optional<List<String>>responseModalities()The requested modalities of the response. abstract Optional<MediaResolution>mediaResolution()If specified, the media resolution specified will be used. abstract Optional<SpeechConfig>speechConfig()The speech generation configuration. abstract Optional<Boolean>audioTimestamp()If enabled, audio timestamp will be included in the request to the model. abstract Optional<AutomaticFunctionCallingConfig>automaticFunctionCalling()The configuration for automatic function calling. abstract Optional<ThinkingConfig>thinkingConfig()The thinking features configuration. abstract Optional<ImageConfig>imageConfig()The image generation configuration. abstract Optional<Boolean>enableEnhancedCivicAnswers()Enables enhanced civic answers. abstract Optional<ModelArmorConfig>modelArmorConfig()Settings for prompt and response sanitization using the Model Armor service. abstract Optional<ServiceTier>serviceTier()The service tier to use for the request. static GenerateContentConfig.Builderbuilder()Instantiates a builder for GenerateContentConfig. abstract GenerateContentConfig.BuildertoBuilder()Creates a builder with the same values as this instance. static GenerateContentConfigfromJson(String jsonString)Deserializes a JSON string to a GenerateContentConfig object. -
Methods inherited from class com.google.genai.JsonSerializable
fromJsonNode, fromJsonString, objectMapper, setMaxReadLength, stringToJsonNode, toJson, toJsonNode, toJsonString -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
httpOptions
abstract Optional<HttpOptions> httpOptions()
Used to override HTTP request options.
-
shouldReturnHttpResponse
abstract Optional<Boolean> shouldReturnHttpResponse()
If true, the raw HTTP response will be returned in the 'sdk_http_response' field.
-
systemInstruction
abstract Optional<Content> systemInstruction()
Instructions for the model to steer it toward better performance. For example, "Answer as concisely as possible" or "Don't use technical terms in your response".
-
temperature
abstract Optional<Float> temperature()
Value that controls the degree of randomness in token selection. Lower temperatures are good for prompts that require a less open-ended or creative response, while higher temperatures can lead to more diverse or creative results.
-
topP
abstract Optional<Float> topP()
Tokens are selected from the most to least probable until the sum of their probabilities equals this value. Use a lower value for less random responses and a higher value for more random responses.
-
topK
abstract Optional<Float> topK()
For each token selection step, the ``top_k`` tokens with the highest probabilities are sampled. Then tokens are further filtered based on ``top_p`` with the final token selected using temperature sampling. Use a lower number for less random responses and a higher number for more random responses.
-
candidateCount
abstract Optional<Integer> candidateCount()
Number of response variations to return.
-
maxOutputTokens
abstract Optional<Integer> maxOutputTokens()
Maximum number of tokens that can be generated in the response.
-
stopSequences
abstract Optional<List<String>> stopSequences()
List of strings that tells the model to stop generating text if one of the strings is encountered in the response.
-
responseLogprobs
abstract Optional<Boolean> responseLogprobs()
Whether to return the log probabilities of the tokens that were chosen by the model at each step.
-
logprobs
abstract Optional<Integer> logprobs()
Number of top candidate tokens to return the log probabilities for at each generation step.
-
presencePenalty
abstract Optional<Float> presencePenalty()
Positive values penalize tokens that already appear in the generated text, increasing the probability of generating more diverse content.
-
frequencyPenalty
abstract Optional<Float> frequencyPenalty()
Positive values penalize tokens that repeatedly appear in the generated text, increasing the probability of generating more diverse content.
-
seed
abstract Optional<Integer> seed()
When ``seed`` is fixed to a specific number, the model makes a best effort to provide the same response for repeated requests. By default, a random number is used.
-
responseMimeType
abstract Optional<String> responseMimeType()
Output response mimetype of the generated candidate text. Supported mimetype: - `text/plain`: (default) Text output. - `application/json`: JSON response in the candidates. The model needs to be prompted to output the appropriate response type, otherwise the behavior is undefined.
-
responseSchema
abstract Optional<Schema> responseSchema()
The `Schema` object allows the definition of input and output data types. These types can be objects, but also primitives and arrays. Represents a select subset of an [OpenAPI 3.0 schema object](https://spec.openapis.org/oas/v3.0.3#schema). If set, a compatible response_mime_type must also be set. Compatible mimetypes: `application/json`: Schema for JSON response.
If `response_schema` doesn't process your schema correctly, try using `response_json_schema` instead.
-
responseJsonSchema
abstract Optional<Object> responseJsonSchema()
Optional. Output schema of the generated response. This is an alternative to `response_schema` that accepts [JSON Schema](https://json-schema.org/). If set, `response_schema` must be omitted, but `response_mime_type` is required. While the full JSON Schema may be sent, not all features are supported. Specifically, only the following properties are supported: - `$id` - `$defs` - `$ref` - `$anchor` - `type` - `format` - `title` - `description` - `enum` (for strings and numbers) - `items` - `prefixItems` - `minItems` - `maxItems` - `minimum` - `maximum` - `anyOf` - `oneOf` (interpreted the same as `anyOf`) - `properties` - `additionalProperties` - `required` The non-standard `propertyOrdering` property may also be set. Cyclic references are unrolled to a limited degree and, as such, may only be used within non-required properties. (Nullable properties are not sufficient.) If `$ref` is set on a sub-schema, no other properties, except for than those starting as a `$`, may be set.
-
routingConfig
abstract Optional<GenerationConfigRoutingConfig> routingConfig()
Configuration for model router requests.
-
modelSelectionConfig
abstract Optional<ModelSelectionConfig> modelSelectionConfig()
Configuration for model selection.
-
safetySettings
abstract Optional<List<SafetySetting>> safetySettings()
Safety settings in the request to block unsafe content in the response.
-
tools
abstract Optional<List<Tool>> tools()
Code that enables the system to interact with external systems to perform an action outside of the knowledge and scope of the model.
-
toolConfig
abstract Optional<ToolConfig> toolConfig()
Associates model output to a specific function call.
-
labels
abstract Optional<Map<String, String>> labels()
Labels with user-defined metadata to break down billed charges.
-
cachedContent
abstract Optional<String> cachedContent()
Resource name of a context cache that can be used in subsequent requests.
-
responseModalities
abstract Optional<List<String>> responseModalities()
The requested modalities of the response. Represents the set of modalities that the model can return.
-
mediaResolution
abstract Optional<MediaResolution> mediaResolution()
If specified, the media resolution specified will be used.
-
speechConfig
abstract Optional<SpeechConfig> speechConfig()
The speech generation configuration.
-
audioTimestamp
abstract Optional<Boolean> audioTimestamp()
If enabled, audio timestamp will be included in the request to the model.
-
automaticFunctionCalling
abstract Optional<AutomaticFunctionCallingConfig> automaticFunctionCalling()
The configuration for automatic function calling.
-
thinkingConfig
abstract Optional<ThinkingConfig> thinkingConfig()
The thinking features configuration.
-
imageConfig
abstract Optional<ImageConfig> imageConfig()
The image generation configuration.
-
enableEnhancedCivicAnswers
abstract Optional<Boolean> enableEnhancedCivicAnswers()
Enables enhanced civic answers. It may not be available for all models. This field is not supported in Gemini Enterprise Agent Platform.
-
modelArmorConfig
abstract Optional<ModelArmorConfig> modelArmorConfig()
Settings for prompt and response sanitization using the Model Armor service. If supplied, safety_settings must not be supplied.
-
serviceTier
abstract Optional<ServiceTier> serviceTier()
The service tier to use for the request. For example, ServiceTier.FLEX.
-
builder
static GenerateContentConfig.Builder builder()
Instantiates a builder for GenerateContentConfig.
-
toBuilder
abstract GenerateContentConfig.Builder toBuilder()
Creates a builder with the same values as this instance.
-
fromJson
static GenerateContentConfig fromJson(String jsonString)
Deserializes a JSON string to a GenerateContentConfig object.
-
-
-
-