ModelWorks logoModelWorks
API

Metrics

Metrics available for circuit versions and individual runs

Metrics

ModelWorks tracks metrics at two levels: per version (aggregate across all runs) and per run (individual execution). These metrics help you monitor performance, diagnose issues, and understand costs.


Per-Version Metrics

Visible on the version details page, these aggregate metrics show how a circuit version is performing over time:

MetricDescription
RunsTotal number of times this version was executed.
EmbedsHow many times this version was called by other circuits via the embed primitive.
NodesNumber of logical steps (tasks) in the circuit.
Avg Response Time (ms)Average execution duration in milliseconds.
Avg Tokens per SecondAverage throughput across all fetch steps.
Avg Spend per RunAverage credits charged per run.
Input Cache Hit RatePercentage of input tokens served from cache vs total input tokens. Weighted across all runs by input volume. Higher is better — cached tokens are billed at a discount.
Error RatePercentage of runs that ended in an exception.

These metrics are also tracked over time in the trend charts (runs per day, average response time, error rate, tokens per second, tokens per run, and input cache hit rate).

If the error rate stays high over a 24-hour window, the version may be automatically moved to the EXCEPTION state. Versions in this state are still queryable but display a warning so consumers know something may be wrong.


Per-Run Metrics

Each completed run produces a result_blob containing billing and performance data. You can fetch it via GET /circuit-runs/{uid} (see Circuit Runs).

Billing Entries

The billing_entries array inside the result blob contains one entry per pricing type in your circuit. Each entry breaks down the cost:

FieldDescription
typePricing type: FLAT, TOKEN, or TOKEN_TIERED.
costTotal credits charged by this entry.
total_input_tokensInput tokens consumed (TOKEN and TOKEN_TIERED only).
total_output_tokensOutput tokens generated (TOKEN and TOKEN_TIERED only).
cached_input_tokensInput tokens served from cache at a discounted rate.
cache_write_tokensTokens written to cache.
cost_per_input_tokenRate applied to non-cached input tokens.
cost_per_output_tokenRate applied to output tokens.
cost_per_input_cache_tokenDiscounted rate applied to cached input tokens.
cost_per_cache_write_tokenRate applied to cache write tokens.
cache_write_ttlWhich cache write TTL tier was billed: "5m", "30m", or "1h".
tier_indexWhich pricing tier was matched (TOKEN_TIERED only, 0-indexed).
noteHuman-readable summary, e.g. "135 in, 1884 cached, 0 write, 10 out".

Performance Reports

The performance_reports object contains per-step execution statistics:

FieldDescription
time_takenWall-clock execution time in milliseconds.
tokens_per_secThroughput — tokens generated per second.
total_tokensTotal tokens processed by this step.

Each key in performance_reports corresponds to a step name from your circuit definition. For example, a circuit with a step named chat_completion_response would have its performance data under performance_reports.chat_completion_response.

Example

JSON
{
  "billing_entries": [
    {
      "type": "TOKEN",
      "cost": 0.000119,
      "total_input_tokens": 19,
      "total_output_tokens": 21,
      "cached_input_tokens": 0,
      "cache_write_tokens": 0,
      "cost_per_input_token": 0.0000014,
      "cost_per_output_token": 0.0000044,
      "note": "19 in, 0 cached, 0 write, 21 out"
    }
  ],
  "performance_reports": {
    "chat_completion_response": {
      "time_taken": 1966,
      "tokens_per_sec": 346.31,
      "total_tokens": 841
    }
  }
}

Summary Metrics on the Run

The top-level run object also includes summary fields derived from the billing entries and performance reports:

FieldDescription
stateRun lifecycle state: PROVISIONED, RUNNING, COMPLETED, or EXCEPTION.
created_atWhen the run started.
ended_atWhen the run finished.
is_publicWhether the run is publicly viewable.

The total cost of a run is the sum of all billing_entries[].cost values. This is the amount deducted from the caller's wallet.


Using Metrics

  • Monitor costs: Check billing_entries to see exactly how each run was billed, including the cache read/write breakdown.
  • Diagnose performance: Use performance_reports to identify which steps are slow or have low throughput.
  • Track cache efficiency: Watch the Input Cache Hit Rate — a high rate means the model provider is serving input from cache, reducing cost and latency. If it's consistently 0% on a model that supports caching, check your total_cached_input_tokens_selector configuration.
  • Track adoption: Watch the per-version Runs and Embeds counts to see how your circuit is being used.
  • Catch errors early: Monitor the Error Rate metric — a sudden spike may indicate a problem with your circuit or an upstream API.
On this page

On this page