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 type | What it is | Price |
|---|---|---|
| Input | Your prompt, system message and conversation history | The model's input price |
| Cached input | Input OpenAI reuses from a recent request with the same prefix | Lower than regular input |
| Output | The model's reply | The model's output price, usually several times input |
| Reasoning | Thinking tokens on reasoning models; not shown in the reply | Billed 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.