Licensing AI features and autonomous agents
Keyright 2.9.0 adds first-class AI and agent entitlements: name the models, endpoints and tools a customer may call, cap an autonomous agent with a credit budget and a lease, and enforce all of it fail-closed and offline from a signed license — with a metered POST /v1/consume for running usage. Here is the entitlement shape, the signed JSON, the SDK helpers in C#, Node, Python and Java, and a concrete deny-the-unlicensed-model scenario.
A license used to answer one question about AI features: may this customer use them at all? That is no longer enough. An AI product today is a set of distinct, separately-priced capabilities — which models, which providers, which tools an agent may call — and an autonomous agent is a process that spends real money on every step it takes. “Licensed: yes” says nothing about whether this customer’s agent may call gpt-5, reach a third-party endpoint, invoke a shell tool, or burn ten thousand credits in a loop overnight.
Keyright 2.9.0 makes those the first-class things a license grants. AI and agent entitlements name the models, endpoints and tools a build may touch, and bound an autonomous agent with a credit budget and a lease — all enforced fail-closed and offline from the signed license, with an opt-in metered POST /v1/consume for running usage across instances.
The entitlement shape
Six conventional keys sit on a license tier as a template; issuing a license at that tier bakes them into the signed lease the customer activates.
ai.enabled— the master switch. Boolean. Whenfalse, nothing else matters.ai.models— an allow-list of model identifiers the build may call, e.g.openai/gpt-5,anthropic/claude-sonnet-4.6.ai.endpoints— the API hosts a build may reach, e.g.api.openai.com.ai.tools— the tool names an agent may invoke, e.g.web.search,code.run.agent.budget.credits— the hard ceiling of credits one agent may spend.agent.lease.seconds— how long an agent may run before its lease must be renewed.
The three list-valued keys are allow-lists with wildcards. A * matches any single segment, so openai/gpt-* admits openai/gpt-5 and openai/gpt-5-mini but not openai/o3; a bare * admits everything in that dimension. Allow-lists fail closed: a model, endpoint or tool that matches nothing on the list is denied. You grant by naming; you never have to enumerate what is forbidden.
A signed license, carrying AI entitlements
Here is what a Pro-tier agent license looks like once issued. The ent block is the entitlement template baked in at issue time; the whole payload is signed, so every value below is tamper-evident.
{
"sub": "acme-corp",
"product": "atlas-agent",
"tier": "pro",
"exp": "2027-11-12T00:00:00Z",
"ent": {
"ai.enabled": true,
"ai.models": ["openai/gpt-5", "openai/gpt-5-mini", "anthropic/claude-*"],
"ai.endpoints": ["api.openai.com", "api.anthropic.com"],
"ai.tools": ["web.search", "code.run", "file.read"],
"agent.budget.credits": 50000,
"agent.lease.seconds": 3600
},
"sig": "ed25519:9f2c…c41a"
}
Note what this grants: any current Claude model (anthropic/claude-*) but only two specific OpenAI models; two provider endpoints; three tools; fifty thousand credits per agent; a one-hour lease. Change any character — add a model, raise the ceiling — and the Ed25519 signature no longer verifies against the public key the app embeds at build time. The check fails closed rather than silently granting more.
Reading and enforcing in your app
The SDK parses the entitlements from the verified lease once, then answers synchronously with no network call. In C#, the AI entitlements hang off info.Ai:
var client = KeyrightClient.Initialize(options);
var info = await client.ActivateAsync(licenseKey); // lease cached locally
// Guard the master switch first.
if (!info.Ai.Enabled)
throw new FeatureNotLicensedException("ai");
// Soft check — branch without throwing.
if (info.Ai.AllowsModel("openai/gpt-5"))
useModel("openai/gpt-5");
// Hard check — throws ModelNotLicensedException when the model is not allowed.
info.Ai.EnforceModel(requestedModel);
// Endpoints and tools work the same way.
info.Ai.EnforceEndpoint("api.openai.com");
info.Ai.EnforceTool("code.run");
// The per-agent budget ceiling is readable offline.
long ceiling = info.AgentBudgetCredits; // 50000, straight from the signed lease
AllowsModel returns a boolean after matching the identifier against ai.models, wildcards included; EnforceModel is the throwing form you put at the boundary of the call itself. Both fail closed: an unknown model is denied, and a lease with no ai.models key grants nothing.
The same surface exists in the other SDKs — same identifiers, same wildcard semantics, idiomatic casing:
// Node
if (info.ai.allowsModel("anthropic/claude-sonnet-4.6")) { /* ... */ }
info.ai.enforceModel(requestedModel); // throws when not allowed
# Python
if info.ai.allows_model("anthropic/claude-sonnet-4.6"):
...
info.ai.enforce_model(requested_model) # raises when not allowed
// Java
if (info.ai().allowsModel("anthropic/claude-sonnet-4.6")) { /* ... */ }
info.ai().enforceModel(requestedModel); // throws when not allowed
Metering a per-agent credit budget
agent.budget.credits is the offline ceiling — a hard cap an air-gapped agent self-limits against. But a real agent fleet shares one budget across many concurrent instances, and each needs to know the running total, not just the cap. That is what POST /v1/consume meters.
Before (or after) a unit of work, the agent reports what it spent. The service decrements a shared counter keyed to the license and returns the remaining balance; when a charge would take the balance below zero it is rejected, and the agent stops. The call is the only part of AI enforcement that touches the network, and only when you opt into shared metering.
// Charge the shared budget for one step. Fails closed when exhausted.
var result = await client.ConsumeAsync(new ConsumeRequest
{
AgentId = agentId,
Credits = step.EstimatedCredits
});
if (!result.Granted)
throw new AgentBudgetExhaustedException(result.Remaining); // Remaining == 0
logger.LogInformation("Agent {Agent} spent {Spent}; {Left} credits left",
agentId, step.EstimatedCredits, result.Remaining);
The offline ceiling and the online meter compose. An agent that cannot reach the service still cannot exceed info.AgentBudgetCredits locally; an agent that can reach it additionally cannot exceed the shared balance, so ten instances cannot each spend the full ceiling. agent.lease.seconds bounds the other axis: a runaway agent whose lease has lapsed stops regardless of remaining credits.
A concrete gating scenario
Put it together. A customer on the license above spins up an agent and, on step three, the planner asks for openai/o3 — a model not on their allow-list — then requests a 40,000-credit batch.
public async Task RunStep(AgentStep step)
{
// 1. Deny the unlicensed model, before any provider call or spend.
if (!info.Ai.AllowsModel(step.Model))
throw new ModelNotLicensedException(step.Model); // "openai/o3" is denied
// 2. Enforce the tool and endpoint the step wants.
info.Ai.EnforceTool(step.Tool);
info.Ai.EnforceEndpoint(step.Endpoint);
// 3. Meter the spend against the shared per-agent budget.
var charge = await client.ConsumeAsync(new ConsumeRequest
{
AgentId = step.AgentId,
Credits = step.EstimatedCredits // 40000 requested
});
if (!charge.Granted)
throw new AgentBudgetExhaustedException(charge.Remaining);
await Execute(step);
}
openai/o3 is rejected at line one — offline, before a single token is bought — because it matches nothing in ai.models. Had the planner asked for openai/gpt-5-mini instead, the model check would pass, the tool and endpoint checks would pass, and the 40,000-credit charge would succeed against a fresh 50,000 ceiling — but a second such step would be rejected with Remaining == 10000 < 40000, and the agent would stop rather than overspend. No build change, no redeploy: moving openai/o3 into the plan, or raising the ceiling to 100,000, is a change to the tier template and a re-issued license.
Takeaway
Treat AI capabilities the way you already treat features: as named, signed entitlements your code checks locally. Let ai.models, ai.endpoints and ai.tools say what an agent may call and agent.budget.credits / agent.lease.seconds say how much and how long — enforce them fail-closed with AllowsModel / EnforceModel and meter shared spend through POST /v1/consume. The model allow-list, the tool allow-list and the budget ceiling all hold offline, straight from the signature; metering is the one thing you reach the network for, and only when a fleet shares a budget. Your packaging — which tier gets which models, how many credits — stays configuration on the server, not constants in your binary.
Try Nebula.NET
Harden your .NET code in minutes — start with the free edition.