Understand the two records
A chat response can include a standard usage object containing prompt, completion and total token counts. Your account dashboard is the place to inspect the actual request and credit charge. Tokens are a measurement of model usage; they are not themselves a currency balance.
Do not assume that a response includes a monetary usage.cost field or that an endpoint from another API platform exists on MandAPI. Read only fields that the actual response returns.
Capture a small response
Install the OpenAI Python client and set MANDAPI_API_KEY and MANDAPI_MODEL_ID as described in the chat quickstart. Save this as usage.py, then run python usage.py when you want to make one real request.
# usage.py
import os
from openai import OpenAI
with OpenAI(
api_key=os.environ["MANDAPI_API_KEY"],
base_url="https://api.mandapi.com/v1",
timeout=30.0,
max_retries=0,
) as client:
result = client.chat.completions.create(
model=os.environ["MANDAPI_MODEL_ID"],
messages=[{"role": "user", "content": "Reply with one short greeting."}],
)
usage = result.usage
print({
"response_id": result.id,
"model": result.model,
"prompt_tokens": usage.prompt_tokens if usage else None,
"completion_tokens": usage.completion_tokens if usage else None,
"total_tokens": usage.total_tokens if usage else None,
})The script does not print the API key, prompt body or model answer. If usage is absent, it records empty values instead of inventing token counts.
Compare the same request
Open your MandAPI dashboard and find the corresponding request using the time, model and response identifier when available. Compare the returned token counts with the fields actually shown in your account. A client-generated request ID can help your application's own logs, but it is not automatically a searchable MandAPI field.
If you estimate cost from the published prices, record the price date and units. A basic estimate is input tokens multiplied by the input rate plus output tokens multiplied by the output rate, each divided by one million. Cache, context tiers and other model-specific rules can change that estimate. Use the recorded credit charge for reconciliation.
Check the result
You should have a timestamped request, a model ID, returned token counts when available and the actual account record. Investigate missing usage or a material mismatch before relying on a report. Never silently convert missing usage to zero.
Keep raw prompts and customer messages out of routine billing logs. Start with counts, identifiers and status; store additional content only when your application needs it and access is controlled.