Interface GenerateContentConfig

Optional model configuration parameters.

For more information, see Content generation parameters <https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/content-generation-parameters>_.

interface GenerateContentConfig {
    abortSignal?: AbortSignal;
    audioTimestamp?: boolean;
    audioTranscriptionConfig?: AudioTranscriptionConfig;
    automaticContinuation?: boolean;
    automaticFunctionCalling?: AutomaticFunctionCallingConfig;
    cachedContent?: string;
    candidateCount?: number;
    continuationToken?: string;
    enableEnhancedCivicAnswers?: boolean;
    frequencyPenalty?: number;
    generationOutputConfig?: GenerationOutputConfig;
    httpOptions?: HttpOptions;
    imageConfig?: ImageConfig;
    labels?: Record<string, string>;
    logprobs?: number;
    maxOutputTokens?: number;
    mediaResolution?: MediaResolution;
    modelArmorConfig?: ModelArmorConfig;
    modelSelectionConfig?: ModelSelectionConfig;
    presencePenalty?: number;
    responseJsonSchema?: unknown;
    responseLogprobs?: boolean;
    responseMimeType?: string;
    responseModalities?: string[];
    responseSchema?: unknown;
    routingConfig?: GenerationConfigRoutingConfig;
    safetySettings?: SafetySetting[];
    seed?: number;
    serviceTier?: ServiceTier;
    speechConfig?: SpeechConfigUnion;
    stopSequences?: string[];
    store?: boolean;
    systemInstruction?: ContentUnion;
    temperature?: number;
    thinkingConfig?: ThinkingConfig;
    toolConfig?: ToolConfig;
    tools?: ToolListUnion;
    topK?: number;
    topP?: number;
}

Properties

abortSignal?: AbortSignal

Abort signal which can be used to cancel the request.

NOTE: AbortSignal is a client-only operation. Using it to cancel an operation will not cancel the request in the service. You will still be charged usage for any applicable operations.

audioTimestamp?: boolean

If enabled, audio timestamp will be included in the request to the model.

audioTranscriptionConfig?: AudioTranscriptionConfig

Optional. Configuration for audio transcription (speech recognition).

automaticContinuation?: boolean

Defaults to true. When a response ends with finish reason CONTINUATION, the SDK sends the same request again with the response's continuation token until the model finishes. Timeouts, retries and billing apply to each request. Set to false to turn this off.

automaticFunctionCalling?: AutomaticFunctionCallingConfig

The configuration for automatic function calling.

cachedContent?: string

Resource name of a context cache that can be used in subsequent requests.

candidateCount?: number

Number of response variations to return.

continuationToken?: string

An opaque continuation token used to resume generation from a previous response that stopped with finish_reason set to CONTINUATION.

Encoded as base64 string.

enableEnhancedCivicAnswers?: boolean

Enables enhanced civic answers. It may not be available for all models. This field is not supported in Gemini Enterprise Agent Platform.

frequencyPenalty?: number

Positive values penalize tokens that repeatedly appear in the generated text, increasing the probability of generating more diverse content.

generationOutputConfig?: GenerationOutputConfig

Optional. Configuration for persisting output assets to external storage.

httpOptions?: HttpOptions

Used to override HTTP request options.

imageConfig?: ImageConfig

The image generation configuration.

labels?: Record<string, string>

Labels with user-defined metadata for the request.

logprobs?: number

Number of top candidate tokens to return the log probabilities for at each generation step.

maxOutputTokens?: number

Maximum number of tokens that can be generated in the response.

mediaResolution?: MediaResolution

If specified, the media resolution specified will be used.

modelArmorConfig?: ModelArmorConfig

Settings for prompt and response sanitization using the Model Armor service. If supplied, safety_settings must not be supplied.

modelSelectionConfig?: ModelSelectionConfig

Configuration for model selection.

presencePenalty?: number

Positive values penalize tokens that already appear in the generated text, increasing the probability of generating more diverse content.

responseJsonSchema?: unknown

Optional. Output schema of the generated response. This is an alternative to response_schema that accepts JSON Schema. 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.
responseLogprobs?: boolean

Whether to return the log probabilities of the tokens that were chosen by the model at each step.

responseMimeType?: string

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.
responseModalities?: string[]

The requested modalities of the response. Represents the set of modalities that the model can return.

responseSchema?: unknown

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

Configuration for model router requests.

safetySettings?: SafetySetting[]

Safety settings in the request to block unsafe content in the response.

seed?: number

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.

serviceTier?: ServiceTier

The service tier to use for the request. For example, ServiceTier.FLEX.

speechConfig?: SpeechConfigUnion

The speech generation configuration.

stopSequences?: string[]

List of strings that tells the model to stop generating text if one of the strings is encountered in the response.

store?: boolean

Configures the logging behavior for a given request. If set, it takes precedence over the project-level logging config. This field is not supported in Gemini Enterprise Agent Platform.

systemInstruction?: ContentUnion

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?: number

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.

thinkingConfig?: ThinkingConfig

The thinking features configuration.

toolConfig?: ToolConfig

Associates model output to a specific function call.

Code that enables the system to interact with external systems to perform an action outside of the knowledge and scope of the model.

topK?: number

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.

topP?: number

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.