Hello world: .NET
Ready — installs from the CloakAPI downloads page. Tested end to end on Linux x86-64.
Runs today on Linux x86-64. On macOS, Windows and ARM the on-device engine is not available yet; the SDK uses basic detection and shows a warning.
Requires .NET 8.0+.
1. Get an API key
Create a key at app.cloakapi.io/api-keys. It starts with cloak_. Verify your email to unlock your trial balance.
2. Install
Set up the on-device engine and pin: Engine setup.
mkdir -p feedcurl -fsSL -o feed/CloakAPI.Sdk.1.2.1.nupkg \ https://app.cloakapi.io/downloads/sdks/dotnet/CloakAPI.Sdk.1.2.1.nupkgdotnet nuget add source "$(pwd)/feed" --name cloakapi-localFrom this repository:
cd repo/sdk/dotnetdotnet pack src/CloakAPI.Sdk/CloakAPI.Sdk.csproj -p:PackageVersion=1.2.1 -o feeddotnet build examples/Hello/Hello.csproj3. Set your key
export CLOAKAPI_API_KEY="cloak_your_key_here"4. Run hello world
using CloakAPI;
const string Prompt = "Say hello to jane.doe@example.com in one short sentence.";
var apiKey = Environment.GetEnvironmentVariable("CLOAKAPI_API_KEY");if (string.IsNullOrEmpty(apiKey)){ Console.Error.WriteLine("CLOAKAPI_API_KEY is not set. Create a key at https://app.cloakapi.io/api-keys"); return 1;}
using var client = new CloakAPIClient(apiKey, new ClientConfig{ ReviewEgressAsync = async (review, ct) => { Console.WriteLine($"This exact request will leave your machine:\n\n{review.Path}\n{review.Preview}"); Console.Write("\nSend it? [y/N] "); return string.Equals(Console.ReadLine()?.Trim(), "y", StringComparison.OrdinalIgnoreCase); },});
try{ var resp = await client.Messages.CreateAsync(new() { Model = "claude-sonnet-4-6", Messages = [new() { Role = "user", Content = Prompt }], MaxTokens = 100, }); Console.WriteLine("\nReply (restored on your device):"); Console.WriteLine(resp.FirstText()); return 0;}catch (Exception e){ Console.Error.WriteLine($"Request failed: {e.Message}"); return 1;}cd repo/sdk/dotnetdotnet run --project examples/Hello/Hello.csproj5. What you should see
You’ll see the exact request before it is sent. Your email address is replaced with a token like <<CLOAK:CONTACT_EM:3f9a1c>>. Type y. The reply comes back with the real address restored on your device. The reply text varies.
If something goes wrong
See the .NET SDK README for common messages and fixes.
What this does and does not do
- Detection is best-effort. Emails, phone numbers, cards and similar are matched by rules; names use an on-device list and an optional on-device model, and may be missed.
- You see the exact request before it is sent.
- CloakAPI does not refuse a request because of what it contains. Errors come from your key, balance, usage limits, request format or size, or the model provider.
- The gateway does not run detection on your content. It checks the request proof, then relays it to the model provider.