diff --git a/src/xAI/GrokClient.cs b/src/xAI/GrokClient.cs index 45e6e4c..9bff022 100644 --- a/src/xAI/GrokClient.cs +++ b/src/xAI/GrokClient.cs @@ -1,6 +1,7 @@ using System.Collections.Concurrent; using System.Net.Http.Headers; using Grpc.Net.Client; +using xAI.Protocol; namespace xAI; @@ -23,6 +24,27 @@ public sealed class GrokClient(string apiKey, GrokClientOptions options) : IDisp /// Gets the options used to configure the client. public GrokClientOptions Options { get; } = options; + /// Gets a new instance of that reuses the client configuration details provided to the instance. + public Auth.AuthClient GetAuthClient() => new(Channel); + + /// Gets a new instance of that reuses the client configuration details provided to the instance. + public Chat.ChatClient GetChatClient() => new(Channel); + + /// Gets a new instance of that reuses the client configuration details provided to the instance. + public Documents.DocumentsClient GetDocumentsClient() => new(Channel); + + /// Gets a new instance of that reuses the client configuration details provided to the instance. + public Embedder.EmbedderClient GetEmbedderClient() => new(Channel); + + /// Gets a new instance of that reuses the client configuration details provided to the instance. + public Image.ImageClient GetImageClient() => new(Channel); + + /// Gets a new instance of that reuses the client configuration details provided to the instance. + public Models.ModelsClient GetModelsClient() => new(Channel); + + /// Gets a new instance of that reuses the client configuration details provided to the instance. + public Tokenize.TokenizeClient GetTokenizeClient() => new(Channel); + internal GrpcChannel Channel => channels.GetOrAdd((Endpoint, ApiKey), key => { var handler = new AuthenticationHeaderHandler(ApiKey) diff --git a/src/xAI/GrokClientExtensions.cs b/src/xAI/GrokClientExtensions.cs index 34e3867..49910d7 100644 --- a/src/xAI/GrokClientExtensions.cs +++ b/src/xAI/GrokClientExtensions.cs @@ -1,5 +1,6 @@ using System.ComponentModel; using Microsoft.Extensions.AI; +using xAI.Protocol; namespace xAI; @@ -10,4 +11,8 @@ public static class GrokClientExtensions /// Creates a new from the specified using the given model as the default. public static IChatClient AsIChatClient(this GrokClient client, string defaultModelId) => new GrokChatClient(client.Channel, client.Options, defaultModelId); -} + + /// Creates a new from the specified using the given model as the default. + public static IChatClient AsIChatClient(this Chat.ChatClient client, string defaultModelId) + => new GrokChatClient(client, defaultModelId); +} \ No newline at end of file