<PackageReference Include="System.ClientModel" Version="1.9.0" />

System.ClientModel.ApiKeyCredential

public class ApiKeyCredential
A credential used to authenticate to a service that accepts an API key. This type provides the ability to update the key's value without creating a new client.
public ApiKeyCredential(string key)

Initializes a new instance of the ApiKeyCredential class.

public void Deconstruct(out string key)

Deconstructs the credential into component values.

public void Update(string key)

Updates the API key to used to authenticate with the service. This method is intended to be called when the API key has been regenerated and long-lived clients need to be updated to send the new value.