Skip to content

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",
    },
)

Keys stay in your product’s environment variables. We never store the OpenAI API key. Quickstart.

Starter is free. No credit card. Operated by Operator Media Yard LLC, New Jersey. hello@costslice.com