SmooAI.Config
4.5.0
See the version list below for details.
dotnet add package SmooAI.Config --version 4.5.0
NuGet\Install-Package SmooAI.Config -Version 4.5.0
<PackageReference Include="SmooAI.Config" Version="4.5.0" />
<PackageVersion Include="SmooAI.Config" Version="4.5.0" />
<PackageReference Include="SmooAI.Config" />
paket add SmooAI.Config --version 4.5.0
#r "nuget: SmooAI.Config, 4.5.0"
#:package SmooAI.Config@4.5.0
#addin nuget:?package=SmooAI.Config&version=4.5.0
#tool nuget:?package=SmooAI.Config&version=4.5.0
SmooAI.Config
.NET client for SmooAI.Config — the OpenAI-compatible configuration service for your entire stack. One schema, one API, every language. Typed access to public values, secrets, and feature flags from any .NET app, with a local-baked runtime for zero-latency cold starts.
Wire-compatible with the TypeScript, Python, Rust and Go clients — the same encrypted bundle decrypts and resolves to the same keys no matter which language you ship.
Install
dotnet add package SmooAI.Config
What you get
- HTTP client with OAuth2 client-credentials auth, token caching, and 401 retry
- Local runtime — AES-256-GCM decrypt of a baked config bundle for zero-network reads at cold start
- Build pipeline — fetch all values and encrypt them into a bundle your deploy tool ships with the function
- Strongly-typed keys via a Roslyn source generator — mis-typed keys fail at compile time
- Feature flag support — live-fetched through the client, never baked
Quickstart
1. Point the generator at your schema
In your csproj:
<ItemGroup>
<AdditionalFiles Include="schema.json" SmooConfigSchema="true" />
</ItemGroup>
Your schema.json (emitted by smooai-config init / smooai-config push):
{
"publicConfigSchema": { "apiUrl": "stringSchema", "retries": "numberSchema" },
"secretConfigSchema": { "moonshotApiKey": "stringSchema", "anthropicApiKey": "stringSchema" },
"featureFlagSchema": { "newFlow": "booleanSchema" }
}
2. Use the generated typed keys
using SmooAI.Config;
using SmooAI.Config.Generated;
using SmooAI.Config.Runtime;
var runtime = SmooConfigRuntime.Load(); // reads SMOO_CONFIG_KEY_FILE + SMOO_CONFIG_KEY
using var client = new SmooConfigClient(new SmooConfigClientOptions
{
ClientId = Environment.GetEnvironmentVariable("SMOOAI_CLIENT_ID")!,
ClientSecret = Environment.GetEnvironmentVariable("SMOOAI_CLIENT_SECRET")!,
OrgId = Environment.GetEnvironmentVariable("SMOOAI_ORG_ID")!,
});
// Public + secret come from the baked runtime (sync, no network).
// Feature flags fall through to the HTTP client automatically.
var apiUrl = await Public.ApiUrl.ResolveAsync(runtime, client);
var moonshot = await Secrets.MoonshotApiKey.ResolveAsync(runtime, client);
var newFlow = await FeatureFlags.NewFlow.ResolveAsync(runtime, client);
No stringly-typed keys. Rename a key in schema.json and every call site
becomes a compile-time error.
The three pieces
HTTP client
OAuth2 client-credentials flow against {baseUrl}/token (with the api.
subdomain rewritten to auth.), tokens cached in memory and refreshed 60
seconds before expiry, automatic 401 retry.
using var client = new SmooConfigClient(new SmooConfigClientOptions
{
ClientId = "...",
ClientSecret = "sk_...",
OrgId = "...",
BaseUrl = "https://api.smoo.ai", // default
DefaultEnvironment = "production", // default
});
// Untyped
JsonElement value = await client.GetValueAsync("moonshotApiKey");
Dictionary<string, JsonElement> all = await client.GetAllValuesAsync();
// Typed (via generated keys)
string? anthropic = await Secrets.AnthropicApiKey.GetAsync(client);
Local runtime
Decrypts a pre-built bundle at cold start and exposes it in-memory. Parity
with the TS / Python / Rust / Go runtimes — blob layout is
nonce (12 bytes) || ciphertext || authTag (16 bytes), AES-256-GCM.
Set two env vars on your function:
| Variable | Value |
|---|---|
SMOO_CONFIG_KEY_FILE |
Absolute path to the .enc bundle on disk |
SMOO_CONFIG_KEY |
Base64-encoded 32-byte AES-256 key |
var runtime = SmooConfigRuntime.Load(); // null when env vars are unset — dev fallback
if (runtime is null) {
// No baked bundle present; fall back to a live-fetching client.
}
var apiUrl = runtime?.GetPublic("apiUrl")?.GetString();
var retries = runtime?.GetValue<int>("retries");
Build pipeline
Bake all public + secret values into an encrypted bundle at deploy time. Feature flags are skipped — they stay live-fetched so you can flip them without a redeploy.
using var client = new SmooConfigClient(clientOptions);
var classify = SchemaClassifier.FromSchemaFile(".smooai-config/schema.json");
var result = await SmooConfigBuilder.BuildAsync(client, new BuildBundleOptions
{
Environment = "production",
Classify = classify,
});
File.WriteAllBytes("smoo-config.enc", result.Bundle);
Console.WriteLine($"SMOO_CONFIG_KEY_FILE={Path.GetFullPath("smoo-config.enc")}");
Console.WriteLine($"SMOO_CONFIG_KEY={result.KeyB64}");
Console.WriteLine($"Baked {result.KeyCount} keys ({result.SkippedCount} feature flags skipped).");
Ship smoo-config.enc alongside the function bundle, set the two env vars
on the function, and the runtime picks up both automatically.
Wire compatibility
The .NET client produces and consumes exactly the same bundle format
as every other SmooAI.Config language client:
@smooai/config(TypeScript)smooai-config(Python)smooai_config(Rust)github.com/smooai/config/go(Go)
You can bake the bundle in any language and decrypt it in any other.
Links
- Homepage: smoo.ai
- Source: github.com/SmooAI/config
- Issues: github.com/SmooAI/config/issues
- License: MIT
| Product | Versions 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 was computed. 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 was computed. 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. |
-
net8.0
- Microsoft.Extensions.Http (>= 8.0.0)
- Microsoft.Extensions.Options (>= 8.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.