Method: projects.locations.dataStores.servingConfigs.answer

Answer query method.

HTTP request

POST https://discoveryengine.googleapis.com/v1alpha/{servingConfig=projects/*/locations/*/dataStores/*/servingConfigs/*}:answer

The URL uses gRPC Transcoding syntax.

Path parameters

Parameters
servingConfig

string

Required. The resource name of the servingConfigs.search serving config, such as projects/*/locations/global/collections/default_collection/engines/*/servingConfigs/default_serving_config, or projects/*/locations/global/collections/default_collection/dataStores/*/servingConfigs/default_serving_config. This field is used to identify the serving configuration name, set of models used to make the search.

Request body

The request body contains data with the following structure:

JSON representation
{
  "query": {
    object (Query)
  },
  "session": string,
  "safetySpec": {
    object (SafetySpec)
  },
  "relatedQuestionsSpec": {
    object (RelatedQuestionsSpec)
  },
  "groundingSpec": {
    object (GroundingSpec)
  },
  "answerGenerationSpec": {
    object (AnswerGenerationSpec)
  },
  "searchSpec": {
    object (SearchSpec)
  },
  "queryUnderstandingSpec": {
    object (QueryUnderstandingSpec)
  },
  "asynchronousMode": boolean,
  "userPseudoId": string,
  "userLabels": {
    string: string,
    ...
  }
}
Fields
query

object (Query)

Required. Current user query.

session

string

The session resource name. Not required.

When session field is not set, the API is in sessionless mode.

We support auto session mode: users can use the wildcard symbol - as session ID. A new ID will be automatically generated and assigned.

safetySpec

object (SafetySpec)

Model specification.

relatedQuestionsSpec

object (RelatedQuestionsSpec)

Related questions specification.

groundingSpec

object (GroundingSpec)

Optional. Grounding specification.

answerGenerationSpec

object (AnswerGenerationSpec)

Answer generation specification.

searchSpec

object (SearchSpec)

servingConfigs.search specification.

queryUnderstandingSpec

object (QueryUnderstandingSpec)

Query understanding specification.

asynchronousMode
(deprecated)

boolean

Deprecated: This field is deprecated. Streaming Answer API will be supported.

Asynchronous mode control.

If enabled, the response will be returned with answer/session resource name without final answer. The API users need to do the polling to get the latest status of answer/session by calling ConversationalSearchService.GetAnswer or ConversationalSearchService.GetSession method.

userPseudoId

string

A unique identifier for tracking visitors. For example, this could be implemented with an HTTP cookie, which should be able to uniquely identify a visitor on a single device. This unique identifier should not change if the visitor logs in or out of the website.

This field should NOT have a fixed value such as unknown_visitor.

The field must be a UTF-8 encoded string with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error is returned.

userLabels

map (key: string, value: string)

The user labels applied to a resource must meet the following requirements:

  • Each resource can have multiple labels, up to a maximum of 64.
  • Each label must be a key-value pair.
  • Keys have a minimum length of 1 character and a maximum length of 63 characters and cannot be empty. Values can be empty and have a maximum length of 63 characters.
  • Keys and values can contain only lowercase letters, numeric characters, underscores, and dashes. All characters must use UTF-8 encoding, and international characters are allowed.
  • The key portion of a label must be unique. However, you can use the same key with multiple resources.
  • Keys must start with a lowercase letter or international character.

See Google Cloud Document for more details.

Response body

If successful, the response body contains an instance of AnswerQueryResponse.

Authorization scopes

Requires the following OAuth scope:

  • https://www.googleapis.com/auth/cloud-platform

For more information, see the Authentication Overview.

IAM Permissions

Requires the following IAM permission on the servingConfig resource:

  • discoveryengine.servingConfigs.answer

For more information, see the IAM documentation.