XaiProtoSharp 2026.3.31

dotnet add package XaiProtoSharp --version 2026.3.31
                    
NuGet\Install-Package XaiProtoSharp -Version 2026.3.31
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="XaiProtoSharp" Version="2026.3.31" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="XaiProtoSharp" Version="2026.3.31" />
                    
Directory.Packages.props
<PackageReference Include="XaiProtoSharp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add XaiProtoSharp --version 2026.3.31
                    
#r "nuget: XaiProtoSharp, 2026.3.31"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package XaiProtoSharp@2026.3.31
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=XaiProtoSharp&version=2026.3.31
                    
Install as a Cake Addin
#tool nuget:?package=XaiProtoSharp&version=2026.3.31
                    
Install as a Cake Tool

XaiProtoSharp

NuGet License Build and Publish Docs

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2026.3.31 70 3/31/2026
2026.3.27 86 3/27/2026
2026.3.24 90 3/24/2026
2026.3.14 94 3/14/2026
2026.2.18 94 2/18/2026
2026.2.13 104 2/13/2026