Skip to content
Guide

OpenAI API cost tracking by feature and customer

By the Alye team · Updated

Short answer
OpenAI bills per organization, project and API key, so its dashboard can't tell you which of your features or customers spent the money. Record each call in your own code with its service, model and customer, price it from the tokens OpenAI returns, and you get cost per feature and per customer.

How OpenAI bills a request

Every response includes a usage block. Each kind of token has its own price per million tokens, which differs by model:

Token typeWhat it isPrice
InputYour prompt, system message and conversation historyThe model's input price
Cached inputInput OpenAI reuses from a recent request with the same prefixLower than regular input
OutputThe model's replyThe model's output price, usually several times input
ReasoningThinking tokens on reasoning models; not shown in the replyBilled as output

Batch and priority processing are billed at different rates. Alye prices them at the standard rate today, so treat costs for batch jobs as an upper bound.

What the OpenAI dashboard can't show

  • Which of your services or features made each call. One API key is usually shared by several services.
  • Which of your customers each call was for, so you can't price plans or spot unprofitable accounts.
  • Failures as they happen: rate limits (429), timeouts and retries that succeed on the third try but triple the latency.
  • Spend across providers, if you also use Anthropic, Gemini or Azure OpenAI.

Track it in two lines

With Alye, calls through the official OpenAI client are recorded automatically, including streaming, embeddings and the Responses API.

# Python
pip install alye
import alye
alye.init(service="support-reply")   # set ALYE_API_KEY in the environment

with alye.context(customer_id="northwind"):
    client.chat.completions.create(model="gpt-4o-mini", messages=[...])
// Node.js
npm install alye
import * as alye from "alye";
alye.init({ service: "support-reply" });
const openai = alye.wrap(new OpenAI());

Nothing sits between you and OpenAI: the SDK records each call and sends it in the background. See the docs for Express and NestJS.

What you see

  • Spend per day, by service, model and customer, priced from a versioned price list.
  • Every request as a trace, with its model calls, retries and errors.
  • Alerts in Slack, Microsoft Teams or email when spend passes a limit, the month is on track to exceed budget, or errors and latency rise.
  • Model retirement warnings, so a service still calling an old model doesn't break on a known date. More on costs in how LLM cost tracking works.

Questions

How do I see OpenAI API cost per feature or per customer?

Record each call where it happens, with the service and customer it served. With Alye, add the SDK to each service (two lines), tag requests with your customer ID, and every OpenAI call is priced and split by service, model and customer.

Why doesn't the OpenAI usage dashboard show cost per customer?

OpenAI bills per organization, project and API key. It doesn't know which of your features or customers made each request, so per-customer cost has to be recorded in your own code.

Are cached input and reasoning tokens priced differently?

Yes. Cached input tokens cost less than regular input, and reasoning tokens are billed as output. Alye prices each kind from the usage OpenAI returns with every response.

Try it on one service. Free for 500,000 calls a month, set up in about five minutes.