Skip to main content
Spend is only as useful as what it is attributed to. Every field below is optional. Set defaults once when you wrap the client, and override them per call. Each field also has an environment variable, TENSORCOST_ plus the name in capitals (for example TENSORCOST_CUSTOMER); see SDKs.

Per call

Defaults go on wrap(). For values that change per request, such as the customer or the run, use withMeta() in Node.js or with_meta() in Python.
withMeta() works on OpenAI and Anthropic clients. Bedrock and Vertex clients take the defaults set on wrap().

Runs and caps

A run is a series of calls that share a workflowId. Give every run its own id and TensorCost can show it as one unit, apply a run cap, and let an operator stop it. A run that reaches its cap is refused with RUN_BUDGET_EXCEEDED where your workspace has enforcement for that layer; see Limits. Whether a run can be stopped or capped depends on the layer. At govern the SDK asks TensorCost before each call, and at steer and route the call goes through the proxy. In both, an operator’s stop refuses the call before the provider is billed. A run cap refuses it only when your workspace has enforcement for that layer; otherwise the cap is recorded but the call goes through. At observe nothing asks first, so a cap is recorded but cannot stop the next call. See Control layers.

Environment is set by the key

The environment of an SDK call comes from the SDK key’s own environment. The environment option does not override it, which keeps a development key from posting into production.

Without the SDK

The same fields travel as headers on the proxy (x-tc-customer, x-tc-feature, x-tc-agent-id, x-tc-workflow-id, x-tc-team-id, x-tc-application, x-tc-tags) and as span attributes through OpenTelemetry. On the proxy, a team-bound key’s team wins over the header.