API reference
TensorCost exposes a REST gateway athttps://api.tensorcost.com/v1/ that fronts the 14 backend microservices. All endpoints are tenant-scoped and require authentication.
Programmatic agents — Claude Desktop, internal LLM agents, partners — should prefer the MCP server over the REST API. MCP gives scope-guarded tools with built-in tenant binding.
Base URL and versioning
/v1/ is the only currently-supported version; older /api/ paths are deprecated and will be removed after 2026-09-30.
Authentication
All endpoints require a Bearer JWT in theAuthorization header.
identity-service. Three flows:
- Browser SSO — Cognito federation (RS256), verified against the user pool’s JWKS.
- CLI / API client —
POST /v1/auth/loginwith email + password +tenant_id. - Service-to-service — backend-issued HS256 tokens with embedded
tenantId. Used by partner integrations.
Login
Refresh
Tenant scoping
Every request is implicitly scoped to the tenant embedded in the JWT. Cross-tenant reads are unreachable by construction — Postgres Row Level Security enforces it at the storage layer (see architecture). Users with multi-tenant access passX-Active-Tenant-Id: <uuid> to switch context per request.
Endpoints by service
The gateway groups endpoints under their owning microservice. The table below is the public surface — internal-only routes (e.g.audit-service direct ingestion, mcp-server tool dispatch) are not listed.
cost-service — /v1/cost/
gpu-service — /v1/gpu/
ai-service — /v1/ai/
alert-service — /v1/alert/
enforcement-service — /v1/enforcement/
integration-service — /v1/integration/
tenant-service — /v1/tenant/
identity-service — /v1/identity/
notification-service — /v1/notification/
report-service — /v1/report/
Common response shape
Successful responses:trace_id correlates to the OpenTelemetry trace and is searchable in our internal observability stack — include it in support tickets.
HTTP status codes
Rate limits
Default: 1,000 requests per minute per tenant. Enterprise tier raises this to 10,000 RPM. Limits are enforced atapi-gateway via Redis token-bucket and surface in response headers:
Webhooks
Every event in the real-time event catalog can also be delivered as a webhook. Configure under Integrations → Webhooks, sign with HMAC-SHA256 (headerX-TensorCost-Signature: t=<unix>,v1=<sig>), and verify on receipt.
SDKs
- TypeScript —
@tensorcost/sdkon npm. A one-line wrapper around your OpenAI, Anthropic, or Bedrock client that reports usage in the background. - Python —
tensorcoston PyPI. Same idea, for OpenAI and Anthropic clients.
Deprecated endpoints
The pre-/v1/ paths (/api/instances, /api/costs, etc.) remain available but emit a Deprecation header and will be removed after 2026-09-30. New integrations should target /v1/.