- [HTTP request](https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1/projects.locations.collections.dataStores.servingConfigs/streamAnswer#body.HTTP_TEMPLATE)
- [Path parameters](https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1/projects.locations.collections.dataStores.servingConfigs/streamAnswer#body.PATH_PARAMETERS)
- [Request body](https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1/projects.locations.collections.dataStores.servingConfigs/streamAnswer#body.request_body)
  - [JSON representation](https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1/projects.locations.collections.dataStores.servingConfigs/streamAnswer#body.request_body.SCHEMA_REPRESENTATION)
- [Response body](https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1/projects.locations.collections.dataStores.servingConfigs/streamAnswer#body.response_body)
- [Authorization scopes](https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1/projects.locations.collections.dataStores.servingConfigs/streamAnswer#body.aspect)
- [IAM Permissions](https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1/projects.locations.collections.dataStores.servingConfigs/streamAnswer#body.aspect_1)

Answer query method (streaming).

It takes one `AnswerQueryRequest` and returns multiple `https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1/AnswerQueryResponse` messages in a stream.

### HTTP request

Choose an endpoint:
global us   
`POST https://discoveryengine.googleapis.com/v1/{servingConfig=projects/*/locations/*/collections/*/dataStores/*/servingConfigs/*}:streamAnswer`

<br />

The URLs use [gRPC Transcoding](https://google.aip.dev/127) 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`. Or the resource name of the agent engine serving config, such as: `projects/*/locations/global/collections/default_collection/engines/*/servingConfigs/default_agent_answer`. (use when `enableAgentInvocation` set to true, and you have custom `AI_MODE` agent engine configured) 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 (`https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1/Query`) }, "session": string, "safetySpec": { object (`https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1/SafetySpec`) }, "relatedQuestionsSpec": { object (`https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1/RelatedQuestionsSpec`) }, "groundingSpec": { object (`https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1/GroundingSpec`) }, "answerGenerationSpec": { object (`https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1/AnswerGenerationSpec`) }, "searchSpec": { object (`https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1/SearchSpec`) }, "queryUnderstandingSpec": { object (`https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1/QueryUnderstandingSpec`) }, "asynchronousMode": boolean, "userPseudoId": string, "userLabels": { string: string, ... }, "endUserSpec": { object (`https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1/EndUserSpec`) } } ``` |

| Fields ||
|---|---|
| `query` | ``object (`https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1/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 (`https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1/SafetySpec`)`` Model specification. |
| `relatedQuestionsSpec` | ``object (`https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1/RelatedQuestionsSpec`)`` Related questions specification. |
| `groundingSpec` | ``object (`https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1/GroundingSpec`)`` Optional. Grounding specification. |
| `answerGenerationSpec` | ``object (`https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1/AnswerGenerationSpec`)`` Answer generation specification. |
| `searchSpec` | ``object (`https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1/SearchSpec`)`` servingConfigs.search specification. |
| `queryUnderstandingSpec` | ``object (`https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1/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 `https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1/projects.locations.dataStores.sessions.answers/get#google.cloud.discoveryengine.v1.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](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) for more details. |
| `endUserSpec` | ``object (`https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1/EndUserSpec`)`` Optional. End user specification. |

### Response body

If successful, the response body contains a stream of `https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1/AnswerQueryResponse` instances.

### Authorization scopes

Requires one of the following OAuth scopes:

- `https://www.googleapis.com/auth/cloud-platform`
- `https://www.googleapis.com/auth/discoveryengine.readwrite`
- `https://www.googleapis.com/auth/discoveryengine.serving.readwrite`

For more information, see the [Authentication Overview](https://docs.cloud.google.com/docs/authentication#authorization-gcp).

### IAM Permissions

Requires the following [IAM](https://cloud.google.com/iam/docs) permission on the `servingConfig` resource:

- `discoveryengine.servingConfigs.answer`

For more information, see the [IAM documentation](https://cloud.google.com/iam/docs).