ProxonProxon
Open Proxon
Documentation

Proxon SDK for Agents

Add per-agent cost and token telemetry to a Node app with one launch flag and no call-site changes.

The Proxon SDK for Agents adds cost and token telemetry to a Node app you control. You install it, launch your app with one flag, and every LLM call the process makes reports its cost and token usage into Proxon, with no changes at the call site. It instruments the Anthropic and OpenAI SDKs in place, so you can slice spend by agent, task, and owner without touching a single request. It is fire-and-forget. It never throws into or slows your request path, and it never sees prompt or response content, only token counts and metadata.

This takes about a minute. You mint an organization credential, install the package and launch with the register flag, and confirm the cost lands in Cost Intelligence. You need to be an organization owner or admin to mint the credential. Anyone can wire up the SDK once they have it.

This SDK is for Node apps, on Node 18.19 or newer. For another language, or a tool that already emits OpenTelemetry, use OpenTelemetry instead.

Step 1: Mint a service credential

In Proxon, open Org Settings, then Credentials, and choose Generate. Proxon issues a bearer token that starts with prx_svc_, scoped to your organization.

The token is shown once. Copy it and store it as a secret, such as an environment variable or an entry in your secrets manager. Proxon keeps only a hash, so it cannot show the token to you again. If you lose it, rotate it or generate a new one. You can revoke or rotate a credential from the same screen at any time.

Only organization owners and admins see Credentials. If you do not, ask an admin to mint one for you.

Step 2: Install and launch with the register flag

Add the package to your Node app, which can be CI, a container, a server, or a laptop:

bash
npm i @proxon/agent-observer

Point it at Proxon with the three PROXON_OBSERVER_* environment variables. Swap prx_svc_<prefix>_<secret> for the token from Step 1.

bash
# Where to send agent-cost events, which is Proxon's production ingest host.
export PROXON_OBSERVER_INGEST_URL="https://ingest.proxon.ai"

# Authenticate with the service credential you minted in Step 1.
export PROXON_OBSERVER_SERVICE_CREDENTIAL="prx_svc_<prefix>_<secret>"

# Name the agent this process reports as, since the rollup keys on it.
export PROXON_OBSERVER_AGENT="my-agent"

Then launch your app with the register flag, with no source edits. It patches the Anthropic and OpenAI SDKs at module load:

bash
node --import @proxon/agent-observer/register app.js

The --import auto-instrumentation is ESM-only. For a CommonJS app, or when you construct the client yourself, instrument the instance explicitly with wrap(new Anthropic()) instead. @anthropic-ai/sdk and openai are optional peer dependencies, and the SDK instruments whichever one you already depend on.

Step 3: Confirm it landed

At startup, the register entry logs one confirmation banner to your process logs, so you can check that it loaded:

Startup log
[proxon-agent-observer] active — reporting agent-cost to https://ingest.proxon.ai as agent "my-agent"

Turn on the Proxon SDK for Agents in Settings, then Data Collection, so Proxon shows the Agent Cost view. Then open Cost Intelligence. Your agent's spend appears there, broken down by model and by the agent name you set, usually within a minute of the first flush.

Attributing spend by agent, task, or customer

The instrumentation cannot know what a given call is for, since that is business context you supply. Wrap a unit of work in withContext, and every event emitted inside it inherits the attribution. The fixed fields, which are agent, task_type, run_type, owner, linear_ticket, and pr_number, become first-class dashboard dimensions. Anything you put in the open-ended attributes bag is discovered automatically as its own breakdown, so a couple of extra keys give you a by-tenant, by-feature, or by-environment view at no extra effort.

Attribute your spend
import { withContext, flush } from '@proxon/agent-observer';

await withContext(
  {
    // Fixed fields, which become first-class dashboard dimensions.
    agent: 'support-bot',
    task_type: 'triage',
    run_type: 'orchestrator',
    owner: 'octocat',
    linear_ticket: 'PROJ-42',
    pr_number: 128,
    // Open-ended custom dimensions. Attach whatever your business cares about,
    // and each key becomes its own breakdown with no schema change needed.
    attributes: { tenant: 'acme', feature: 'search', environment: 'prod' },
  },
  async () => {
    await anthropic.messages.create({ /* ... */ }); // auto-attributed
  }
);

await flush(); // ship the final batch on shutdown or after a one-shot run

How cost is computed

Providers return token counts, not dollars. Proxon recomputes cost on its own servers from a maintained price book, so you never ship pricing in your agent. Content, meaning prompts and responses, is never sent.

SDK or OpenTelemetry?

The Proxon SDK for Agents and OpenTelemetry do the same job in two ways. For a Node app you control, the SDK on this page auto-instruments it with one line. For anything else, such as another language or a tool that already emits OpenTelemetry like Claude Code or GitHub Copilot, point that exporter at Proxon's OTLP endpoint instead. Either one is enough on its own, and running both adds detail rather than new coverage. See the data collection overview for the full picture.