DataPower API Gateway
only

Gemini invoke

Use the Gemini invoke policy to invoke Gemini operations.

Gateway support

Table 1. Table showing which gateways support this policy, and the corresponding policy version
Gateway Policy version
DataPower® API Gateway 2.0.0

This topic describes how to configure the policy in the assembly user interface; for details on how to configure the policy in your OpenAPI source, see gemini-invoke.

About

The Gemini invoke policy provides access to six Gemini operations:
  • POST models/[model]:generateContent
  • POST models/[model]:countTokens
  • POST models/[model]:embedContent
  • POST models/[model]:batchEmbedContents
  • GET models/[model]
  • GET models

The Gemini invoke policy supports the properties shown in Table 2.

Properties

The following table lists the policy properties, indicates whether a property is required, specifies the valid and default values for input, and specifies the data type of the values.

Table 2. Gemini invoke policy properties
Property label Required Description Data type
Title No Gemini invoke chat completions string
Description No A description of the policy. string
Gemini Operation Yes The Gemini operation to invoke; must be one of the following operations:
  • POST models/[model]:generateContent

    An HTTP POST operation for generateContent. See Generating Content in the Gemini API documentation for sample request and response examples.

  • POST models/[model]:countTokens

    An HTTP POST operation for /countTokens. See Counting tokens in the Gemini API documentation for sample request and response examples.

  • POST models/[model]:embedContent

    An HTTP POST operation for embedContent. See Embed Content in the Gemini API documentation for sample request and response examples.

  • POST models/[model]:batchEmbedContents

    An HTTP POST operation for batchEmbedContents. See Batch Embed Content in the Gemini API documentation for sample request and response examples.

  • GET models

    An HTTP GET operation for /models. See List Models in the Gemini API documentation for sample response examples.

  • GET models/[model]

    An HTTP GET operation for /models/[model]. See Retrieve model in the Gemini API documentation for sample response examples.

string
Gemini API Key Yes The API key, or a variable reference to the variable that contains an API key. The API key is used to authenticate Gemini requests. string
Enable response caching No Response caching is enabled by default to optimize API performance; however, you can disable it if needed for your API.

When response caching is enabled, then when a request is sent to the Gemini service, the response cache is inspected to determine if the request payload has an associated cached response. If so, that cached response and its associated HTTP response headers are placed into the DataPower API Gateway context message specified by the Output Message property.

If there is no cached response, the request is passed to the Gemini service, and the response is cached for subsequent operations using the time-to-live specified in the Response Cache Expiration property.

boolean
Response Cache Expiration No The duration of the cache (the time-to-live). The minimum duration is 60 seconds and the maximum duration is 86400 seconds (1 day) -- any value outside of that range will fail validation when the API is published, even if the value is accepted in this field. integer
Cache Scope No A string that adds uniqueness to the key used to store a cached response. Adding a cache scope enables the same request to be saved in multiple cache entries. string
Gemini Operation Path Parameters No For operations that have a path parameter designated with a path parameter name in square brackets in the operation, specify the name of the parameter and the value separated by a colon. If the operation has more that one path parameter, each path parameter designation should be separated with a comma. For example, for operation GET models/[model], the path parameter property would be specified as model:somename.
Note: If a path parameter is required for the operation selected but was not provided, the invoke operation will fail. However, for operations that don't require a path parameter, any provided path parameter will be ignored.
string
Gemini Operation Query Parameters No For operations that support query parameters, specify a query parameter string that specifies the name of the parameter and value separated with an equal sign character. If more than one query parameter is supported, each query parameter would be separated with an ampersand character. The supported operations at this time do not support query parameters, although operations that could be supported in the future would support query parameters. string
Output Message No The name of the DataPower API Gateway context message that receives the Gemini response. By default, this property uses message as the value, which enables the response to be accessible by subsequent API policies in message.body and message.headers. string