diff --git a/src/xAI/GrokClient.cs b/src/xAI/GrokClient.cs
index 3a9a4c5..45e6e4c 100644
--- a/src/xAI/GrokClient.cs
+++ b/src/xAI/GrokClient.cs
@@ -7,9 +7,9 @@ namespace xAI;
/// Client for interacting with the Grok service.
/// The API key used for authentication.
/// The options used to configure the client.
-public class GrokClient(string apiKey, GrokClientOptions options)
+public sealed class GrokClient(string apiKey, GrokClientOptions options) : IDisposable
{
- static ConcurrentDictionary<(Uri, string), GrpcChannel> channels = [];
+ static readonly ConcurrentDictionary<(Uri, string), GrpcChannel> channels = [];
/// Initializes a new instance of the class with default options.
public GrokClient(string apiKey) : this(apiKey, new GrokClientOptions()) { }
@@ -36,6 +36,9 @@ public class GrokClient(string apiKey, GrokClientOptions options)
return GrpcChannel.ForAddress(Endpoint, options);
});
+ /// Clears the cached list of gRPC channels in the client.
+ public void Dispose() => channels.Clear();
+
class AuthenticationHeaderHandler(string apiKey) : DelegatingHandler
{
protected override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)