Matters, workflows and cost: attribution below the customer
Customer Statements & Buyer Requests
#matter#project#workflow#trace#agent#cost#pricing#attribution#law firm
Break usage, cost and emissions down by your customer's matters or projects, and total each multi-step agent run.
How It Works Under the Hood
- •customer_ref identifies your customer; matter_ref identifies a matter, case or project under that customer. Both must be pseudonymous ids (letters, digits and . _ : / -), never emails or names.
- •trace_id groups every call of one agent run; workflow_name says which workflow it was. OpenTelemetry trace ids and gen_ai.agent.name are used automatically.
- •Cost per call uses your own negotiated prices where you've set them in Settings → Developer, otherwise list prices; the longest matching model id wins. Calls without a price are counted as unpriced, never as free. Cost is stored per call but kept outside the audit chain, so correcting a price never breaks the evidence.
- •The Usage & cost tab totals calls, tokens, emissions and cost by model, vendor, hosting, operation, customer, matter or workflow for the last 30 days.
How to Use It Step-by-Step
- 1Return customerRef, matterRef, workflowName and traceId from resolveContext (JavaScript), or use shdwsdk.matter() and shdwsdk.workflow() (Python).
- 2Add your negotiated prices in Settings → Developer → Model prices.
- 3Open Dashboard → Usage & cost and group by Matter or Workflow.
JavaScript and Python
// JavaScript
const shdw = new ShdwTelemetryClient({
apiKey: process.env.SHDW_API_KEY,
resolveContext: () => ({
customerRef: ctx.firmId,
matterRef: ctx.matterId,
workflowName: ctx.workflow,
traceId: ctx.traceId,
}),
});
# Python
with shdwsdk.matter("M-2026-0042", customer_ref="firm-42"), shdwsdk.workflow("Due diligence"):
run_agent()Related guides
- Per-customer Scope 3 emissions statements
- Questionnaire answers and buyer disclosure requests
- Interactive CLI Setup Wizard (npx @shdwsdk/sdk init / npx shdw-init)
- Non-Blocking Client Wrapper (shdw.wrapClient) & Fail-Silent Guarantee
- Layer 1: Zero-Touch Runtime AI-BOM Auto-Discovery & Zero-Knowledge Prompt Hashing
- Layer 2: RAG & Vector Database Auto-Instrumentation (shdw.wrapVectorStore)
- Layer 3: Static Manifest & CI/CD Auto-Scanner (@shdwsdk/sdk/scanner)
- Layer 4: Model Integrity & CycloneDX / SPDX Exporters
