Table of Contents

Class HttpApiClient

Namespace
Google.GenAI
Assembly
Google.GenAI.dll
public class HttpApiClient : ApiClient, IDisposable, IAsyncDisposable
Inheritance
HttpApiClient
Implements
Inherited Members

Constructors

HttpApiClient(bool?, bool?, string?, string?, string?, ICredential?, HttpOptions?, ClientOptions?)

public HttpApiClient(bool? enterprise = null, bool? vertexAI = null, string? apiKey = null, string? project = null, string? location = null, ICredential? credentials = null, HttpOptions? httpOptions = null, ClientOptions? clientOptions = null)

Parameters

enterprise bool?
vertexAI bool?
apiKey string
project string
location string
credentials ICredential
httpOptions HttpOptions
clientOptions ClientOptions

Methods

RequestAsync(HttpMethod, string, string, HttpOptions?, CancellationToken)

Sends an HTTP request given the HTTP method, path, and request JSON string.

public override Task<ApiResponse> RequestAsync(HttpMethod httpMethod, string path, string requestJson, HttpOptions? requestHttpOptions, CancellationToken cancellationToken = default)

Parameters

httpMethod HttpMethod
path string
requestJson string
requestHttpOptions HttpOptions
cancellationToken CancellationToken

Returns

Task<ApiResponse>

RequestStreamAsync(HttpMethod, string, string, HttpOptions?, CancellationToken)

Sends an HTTP request for streaming responses that return Server-Sent Events.

public override IAsyncEnumerable<ApiResponse> RequestStreamAsync(HttpMethod httpMethod, string path, string requestJson, HttpOptions? requestHttpOptions, CancellationToken cancellationToken = default)

Parameters

httpMethod HttpMethod

The HTTP method to use.

path string

The API path.

requestJson string

The request body as JSON string.

requestHttpOptions HttpOptions

Optional HTTP options.

cancellationToken CancellationToken

The cancellation token to use.

Returns

IAsyncEnumerable<ApiResponse>

An async enumerable of ApiResponse chunks.