Skip to main content
Control is a ladder. The SDK sets how far up it is allowed to go, and the console sets how far TensorCost actually goes today.

The layer you set is a ceiling

TensorCost uses the lower of two settings. The diagram shows the ladder, with what each step adds, and how the two settings combine. The two settings are: maxLayer (Node.js) or max_layer (Python) in your code, and the layer published in the console under Authority › Routing. You can turn control up or down in the console without a deploy, and your code can never be pushed past its own ceiling. Pausing routing holds the published layer at govern, and without a content-retention grant a published steer or route also runs as govern.
steer and route need a proxy URL, which is https://api.tensorcost.com; wrap() fails without one. govern does not need it. The SDK caches the console’s layer for 30 seconds and never waits more than 250 ms for it. If TensorCost cannot be reached for five minutes, the SDK settles at govern. It keeps checking, and it never raises itself to route on its own.

Roll out one step at a time

1

Observe

Wrap your clients and leave everything at the default. Check that spend, customers and agents look right.
2

Govern

Set maxLayer to govern and publish the same layer in Authority › Routing. Budgets, approved models and compliance profiles now apply before each call.
3

Route

Set maxLayer to route and supply the proxy URL. A call moves to another model only when a routing policy for it is switched on. Until then it goes to your provider unchanged, and the decision is recorded in Activity › Decisions.
Policies themselves, and how to preview them, are described in Routing.

What can refuse a call

At govern and above, a refused call raises an error from the SDK instead of reaching the provider. Every refusal extends one base class, TensorCostRefusedError, so a single catch covers them, including refusals a newer server adds.
A provider’s own error, such as a bad request, reaches you as the provider SDK’s error, as it would without TensorCost. Compliance profiles also run pattern detectors inside your process before the call, so a matched secret never leaves it; set the team (teamId or team_id) to apply that team’s profile.

Reliability

The SDK only goes around TensorCost when it cannot get an answer: a network error, a timeout, a 5xx, or a 429 or 402 with no refusal in it. Anything TensorCost actually answers reaches your code as an error and is never retried or sent around it.
If the proxy forwarded a call to the provider and then failed, going around it can bill the call twice. Where calls must never go around TensorCost, turn off fail-open (failOpenEnabled: false in Node.js, fail_open_enabled=False in Python); proxy failures then surface as errors.

Limits by provider

Bedrock and Vertex sign requests inside their own SDKs, so they cannot use the proxy. steer and route are not available for them, and govern is accepted but not enforced yet; the SDK warns once. Anthropic at steer or route runs at govern. In Python, streamed calls at steer and route go straight to the provider.