Skip to content

HammingAI

Nuget package dotnet License: MIT Discord

Features 🔥

  • Fully generated C# SDK based on Hamming AI API using AutoSDK
  • Voice agent testing, evaluation, and production monitoring
  • Supports Vapi, RetellAI, Bland, LiveKit, and other voice agent platforms
  • All modern .NET features - nullability, trimming, NativeAOT, etc.
  • MEAI AIFunction tools for integration with any IChatClient

Usage

1
2
3
using HammingAI;

using var client = new HammingAIClient(apiKey);

Getting Started

Shows how to create a client and list datasets.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
using var client = new HammingAIClient(apiKey);

// List all datasets in the workspace.
var response = await client.Datasets.ListDatasetsAsync();

Console.WriteLine($"Found {response.Datasets!.Count} datasets.");

foreach (var dataset in response.Datasets)
{
    Console.WriteLine($"- {dataset.Id}: {dataset.Name}");
}

Voice Agent Testing

Shows how to run a voice agent test and retrieve experiment results.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using var client = new HammingAIClient(apiKey);

var agentId =
    Environment.GetEnvironmentVariable("HAMMING_AGENT_ID") is { Length: > 0 } agentValue
        ? agentValue
        : throw new AssertInconclusiveException("HAMMING_AGENT_ID environment variable is not found.");

var datasetId =
    Environment.GetEnvironmentVariable("HAMMING_DATASET_ID") is { Length: > 0 } datasetValue
        ? datasetValue
        : throw new AssertInconclusiveException("HAMMING_DATASET_ID environment variable is not found.");

var toNumber =
    Environment.GetEnvironmentVariable("HAMMING_TO_NUMBER") is { Length: > 0 } numberValue
        ? numberValue
        : throw new AssertInconclusiveException("HAMMING_TO_NUMBER environment variable is not found.");

// Start a voice agent test run with the specified dataset scenarios.
var runResponse = await client.VoiceAgents.RunVoiceAgentAsync(
    agentId: agentId,
    toNumber: toNumber,
    datasetId: datasetId);

Console.WriteLine($"Voice Experiment ID: {runResponse.VoiceExperimentId}");

// Check the status of the voice experiment.
var statusResponse = await client.VoiceAgents.GetVoiceExperimentAsync(
    voiceExperimentId: runResponse.VoiceExperimentId!);

Console.WriteLine($"Status: {statusResponse.Status}");

// Retrieve call results once the experiment finishes.
var callsResponse = await client.VoiceAgents.GetVoiceExperimentCallsAsync(
    voiceExperimentId: runResponse.VoiceExperimentId!);

Console.WriteLine($"Calls: {callsResponse.Calls!.Count}");

foreach (var call in callsResponse.Calls)
{
    Console.WriteLine($"- Call {call.Id}: scoring={call.ScoringStatus}, duration={call.DurationMs}ms");
}

Prompts

Shows how to list and retrieve prompts with their content.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
using var client = new HammingAIClient(apiKey);

// List all prompts in the workspace.
var promptsList = await client.Prompts.ListPromptsAsync();

Console.WriteLine($"Found {promptsList.Prompts!.Count} prompts.");

// Get a specific prompt by slug to see its content.
if (promptsList.Prompts.Count > 0)
{
    var slug = promptsList.Prompts[0].Slug!;
    var promptResponse = await client.Prompts.GetPromptAsync(slug: slug);

    var promptValue = promptResponse.Prompt!.Value;
    Console.WriteLine($"Prompt slug: {promptValue.Value1?.Slug}");

    if (promptValue.Value2?.Content is not null)
    {
        Console.WriteLine($"Model: {promptValue.Value2.Content.LanguageModel}");
        Console.WriteLine($"Messages: {promptValue.Value2.Content.ChatMessages?.Count ?? 0}");
    }
}

AIFunction Tools

Shows how to use HammingAI as MEAI AIFunction tools with any IChatClient.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
using var client = new HammingAIClient(apiKey);

// Create AIFunction tools for use with any IChatClient.
var runTestTool = client.AsRunVoiceAgentTestTool();
var getStatusTool = client.AsGetVoiceExperimentStatusTool();
var getCallsTool = client.AsGetVoiceExperimentCallsTool();
var listDatasetsTool = client.AsListDatasetsTool();

// Pass these tools to any IChatClient via ChatOptions.Tools.
Console.WriteLine($"Available tools: {runTestTool.Name}, {getStatusTool.Name}, {getCallsTool.Name}, {listDatasetsTool.Name}");

Support

Priority place for bugs: https://github.com/tryAGI/HammingAI/issues
Priority place for ideas and general questions: https://github.com/tryAGI/HammingAI/discussions
Discord: https://discord.gg/Ca2xhfBf3v

Acknowledgments

JetBrains logo

This project is supported by JetBrains through the Open Source Support Program.