Table of Contents

Class ApiKeyConfig

Namespace
Google.GenAI.Types
Assembly
Google.GenAI.dll

Config for authentication with API key. This data type is not supported in Gemini API.

public record ApiKeyConfig : IEquatable<ApiKeyConfig>
Inheritance
ApiKeyConfig
Implements
Inherited Members

Properties

ApiKeySecret

Optional. The name of the SecretManager secret version resource storing the API key. Format: projects/{project}/secrets/{secrete}/versions/{version} - If both api_key_secret and api_key_string are specified, this field takes precedence over api_key_string. - If specified, the secretmanager.versions.access permission should be granted to Vertex AI Extension Service Agent (https://cloud.google.com/vertex-ai/docs/general/access-control#service-agents) on the specified resource.

[JsonPropertyName("apiKeySecret")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? ApiKeySecret { get; set; }

Property Value

string

ApiKeyString

Optional. The API key to be used in the request directly.

[JsonPropertyName("apiKeyString")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? ApiKeyString { get; set; }

Property Value

string

HttpElementLocation

Optional. The location of the API key.

[JsonPropertyName("httpElementLocation")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public HttpElementLocation? HttpElementLocation { get; set; }

Property Value

HttpElementLocation?

Name

Optional. The parameter name of the API key. E.g. If the API request is "https://example.com/act?api_key=", "api_key" would be the parameter name.

[JsonPropertyName("name")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Name { get; set; }

Property Value

string

Methods

FromJson(string, JsonSerializerOptions?)

Deserializes a JSON string to a ApiKeyConfig object.

public static ApiKeyConfig? FromJson(string jsonString, JsonSerializerOptions? options = null)

Parameters

jsonString string

The JSON string to deserialize.

options JsonSerializerOptions

Optional JsonSerializerOptions.

Returns

ApiKeyConfig

The deserialized ApiKeyConfig object, or null if deserialization fails.