XaiProtoSharp 2026.3.31
dotnet add package XaiProtoSharp --version 2026.3.31
NuGet\Install-Package XaiProtoSharp -Version 2026.3.31
<PackageReference Include="XaiProtoSharp" Version="2026.3.31" />
<PackageVersion Include="XaiProtoSharp" Version="2026.3.31" />
<PackageReference Include="XaiProtoSharp" />
paket add XaiProtoSharp --version 2026.3.31
#r "nuget: XaiProtoSharp, 2026.3.31"
#:package XaiProtoSharp@2026.3.31
#addin nuget:?package=XaiProtoSharp&version=2026.3.31
#tool nuget:?package=XaiProtoSharp&version=2026.3.31
XaiProtoSharp
Auto-generated C# gRPC client for the xAI API, built from protobuf definitions in xai-org/xai-proto.
Disclaimer: This is an unofficial, community-maintained project. All library code is auto-generated from upstream protobuf definitions and is provided as-is with no guarantee of functionality. This project is not affiliated with or endorsed by xAI. Use at your own risk.
Installation
Install via NuGet:
dotnet add package XaiProtoSharp
Quick Start
using Grpc.Core;
using Grpc.Net.Client;
using XaiApi;
// Create a gRPC channel
var channel = GrpcChannel.ForAddress("https://api.x.ai");
var client = new Chat.ChatClient(channel);
// Authenticate with your API key
var headers = new Metadata
{
{ "Authorization", $"Bearer {apiKey}" }
};
// Send a chat completion request
var request = new GetCompletionsRequest
{
Model = "grok-4-1-fast-reasoning",
Messages =
{
new Message
{
Content = { new Content { Text = "Hello, world!" } },
Role = MessageRole.RoleUser
}
},
MaxTokens = 100
};
var response = client.GetCompletion(request, headers);
foreach (var output in response.Outputs)
{
Console.WriteLine(output.Message.Content);
}
Documentation
Browse the full API reference at dsdude123.github.io/XaiProtoSharp.
Supported Frameworks
- .NET 8.0
- .NET 9.0
- .NET 10.0
Building from Source
Prerequisites: .NET 10.0 SDK, Buf CLI (for code generation only)
# Build
dotnet build XaiProtoSharp.slnx
# Run tests (requires XAI_API_KEY environment variable)
dotnet test Xai.Protos.Test
To regenerate the gRPC client code from upstream protobuf definitions:
git clone https://github.com/xai-org/xai-proto.git xai-proto
buf generate xai-proto
Contributing
See CONTRIBUTING.md for guidelines on how to contribute to this project.
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Google.Api.Gax.Grpc (>= 4.13.0)
- Google.Protobuf (>= 3.33.5)
- Grpc.Net.Client (>= 2.76.0)
-
net8.0
- Google.Api.Gax.Grpc (>= 4.13.0)
- Google.Protobuf (>= 3.33.5)
- Grpc.Net.Client (>= 2.76.0)
-
net9.0
- Google.Api.Gax.Grpc (>= 4.13.0)
- Google.Protobuf (>= 3.33.5)
- Grpc.Net.Client (>= 2.76.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.