mirror of
https://github.com/hanzoai/csharp-sdk.git
synced 2026-11-06 21:39:15 +00:00
This name held the Hanzo SDK until it moved to github.com/hanzo-csharp/sdk. The README links there: install, quickstart, and each example. Co-authored-by: Hanzo Dev <[email protected]>
2.5 KiB
2.5 KiB
Hanzo C# SDK → hanzo-csharp/sdk
The Hanzo C# SDK lives at github.com/hanzo-csharp/sdk: every /v1
operation of api.hanzo.ai as a typed method, generated from the API document
each cloud release publishes. This repository is its old address and holds no
code. Issues and pull requests go to hanzo-csharp/sdk.
Install
.NET 8 or newer, from nuget.org:
dotnet add package Hanzo
Quickstart
using Hanzo.AI;
using Hanzo.AI.Api;
using Hanzo.AI.Model;
var config = Gateway.Configuration(); // HANZO_API_KEY, HANZO_BASE_URL, HANZO_ORG_ID
foreach (var key in new AccountApi(config).GetAccountKeys().Keys)
{
Console.WriteLine($"{key.Type} {key.Prefix}");
}
var reply = new AiApi(config).PostChatCompletions(new OpenaiChatCompletionRequest(
model: "zen5",
messages: new() { new OpenaiChatCompletionMessage(role: "user", content: "Say hello.") }));
Console.WriteLine(reply.Choices[0].Message.Content);
Examples
Each a complete program in the SDK, compiled against it on every release:
| flow | what it does |
|---|---|
| hello | GET /v1/account/keys: prove the key works |
| chat | POST /v1/chat/completions: one completion |
| money | GET /v1/billing/balance, GET /v1/billing/usage |
| store | create a KV store, read it back, delete it |
| agent | create an agent, run it, poll the run to completion |
| tools | GET /v1/tool: the tool catalog the key reaches |
| kai | POST /v1/decisions: a Kai decision, in the Kai cookbook |