Skip to main content

API reference

TensorCost exposes a REST gateway at https://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

The gateway is versioned at the path prefix. /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 the Authorization header.
Tokens are minted by identity-service. Three flows:
  • Browser SSO — Cognito federation (RS256), verified against the user pool’s JWKS.
  • CLI / API clientPOST /v1/auth/login with 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 pass X-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:
Errors:
The 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 at api-gateway via Redis token-bucket and surface in response headers:
Per-tenant limits also apply to the gRPC ingress (per ADR-0010 CC-4) and to the managed-inference adapters’ upstream pulls (we don’t burst your CUR / CloudWatch budget).

Webhooks

Every event in the real-time event catalog can also be delivered as a webhook. Configure under Integrations → Webhooks, sign with HMAC-SHA256 (header X-TensorCost-Signature: t=<unix>,v1=<sig>), and verify on receipt.

SDKs

  • TypeScript@tensorcost/sdk on npm. A one-line wrapper around your OpenAI, Anthropic, or Bedrock client that reports usage in the background.
  • Pythontensorcost on PyPI. Same idea, for OpenAI and Anthropic clients.
See developer tools for setup and configuration. There’s no Go SDK today — if that’s a hard requirement for your team, tell support.

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/.