# Discovery Engine v1beta API - Class GroundedGenerationServiceClient (1.0.0-beta23)

1.0.0-beta23 (latest) 1.0.0-beta22

    public abstract class GroundedGenerationServiceClient

Reference documentation and code samples for the Discovery Engine v1beta API class GroundedGenerationServiceClient.

GroundedGenerationService client wrapper, for convenient use.

## Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) \> GroundedGenerationServiceClient

## Inherited Members

[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) [object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone) [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Derived Types

[GroundedGenerationServiceClientImpl](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.GroundedGenerationServiceClientImpl)

## Namespace

[Google.Cloud.DiscoveryEngine.V1Beta](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta)

## Assembly

Google.Cloud.DiscoveryEngine.V1Beta.dll

## Remarks

Service for grounded generation.

## Properties

### DefaultEndpoint

    public static string DefaultEndpoint { get; }

The default endpoint for the GroundedGenerationService service, which is a host of
"discoveryengine.googleapis.com" and a port of 443.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.string` |   |

### DefaultScopes

    public static IReadOnlyList<string> DefaultScopes { get; }

The default GroundedGenerationService scopes.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.collections.generic.ireadonlylist-1https://learn.microsoft.com/dotnet/api/system.string` |   |

**Remarks** The default GroundedGenerationService scopes are:

- <https://www.googleapis.com/auth/cloud-platform>

### GrpcClient

    public virtual GroundedGenerationService.GroundedGenerationServiceClient GrpcClient { get; }

The underlying gRPC GroundedGenerationService client

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.GroundedGenerationServicehttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.GroundedGenerationService.GroundedGenerationServiceClient` |   |

### LocationsClient

    public virtual LocationsClient LocationsClient { get; }

The [LocationsClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Location/latest/Google.Cloud.Location.LocationsClient.html) associated with this client.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Location/latest/Google.Cloud.Location.LocationsClient.html` |   |

### ServiceMetadata

    public static ServiceMetadata ServiceMetadata { get; }

The service metadata associated with this client type.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ServiceMetadata.html` |   |

## Methods

### CheckGrounding(CheckGroundingRequest, CallSettings)

    public virtual CheckGroundingResponse CheckGrounding(CheckGroundingRequest request, CallSettings callSettings = null)

Performs a grounding check.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.CheckGroundingRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.CheckGroundingResponse` | The RPC response. |

**Example**

    // Create client
    GroundedGenerationServiceClient groundedGenerationServiceClient = GroundedGenerationServiceClient.Create();
    // Initialize request argument(s)
    CheckGroundingRequest request = new CheckGroundingRequest
    {
        GroundingConfigAsGroundingConfigName = GroundingConfigName.FromProjectLocationGroundingConfig("[PROJECT]", "[LOCATION]", "[GROUNDING_CONFIG]"),
        AnswerCandidate = "",
        Facts =
        {
            new GroundingFact(),
        },
        GroundingSpec = new CheckGroundingSpec(),
        UserLabels = { { "", "" }, },
    };
    // Make the request
    CheckGroundingResponse response = groundedGenerationServiceClient.CheckGrounding(request);

### CheckGroundingAsync(CheckGroundingRequest, CallSettings)

    public virtual Task<CheckGroundingResponse> CheckGroundingAsync(CheckGroundingRequest request, CallSettings callSettings = null)

Performs a grounding check.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.CheckGroundingRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.CheckGroundingResponse` | A Task containing the RPC response. |

**Example**

    // Create client
    GroundedGenerationServiceClient groundedGenerationServiceClient = await GroundedGenerationServiceClient.CreateAsync();
    // Initialize request argument(s)
    CheckGroundingRequest request = new CheckGroundingRequest
    {
        GroundingConfigAsGroundingConfigName = GroundingConfigName.FromProjectLocationGroundingConfig("[PROJECT]", "[LOCATION]", "[GROUNDING_CONFIG]"),
        AnswerCandidate = "",
        Facts =
        {
            new GroundingFact(),
        },
        GroundingSpec = new CheckGroundingSpec(),
        UserLabels = { { "", "" }, },
    };
    // Make the request
    CheckGroundingResponse response = await groundedGenerationServiceClient.CheckGroundingAsync(request);

### CheckGroundingAsync(CheckGroundingRequest, CancellationToken)

    public virtual Task<CheckGroundingResponse> CheckGroundingAsync(CheckGroundingRequest request, CancellationToken cancellationToken)

Performs a grounding check.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.CheckGroundingRequest` The request object containing all of the parameters for the API call. |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` A [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) to use for this RPC. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.CheckGroundingResponse` | A Task containing the RPC response. |

**Example**

    // Create client
    GroundedGenerationServiceClient groundedGenerationServiceClient = await GroundedGenerationServiceClient.CreateAsync();
    // Initialize request argument(s)
    CheckGroundingRequest request = new CheckGroundingRequest
    {
        GroundingConfigAsGroundingConfigName = GroundingConfigName.FromProjectLocationGroundingConfig("[PROJECT]", "[LOCATION]", "[GROUNDING_CONFIG]"),
        AnswerCandidate = "",
        Facts =
        {
            new GroundingFact(),
        },
        GroundingSpec = new CheckGroundingSpec(),
        UserLabels = { { "", "" }, },
    };
    // Make the request
    CheckGroundingResponse response = await groundedGenerationServiceClient.CheckGroundingAsync(request);

### Create()

    public static GroundedGenerationServiceClient Create()

Synchronously creates a [GroundedGenerationServiceClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.GroundedGenerationServiceClient) using the default credentials,
endpoint and settings. To specify custom credentials or other settings, use
[GroundedGenerationServiceClientBuilder](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.GroundedGenerationServiceClientBuilder).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.GroundedGenerationServiceClient` | The created [GroundedGenerationServiceClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.GroundedGenerationServiceClient). |

### CreateAsync(CancellationToken)

    public static Task<GroundedGenerationServiceClient> CreateAsync(CancellationToken cancellationToken = default)

Asynchronously creates a [GroundedGenerationServiceClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.GroundedGenerationServiceClient) using the default credentials,
endpoint and settings. To specify custom credentials or other settings, use
[GroundedGenerationServiceClientBuilder](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.GroundedGenerationServiceClientBuilder).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` The [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) to use while creating the client. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.GroundedGenerationServiceClient` | The task representing the created [GroundedGenerationServiceClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.GroundedGenerationServiceClient). |

### GenerateGroundedContent(GenerateGroundedContentRequest, CallSettings)

    public virtual GenerateGroundedContentResponse GenerateGroundedContent(GenerateGroundedContentRequest request, CallSettings callSettings = null)

Generates grounded content.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.GenerateGroundedContentRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.GenerateGroundedContentResponse` | The RPC response. |

**Example**

    // Create client
    GroundedGenerationServiceClient groundedGenerationServiceClient = GroundedGenerationServiceClient.Create();
    // Initialize request argument(s)
    GenerateGroundedContentRequest request = new GenerateGroundedContentRequest
    {
        LocationAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
        Contents =
        {
            new GroundedGenerationContent(),
        },
        GenerationSpec = new GenerateGroundedContentRequest.Types.GenerationSpec(),
        GroundingSpec = new GenerateGroundedContentRequest.Types.GroundingSpec(),
        SystemInstruction = new GroundedGenerationContent(),
        UserLabels = { { "", "" }, },
    };
    // Make the request
    GenerateGroundedContentResponse response = groundedGenerationServiceClient.GenerateGroundedContent(request);

### GenerateGroundedContentAsync(GenerateGroundedContentRequest, CallSettings)

    public virtual Task<GenerateGroundedContentResponse> GenerateGroundedContentAsync(GenerateGroundedContentRequest request, CallSettings callSettings = null)

Generates grounded content.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.GenerateGroundedContentRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.GenerateGroundedContentResponse` | A Task containing the RPC response. |

**Example**

    // Create client
    GroundedGenerationServiceClient groundedGenerationServiceClient = await GroundedGenerationServiceClient.CreateAsync();
    // Initialize request argument(s)
    GenerateGroundedContentRequest request = new GenerateGroundedContentRequest
    {
        LocationAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
        Contents =
        {
            new GroundedGenerationContent(),
        },
        GenerationSpec = new GenerateGroundedContentRequest.Types.GenerationSpec(),
        GroundingSpec = new GenerateGroundedContentRequest.Types.GroundingSpec(),
        SystemInstruction = new GroundedGenerationContent(),
        UserLabels = { { "", "" }, },
    };
    // Make the request
    GenerateGroundedContentResponse response = await groundedGenerationServiceClient.GenerateGroundedContentAsync(request);

### GenerateGroundedContentAsync(GenerateGroundedContentRequest, CancellationToken)

    public virtual Task<GenerateGroundedContentResponse> GenerateGroundedContentAsync(GenerateGroundedContentRequest request, CancellationToken cancellationToken)

Generates grounded content.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.GenerateGroundedContentRequest` The request object containing all of the parameters for the API call. |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` A [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) to use for this RPC. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.GenerateGroundedContentResponse` | A Task containing the RPC response. |

**Example**

    // Create client
    GroundedGenerationServiceClient groundedGenerationServiceClient = await GroundedGenerationServiceClient.CreateAsync();
    // Initialize request argument(s)
    GenerateGroundedContentRequest request = new GenerateGroundedContentRequest
    {
        LocationAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
        Contents =
        {
            new GroundedGenerationContent(),
        },
        GenerationSpec = new GenerateGroundedContentRequest.Types.GenerationSpec(),
        GroundingSpec = new GenerateGroundedContentRequest.Types.GroundingSpec(),
        SystemInstruction = new GroundedGenerationContent(),
        UserLabels = { { "", "" }, },
    };
    // Make the request
    GenerateGroundedContentResponse response = await groundedGenerationServiceClient.GenerateGroundedContentAsync(request);

### ShutdownDefaultChannelsAsync()

    public static Task ShutdownDefaultChannelsAsync()

Shuts down any channels automatically created by [Create()](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.GroundedGenerationServiceClient#Google_Cloud_DiscoveryEngine_V1Beta_GroundedGenerationServiceClient_Create) and
[CreateAsync(CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.GroundedGenerationServiceClient#Google_Cloud_DiscoveryEngine_V1Beta_GroundedGenerationServiceClient_CreateAsync_System_Threading_CancellationToken_). Channels which weren't automatically created are not
affected.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task` | A task representing the asynchronous shutdown operation. |

**Remarks** After calling this method, further calls to [Create()](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.GroundedGenerationServiceClient#Google_Cloud_DiscoveryEngine_V1Beta_GroundedGenerationServiceClient_Create) and
[CreateAsync(CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.GroundedGenerationServiceClient#Google_Cloud_DiscoveryEngine_V1Beta_GroundedGenerationServiceClient_CreateAsync_System_Threading_CancellationToken_) will create new channels, which could in turn be shut down
by another call to this method.

### StreamGenerateGroundedContent(CallSettings, BidirectionalStreamingSettings)

    public virtual GroundedGenerationServiceClient.StreamGenerateGroundedContentStream StreamGenerateGroundedContent(CallSettings callSettings = null, BidirectionalStreamingSettings streamingSettings = null)

Generates grounded content in a streaming fashion.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |
| `streamingSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.BidirectionalStreamingSettings.html` If not null, applies streaming overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.GroundedGenerationServiceClienthttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.GroundedGenerationServiceClient.StreamGenerateGroundedContentStream` | The client-server stream. |

**Example**

    // Create client
    GroundedGenerationServiceClient groundedGenerationServiceClient = GroundedGenerationServiceClient.Create();
    // Initialize streaming call, retrieving the stream object
    using GroundedGenerationServiceClient.StreamGenerateGroundedContentStream response = groundedGenerationServiceClient.StreamGenerateGroundedContent();

    // Sending requests and retrieving responses can be arbitrarily interleaved
    // Exact sequence will depend on client/server behavior

    // Create task to do something with responses from server
    Task responseHandlerTask = Task.Run(async () =>
    {
        // Note that C# 8 code can use await foreach
        AsyncResponseStream<GenerateGroundedContentResponse> responseStream = response.GetResponseStream();
        while (await responseStream.MoveNextAsync())
        {
            GenerateGroundedContentResponse responseItem = responseStream.Current;
            // Do something with streamed response
        }
        // The response stream has completed
    });

    // Send requests to the server
    bool done = false;
    while (!done)
    {
        // Initialize a request
        GenerateGroundedContentRequest request = new GenerateGroundedContentRequest
        {
            LocationAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
            Contents =
            {
                new GroundedGenerationContent(),
            },
            GenerationSpec = new GenerateGroundedContentRequest.Types.GenerationSpec(),
            GroundingSpec = new GenerateGroundedContentRequest.Types.GroundingSpec(),
            SystemInstruction = new GroundedGenerationContent(),
            UserLabels = { { "", "" }, },
        };
        // Stream a request to the server
        await response.WriteAsync(request);
        // Set "done" to true when sending requests is complete
    }

    // Complete writing requests to the stream
    await response.WriteCompleteAsync();
    // Await the response handler
    // This will complete once all server responses have been processed
    await responseHandlerTask;