Silvanexum

v0.7.0
io.github.silvanexum/silvanexum Checked 3 days ago Published 5 days ago

Spend control for AI agents - cost attribution, budget caps, and signed runs as MCP tools.

Silvanexum is spend control for AI agents. It tells you what every LLM call cost, which customer and which agent it was for, and it can stop a call before it runs when a budget is spent. It works across OpenAI, Anthropic, Gemini and NVIDIA NIM. This repo holds everything you install to use it: the TypeScript and Python SDKs, the MCP server, the NVIDIA NeMo plugins, a VS Code extension and a Claude skill. All Apache-2.0. 📚 Docs: https://docs.silvanexum.com

Summary extracted from the README.

Silvanexum SDKs, MCP server and integrations

npm PyPI License: Apache-2.0 Silvanexum MCP server

Silvanexum is spend control for AI agents. It tells you what every LLM call cost, which customer and which agent it was for, and it can stop a call before it runs when a budget is spent. It works across OpenAI, Anthropic, Gemini and NVIDIA NIM.

This repo holds everything you install to use it: the TypeScript and Python SDKs, the MCP server, the NVIDIA NeMo plugins, a VS Code extension and a Claude skill. All Apache-2.0.

📚 Docs: https://docs.silvanexum.com

Packages

Package Install What it is
@silvanexum/sdk npm i @silvanexum/sdk TypeScript/JavaScript SDK (ESM + CJS, typed)
silvanexum pip install silvanexum Python SDK (pydantic v2, typed)
@silvanexum/mcp npx -y @silvanexum/mcp MCP server for Claude, Cursor, Windsurf and other MCP hosts
silvanexum-mcp uvx silvanexum-mcp The same MCP server in Python
silvanexum-relay pip install silvanexum-relay NVIDIA NeMo Relay plugin: meters every LLM call, blocks over-budget calls
silvanexum-nat pip install silvanexum-nat NVIDIA NeMo Agent Toolkit cost-tracking exporter
silvanexum-vscode see the package README Spend, budgets and traces in your editor
skill/silvanexum copy into ~/.claude/skills Claude Agent Skill

Quickstart

Get an API key at silvanexum.com, then pick one of three ways in.

1. SDK-only metering. You keep calling your provider directly; nothing sits in your request path and no prompts leave your stack. Silvanexum prices the usage, attributes it, and enforces budgets.

import { Silvanexum } from "@silvanexum/sdk";

const sx = new Silvanexum({ apiKey: process.env.SILVANEXUM_API_KEY });

const msg = await sx.meter.track("anthropic", "claude-sonnet-5-5", { customer: "acme", agent: "support-bot" },
  () => claude.messages.create({ model: "claude-sonnet-5-5", max_tokens: 1024, messages }));

2. Gateway. Point your OpenAI client at the gateway. Zero changes to agent code.

const openai = new OpenAI({
  baseURL: sx.gateway.openaiBaseUrl(),
  apiKey: process.env.SILVANEXUM_API_KEY,
});

3. Budgets and reports.

await sx.budgets.create({
  name: "acme-monthly",
  scopeType: "agent",
  scopeId: "agt_123",
  periodType: "monthly",
  limitCredits: 50_000,
  enforcement: "block", // over-budget calls are rejected, not just alerted on
});

console.table(await sx.spending.summary({ groupBy: "agent" }));

4. Hard caps with parallel agents. Hold a call's worst case before it runs, so many agents at once can't all pass the same check. The reported usage settles the hold; a hold that never gets usage is charged in full when it expires.

await sx.meter.track("openai", "gpt-4o", { customer: "acme", reserve: { inputTokens: 2_000, maxOutputTokens: 1_024 } },
  () => openai.chat.completions.create({ model: "gpt-4o", max_tokens: 1024, messages }));

Gateway calls under a block budget are held automatically.

5. Your own model prices. Self-hosted and edge models cost what your hardware costs. Price them per token, per GPU hour, or both:

await sx.gateway.setPrice({ provider: "other", model: "llama-3.1-*", gpuHourUsd: 1.2 });

Python works the same way; see packages/sdk-py.

Repo layout

packages/
  sdk-ts/            @silvanexum/sdk
  sdk-py/            silvanexum
  mcp/               @silvanexum/mcp
  mcp-py/            silvanexum-mcp
  relay-plugin-py/   silvanexum-relay
  nat-plugin-py/     silvanexum-nat
  vscode/            VS Code extension
  codegen/           generates spec/openapi.json and the SDK types
spec/
  openapi.json       OpenAPI 3.1 document for the public API
skill/
  silvanexum/        Claude Agent Skill

The SDK types and spec/openapi.json are generated from the Silvanexum API's contracts, so they match the live API. Please don't edit files under generated/ or _generated/ by hand; see CONTRIBUTING.md.

Develop

pnpm install
pnpm -r build
pnpm -r test

Python packages use their own pyproject.toml; run pytest inside each one.

Contributing and security

Bug reports, ideas and PRs are welcome; see CONTRIBUTING.md. Please report security issues privately as described in SECURITY.md.

License

Apache-2.0. "Silvanexum" and the Silvanexum logo are trademarks of Silvanexum and are not covered by the license.