Manual Integration

Initialize the auditor singleton, patch clients or log events manually, and flush before shutdown.

Agent hint

Use when wiring AurexAuditor.getInstance / AurexAuditor(), patchAll, logEvent, flush, or shutdown.

In scope

  • Singleton initialization
  • patch_all / patchOpenAI
  • Manual log_event
  • Pricing registration
  • flush / flushAndWait

Out of scope

  • Full AurexConfig field list — see AurexConfig
  • wrap() — see Context Wrappers

Initialize and log

Python
from aurex_sdk import AurexAuditor, AurexConfig

auditor = AurexAuditor(AurexConfig(
    api_key="aux_dev_yourkey",
    project="my-project",
    storage_mode="file",
    ledger_path=".aurex/ledger.jsonl",
    cloud_sync=True,
))

auditor.log_event(
    model="gpt-4o-mini",
    input_tokens=120,
    output_tokens=40,
    workflow_id="checkout_agent",
)

auditor.flush()
auditor.shutdown()
Node.js
import { AurexAuditor } from "aurex-sdk";

const auditor = AurexAuditor.getInstance({
  apiKey: "aux_dev_yourkey",
  project: "my-project",
  ledgerPath: ".aurex/ledger.jsonl",
  cloudSync: true,
});

auditor.logEvent({
  model: "gpt-4o-mini",
  inputTokens: 120,
  outputTokens: 40,
  workflowId: "checkout_agent",
});

await auditor.flushAndWait();
auditor.shutdown();

Automatic client patching

Python
from aurex_sdk import AurexAuditor

auditor = AurexAuditor()
auditor.patch_all()
# auditor.patch_openai()
# auditor.patch_anthropic()
Node.js
import { AurexAuditor } from "aurex-sdk";

const auditor = AurexAuditor.getInstance();
auditor.patchAll();

Dynamic pricing

Python
auditor.register_model_pricing("custom-llama-3", input_cost=0.15, output_cost=0.60)
auditor.register_model_pricing("local/*", input_cost=0.00, output_cost=0.00)
Node.js
auditor.registerModelPricing("custom-llama-3", 0.15, 0.60);
auditor.registerModelPricing("local/*", 0.00, 0.00);

See also