margovia.openai(client) or margovia.anthropic(client). Those tracked clients can read provider usage and report cost automatically. Use wrappers or explicit provider helpers when you need to migrate existing call sites.
Start and complete a run
running until you explicitly call run.complete(...) or run.fail(...). Cost events alone do not close the run.
Track failures
Use track for workflow lifecycle
track wraps a function, opens a run, and completes or fails it automatically. It does not read provider token usage by itself.
track is the safest option for custom workflows because it automatically completes the run on success and fails it when fn throws.
If the function calls OpenAI or Anthropic, use wrapped clients inside:
track around a raw provider client unless you also report cost manually.
Track multiple provider calls
Use one manual run when several calls belong to the same user-facing workflow.run.step(...) attaches wrapped provider calls to the existing run instead of creating separate runs.
Customer IDs
Send a stable, namespaced customer ID:"1" unless that is the stable ID you use across your whole system. Margovia will not rewrite the value.