Salar Saeedi

Automation & agents · Analysis

Build an AI cost record for the whole run

Connect usage to individual calls in a trace so retries, tool loops and caches remain visible in operational reporting.

Salar Saeedi1 min read
Three-stage illustration — Build an AI cost record for the whole run

A single button starts an assistant that classifies a request, reads two sources, drafts an answer and retries its final call. Billing dashboards usually show a collection of API requests. The product needs to know which work belonged to one user intent.

Connect child operations to one run

OpenTelemetry represents a trace as related spans. Assign a run ID and give each model call a child span with operation, outcome and timing. Keep system identifiers separate from private input text.

Source · OpenTelemetry · Traces · OpenTelemetry · Generative AI conventions

Use returned units for accounting

Record provider usage as returned, distinguishing cached input if supplied. Attach the pricing terms or version used to calculate a customer charge. Use estimates only when their limits are visible.

Source · OpenAI · Prompt caching

Compare the run and each attempt

Run an ordinary case and a case that retries after a timeout. The first can show one path while the second preserves an incomplete or duplicate attempt without blindly charging twice.

What to take away

Keep provider usage, product billing and the user’s completed outcome as three records you can relate during a dispute.

References

Related work in the portfolio