Skip to main content
The SDK’s steer and route layers call the proxy for you. If you work in a language without an SDK, or want to see exactly what happens on the wire, call it yourself. The proxy forwards your request to your provider, applies your policies, records the call, and returns the provider’s response. The proxy is on the API host:
It is the only model endpoint. The body is forwarded as it is, so you send the provider’s own request shape. The sequence below is one call from start to finish: exchange the key once, then each call passes TensorCost’s checks before it reaches the provider.

Get a token

The proxy does not accept your SDK key directly. Exchange it for a token that lasts 15 minutes, and exchange again before it expires. The exchange endpoint needs no other credential and allows 60 requests a minute per source IP.
tenant_id is your workspace id from Connect › SDK setup; the SDK key comes from Connect › API keys. The token carries the key’s environment and team. A wrong key, a revoked key, or a key that does not belong to the tenant returns 401.

Make a call

Request headers

The environment is the token’s; x-tc-environment is ignored for SDK keys.

Provider credentials

x-tc-provider-auth carries the key you would send to the provider yourself. Bedrock and Vertex calls are signed with the cloud account you connected in TensorCost, not with a header you send. Without a connected account, the provider answers 401.

Allowed providers

x-tc-provider-url must be https and one of api.openai.com, *.openai.azure.com, api.anthropic.com, bedrock-runtime.<region>.amazonaws.com or <region>-aiplatform.googleapis.com. Anything else returns 400. An Anthropic Messages body sent to this path with x-tc-provider-url: https://api.anthropic.com is forwarded to Anthropic’s /v1/messages. Set stream: true to stream; for OpenAI streams to count toward run and period budgets, also send stream_options: {"include_usage": true}.

Response headers

Refusals and errors

TensorCost’s own refusals are 403 with a body of the form {"error": {"code": "...", ...}}. They are 403 rather than 402 on purpose: a cap you set on yourself is a policy decision, not a payment problem. Any other status is the provider’s own, with its body unchanged. Streams are cut after 120 seconds without a chunk. On the Scale plan a monthly ceiling on proxy requests applies. Past it the proxy answers 402 with kind: "scale-cogs-exceeded". Enterprise has no ceiling.

Observations without the proxy

If you call the provider yourself and only want TensorCost to record it, post the call to POST /api/inference-proxy/observation with the same token. It returns 202. A hard budget cap does not refuse here: it sets X-TensorCost-Budget-Exceeded and still records the call. Required fields are sdk_version, provider, model, operation, request_at, status and correlation_id; token counts, customer, feature and the other attribution fields are optional, and a missing cost is priced for you.