/limitr:limitr-networkfrom Limitr
Builds Limitr Network Protocol (LNP) services: providers selling routes to consumers, paid with signed vouchers instead of API keys. Covers policy network config, limitr.network() API, vouchers, receipts, metering, operators, and wire format.
Ships in Limitr. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Limitr Network lets one Limitr policy use another's services and pay for them. A provider publishes plans, prices,
and routes from its policy. A consumer signs a voucher ("up to this much, on this plan, until then"). The
provider makes a voucher customer (ID nv_<voucher>, type voucher) with the spend as a cap, and grants the
routes its plan reaches; on the consumer's side each route is a tool (a capability). Every request is signed by
the consumer's key and every response carries the provider's signed receipt. Prices are in runes (the
provider's exchange says what a rune is; 1 USD by default).
It's an optional module (src/network/): a policy that doesn't call limitr.network() never loads it. The whole
protocol, its HTTP included, runs in the policy; the host keeps the key, allows hosts, and passes requests to one
handler.
Docs in the repo: src/network/README.md (overview), src/network/SPEC.md (design), src/network/PROTOCOL.md
(wire format and test vectors), typescript/tutorial/network/ and python/tutorial/network/ (seven runnable chapters
each), typescript/demos/network/ and python/demos/network/.
Every field: references/config.md.
import { Limitr } from '@formata/limitr';
const weather = await Limitr.new(`
policy: {
credits: { forecast: { label: 'Forecast', unit: 'forecast', price: { amount: 0.01 } } }
plans: { agent: { label: 'Agents', entitlements: { forecasts: { limit: { credit: 'forecast', mode: 'soft', value: 0 } } } } }
network: {
provider: {
name: 'acme_weather' // names its tools: acme_weather_forecast
label: 'Acme Weather'
url: 'https://weather.example.com' // its public URL: the manifest and routes are under it
offers: ['agent'] // plans offered on the network
routes: {
forecast: {
description: 'Get the weather forecast for a city'
method: 'GET' // GET and DELETE take arguments as a query string, others a JSON body
path: '/forecast'
parameters: [{ name: 'city', description: 'The city' }]
entitlement: 'forecasts' // optional: metered before the work (value: 1 by default)
}
}
}
}
}`);
const network = await weather.network({ secretKey: process.env.WEATHER_SECRET_KEY });
export async function handler(request: Request): Promise<Response> {
return await network.handle(request, async ({ route, customer, subject, query, body, request }) => {
// runs only for signed, fresh, allowed requests; meter more here with `customer` if the route needs it
return { city: query.get('city'), forecast: 'sunny' }; // an object (JSON), a string, or a Response
});
}
handle serves the manifest (GET /.well-known/limitr-network), vouchers, cancels, and every route. It's
web-standard (Deno, Bun, Workers, Hono, Next.js as is; Node's http needs a small adapter, see the demo).secretKey): vouchers are made out to it. Without one a new key is made each start
(and given to keyStore). LimitrNetwork.generateKey() makes one up front.entitlement leaves metering to the work: await weather.allow(customer, 'summaries', tokens) (or reserve/settle), by whatever the policy counts. The request's cost (for its receipt)
is what it metered, measured by a cap the module puts on the voucher's customer for the request. A request nothing
meters is free. Return a Response with status 402 when the work's allow says no.revoke(voucher, reason) ends a voucher (returns the signed revoke to deliver); sweep() removes ended voucher
customers after keep_ended (handle runs it hourly).network.provider.tools declares tools ({ description, parameters, plans? }), each a function of the same name in
network.provider.logic (Stof source, part of the terms). They run on the consumer's side only with trust: 'logic',
loaded as untrusted source and sealed: no access to the consumer's policy, no objects, no HTTP or host libraries (only
<Network>.TOOL_LIBS), at most network.tool_time (30s). Their way out is self.api.call(route, args) (a signed,
metered request to one of this provider's routes; returns the body) and self.api.json(text).
logic: r#"
fn warmest(input: map) -> unknown {
let best = null;
for (const city in input.get('cities').split(',')) {
const f = self.api.json(self.api.call('forecast', map(('city', city.trim()))));
if (best == null || f.get('high') > best.get('high')) best = f;
}
best
}
"#
const agent = await Limitr.new('policy: {}');
const network = await agent.network({ name: 'support_agent' });
await network.connect('https://weather.example.com', 'agent', 0.03, Date.now() + 3600_000, { max: 0.01 });
const tools = await agent.claudeTools(); // for Claude
const result = await agent.runCapability('acme_weather_forecast', { city: 'Boston' });
const refused = network.refusal(result); // { provider, status, reason, spent, remaining, ... }
agent.addHandler('spend', (key, value) => {
if (key === 'network-receipt') console.log(JSON.parse(value as string)); // { name, voucher, n, cost, spent, remaining, ... }
});
await network.update('acme_weather', { spend: 0.10 }); // a newer voucher (more spend or time)
await network.trust('acme_weather', 'logic'); // add the provider's own tools
await network.connection('acme_weather'); // { spent, remaining, customer, subject, routes, tools, ... }
await network.cancel('acme_weather');
connect(url, plan, spend, expires, { budget, trust, mayCall, max }) reads and checks the manifest, signs the
voucher, takes the grant, and returns the new tools' names. The voucher agrees to the terms' exact digest, so new
terms need a new voucher.{ "refused": { status, reason, spent, remaining, ... } }
(and a network-refused event). 401: the signature, voucher, replay, or route; 402: limits, spend, or expiry; 503:
the provider's operator is unreachable. A provider's tool that fails gives { "failed": { ... } } (failure()).update() signs vouchers.max caps each request (runes), enforced by the provider on top of the voucher's spend.mayCall: ['acme_maps'] lets a trusted provider's tools call the consumer's other connections' routes.Optional parties both sides trust, by role, at most one per role, in network.operators:
network: {
operators: {
ours: { url: 'https://operator.example', key: '<its first public key>', roles: ['state', 'identity', 'discovery'],
state: { mode: 'strict' }, channel: true }
}
}
strict: each request claimed first, exact; bounded: leases,
fast, overshoot at most the outstanding leases), fail-closed by default (offline: 'refuse'). Budgets:
network.budget('ours', spend, expires, { providers }) then connect(..., { budget }); budgetInfo(id).network.identify() gets "this key is "; consumers send it with every voucher, providers put
theirs in their manifest. A provider requires one by default when it has an identity operator
(provider.identity: 'auto' | 'required' | 'optional', per plan with identity_plans); the work sees subject.
A consumer with require_identity: true connects only to identified providers.network.list('public' | 'private', { members, subjects }), unlist(), and
network.discover(query, { limit }) (signed; results are providers' own signed manifests: { key, name, label, url, terms }).limitr.network({ channels: { ours: (request) => response } }) (web-standard; another policy's network.operate is one). Never falls back to HTTP.Limitr.cloud() engine whose workspace has Limitr Network, limitr.network() adds Cloud as
operators.limitr (state, identity, discovery: the roles no operator in the policy serves) over the engine's
WebSocket, so identify(), budget('limitr', ...), list(), and discover() just work. { cloud: false } opts
out; a policy that names Cloud's key itself keeps its own entry.network.service (roles, identities, requires, rotations, ...), served
with network.operate(request). requires: ['provider', 'consumer'] refuses keys it hasn't identified.network.rotation(newPublicKey) returns a statement to
append to service.rotations, then it runs with the new key. Policies follow the chain; vouchers go on.checkOperators() reads and checks every operator's manifest.The same API in snake_case (pip install limitr; needs stof 0.12.0+). Python has no web-standard Request and
Response, so limitr has its own, plus WSGI and a small server:
import os, time
from limitr import Limitr, LimitrNetwork, Response
weather = Limitr(policy_source) # the provider policy above
network = weather.network(secret_key=os.environ['WEATHER_SECRET_KEY'])
def work(call): # a NetworkCall: route, customer, query, body, request, subject
if call.route == 'week' and not weather.allow(call.customer, 'forecasts', int(call.query.get('days', 7))):
return Response(402, body='not within this request')
return {'city': call.query.get('city'), 'forecast': 'sunny'} # dict as JSON, str as text, or a Response
app = network.wsgi(work) # gunicorn, waitress, or mounted in Flask or Django
# network.handle(request, work) takes a limitr.Request and returns a Response, for any other framework;
# network.serve(work, port=8787) runs it on a thread with the standard library (demos, tests, local tools)
agent = Limitr('policy: {}')
agent_net = agent.network(name='support_agent')
tools = agent_net.connect('https://weather.example', 'agent', 0.03, time.time() * 1000 + 3_600_000,
trust='logic', max=0.05) # options are keyword arguments
result = agent.run_capability('acme_weather_forecast', {'city': 'Boston'})
refused = LimitrNetwork.refusal(result) # None, or the refusal dict
agent_net.update('acme_weather', spend=0.10)
time.time() * 1000) or a datetime; vouchers carry whole ms.Request to a Response: channels={'ours': operator_network.operate}.
LimitrNetwork.generate_key() returns {'secret_key', 'public_key'}; key_store= gets a newly made key.network-receipt included), not JSON strings.operator_network.operator_wsgi() or serve_operator(port=...).secretKey (secret_key).url that isn't the public URL. It's in the terms and where consumers send requests.http:// URLs. Only localhost and 127.0.0.1 may be http; everything else must be https.fits()): every offered plan a route
reaches must have its entitlement.network.refusal(result) and act (tell the user, stop, or top up).identity: 'required' with no operator serving identity
doesn't validate ('auto' is optional then).What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
5 skills in this plugin
/limitrWrite, review, and debug Limitr policies: the credits, plans, entitlements, limits, caps, grants, topups, overhead costs, reservations, usage estimates, feature flags, and notifications that decide what each customer may do and what it costs. Limitr policies are Stof documents run by the embedded Limitr engine, so use this together with the stof skill. Use for any `Limitr policy: {...}` document, pricing or usage-limit design, allow()/check()/reserve()/settle() semantics, predicting a call's usage before it runs (Ex. output tokens from input tokens), feature flags and rollouts, giving or taking a customer's entitlements, meter or cap behavior, Limitr events, margin questions, or tests in the Limitr repo (src/spec, src/tests). For calling Limitr from an application, also load the SDK skill for that language (Ex. limitr-ts for TypeScript; the Python `limitr` package has the same API in snake_case).
/limitr-pyUse Limitr from Python with the limitr package (pip install limitr): create the engine, load policies and customers, gate calls with allow/check, feature flags and rollouts, give or take a customer's features, reserve and settle LLM calls, predict output tokens before a call, handle events, persist customer state, connect to Limitr Cloud, load the Limitr Network module (limitr.network(), see the limitr-network skill), and govern calls made with the Anthropic Python SDK. Use for code that imports limitr or calls Limitr(...) / Limitr.cloud, and for integrating usage limits, credits, or pricing into a Python app (FastAPI, Flask, Django, workers, agents). Load the limitr skill for policy semantics and the stof skill for Stof syntax.
/limitr-tsUse Limitr from TypeScript or JavaScript with the @formata/limitr package: create the engine, load policies and customers, gate calls with allow/check, feature flags and rollouts, give or take a customer's features, reserve and settle LLM calls, predict output tokens before a call, handle events, persist customer state, and connect to Limitr Cloud, load the Limitr Network module (limitr.network(), see the limitr-network skill), and govern agents built on the Claude Agent SDK (references/claude-agent-sdk.md) or calls made with the Claude Messages API (references/claude-messages.md). Use for code that imports @formata/limitr or calls Limitr.new / Limitr.cloud, and for integrating usage limits, credits, or pricing into a Node, Deno, Bun, or browser app. Load the limitr skill for policy semantics and the stof skill for Stof syntax.
/stofWrite, read, debug, and embed Stof (.stof) documents. Stof is a data runtime: a superset of JSON where documents carry their own functions, types, units, schemas, and tests, and run sandboxed anywhere (Rust, WebAssembly/TypeScript, Python). Use for any .stof file, Stof syntax or error question, converting JSON/YAML/TOML to Stof, self-validating configs (#[schema]), prototype types (#[type]), #[main]/#[test]/#[run] functions, the `stof` CLI, or embedding Stof with StofDoc (JS), Doc (Python), or Graph/Runtime (Rust). Also use when code shows `self.`, `#[type]`, `new X {}`, `schemafy`, `Lib::func`, `funcs(attributes = ...)`, `#[load]`, `import(url, sha256, ...)`, or `stof test`/`stof add`.
npx claudepluginhub dev-formata-io/limitr --plugin limitrOther plugins' skills for the same job