Chalk.Client 1.0.2

dotnet add package Chalk.Client --version 1.0.2
                    
NuGet\Install-Package Chalk.Client -Version 1.0.2
                    
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="Chalk.Client" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Chalk.Client" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Chalk.Client" />
                    
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 Chalk.Client --version 1.0.2
                    
#r "nuget: Chalk.Client, 1.0.2"
                    
#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 Chalk.Client@1.0.2
                    
#: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=Chalk.Client&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Chalk.Client&version=1.0.2
                    
Install as a Cake Tool

Chalk C# Client

Official C# client library for the Chalk feature platform.

Installation

dotnet add package Chalk.Client

Quick Start

using Chalk;
using Chalk.Models;

// Create a client using environment variables or chalk.yaml
using var client = ChalkClient.Create();

// Or use the builder for custom configuration
using var client = ChalkClient.Builder()
    .WithClientId("your-client-id")
    .WithClientSecret("your-client-secret")
    .WithEnvironmentId("your-environment-id")
    .Build();

// Execute an online query
var queryParams = new OnlineQueryParamsBuilder()
    .WithInput("user.id", 123)
    .WithOutputs("user.name", "user.email", "user.credit_score")
    .Build();

var result = await client.OnlineQueryAsync(queryParams);

// Get individual values
var name = result.GetValue<string>("user.name");
var creditScore = result.GetValue<double>("user.credit_score");

Configuration

The client can be configured in multiple ways, with the following precedence:

  1. Builder methods (highest priority)
  2. Environment variables
  3. chalk.yaml/chalk.yml file
  4. Default values

Environment Variables

Variable Description
CHALK_CLIENT_ID Client ID for authentication
CHALK_CLIENT_SECRET Client secret for authentication
CHALK_ACTIVE_ENVIRONMENT Environment ID
CHALK_API_SERVER API server URL (default: https://api.chalk.ai)
CHALK_QUERY_SERVER Custom query server URL
CHALK_BRANCH Branch name
CHALK_DEPLOYMENT_TAG Deployment tag

chalk.yaml

Create a chalk.yaml or chalk.yml file in your project root or home directory (~/.chalk.yml):

client_id: your-client-id
client_secret: your-client-secret
active_environment: your-environment-id
api_server: https://api.chalk.ai

Bulk Queries

For multiple rows, pass lists of values:

var queryParams = new OnlineQueryParamsBuilder()
    .WithInput("user.id", new List<object?> { 1, 2, 3 })
    .WithOutputs("user.name", "user.email")
    .Build();

var result = await client.OnlineQueryAsync(queryParams);

// Get all values for a feature
var names = result.GetValues<string>("user.name");

Query Options

var queryParams = new OnlineQueryParamsBuilder()
    .WithInput("user.id", 123)
    .WithOutputs("user.name")
    // Set staleness for features
    .WithStaleness(new Dictionary<string, TimeSpan>
    {
        ["user.name"] = TimeSpan.FromMinutes(5)
    })
    // Add metadata
    .WithMeta(new Dictionary<string, string>
    {
        ["source"] = "my-app"
    })
    // Add tags
    .WithTags("production", "v2")
    // Include execution metadata in response
    .WithIncludeMeta()
    // Set query name for tracking
    .WithQueryName("get-user-profile")
    // Set correlation ID for tracing
    .WithCorrelationId(Guid.NewGuid().ToString())
    // Set timeout
    .WithTimeout(TimeSpan.FromSeconds(30))
    .Build();

Error Handling

try
{
    var result = await client.OnlineQueryAsync(queryParams);

    // Check for server-side errors
    if (result.Errors.Count > 0)
    {
        foreach (var error in result.Errors)
        {
            Console.WriteLine($"Error: {error.Code} - {error.Message}");
        }
    }
}
catch (ClientException ex)
{
    // Configuration or serialization errors
    Console.WriteLine($"Client error: {ex.Message}");
}
catch (ServerException ex)
{
    // HTTP or API errors
    Console.WriteLine($"Server error {ex.StatusCode}: {ex.Message}");
}

gRPC Client

For high-performance scenarios, you can use the gRPC client:

using var client = ChalkClient.CreateGrpc();

// Or via builder
using var client = ChalkClient.Builder()
    .WithClientId("your-client-id")
    .WithClientSecret("your-client-secret")
    .WithGrpc()
    .Build();

Note: The current gRPC implementation uses HTTP for online queries. Full gRPC protocol support is planned for a future release.

Building from Source

Prerequisites

  • .NET 6.0 SDK or later
  • (Optional) Mono for macOS testing

Build

dotnet build

Test

dotnet test

Test with Mono (macOS)

brew install mono
dotnet publish -c Release
mono ./publish/Chalk.Client.Tests.dll

License

Apache License 2.0

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
1.0.2 83 5/20/2026
1.0.1 107 4/14/2026
1.0.0 25,956 3/2/2026