OpenAI cost per tenant — one key, tagged requests, a P&L
One OpenAI key can serve every customer. The Costs API can group by api_key. That is still your key, not their tenant_id. Tag the request. Then read a customer P&L.
Engineers who ask for OpenAI cost per tenant usually share one key. Opening a project or a key per customer does not scale. OpenAI’s Costs API group_by=api_key answers “which of our keys.” It does not answer “which row in our tenants table.”
CostSlice keeps that one key. You send x-cs-tenant — an opaque id, never an email — plus x-cs-key. The customer P&L is cost versus what they pay.
api.costslice.com/v1
from openai import OpenAI
import os
client = OpenAI(
base_url="https://api.costslice.com/v1",
api_key=os.environ["OPENAI_API_KEY"],
default_headers={
"x-cs-key": os.environ["COSTSLICE_KEY"],
"x-cs-tenant": tenant_id, # opaque id, never an email
"x-cs-feature": "support-copilot",
"x-cs-env": "prod",
},
)
Worked example: the sample tenant acme-health is one opaque id on clinical-summary. Plan $2,400. LLM cost $4,812. Margin −101%. That is cost per tenant, not cost per API key. See the sample P&L.
Starter is free. No credit card. Operator: Media Yard LLC, PO Box 73, Pennsauken, NJ 08110. hello@costslice.com