helix cost¶
Print a token-usage summary. This subcommand is currently a stub: it
prints the schema of the cost table and explains how token usage is
captured (per-exchange headers X-LLM-Input-Tokens /
X-LLM-Output-Tokens / X-LLM-Total-Tokens) along with the
configuration block needed to expose them via the management API.
The live numbers themselves are pulled from the management API's
/api/metrics endpoint, not from this command — once the management
API is enabled in helix.yaml, hit that endpoint for per-provider,
per-model token + cost data.
Usage¶
Flags¶
This subcommand takes no flags and no arguments.
Behavior notes¶
- Requires
$HELIX_LICENSE. Verified at process start, even though the implementation only prints static text today. The license banner is emitted to stderr before the cost table. - Output is a fixed template followed by two how-to notes. No data source is consulted yet — the implementation is a placeholder.
- The exchange headers
X-LLM-Input-Tokens,X-LLM-Output-Tokens, andX-LLM-Total-Tokensare set by every LLM component (openai,anthropic,ollama, …) on every reply. They feed thehelix_llm_tokens_total/helix_llm_tokens_input_total/helix_llm_tokens_output_totalPrometheus counters when the metrics endpoint is enabled, and they're forwarded to the management API's/api/metricsendpoint when it is enabled.
Examples¶
Inspect the placeholder output:
$ helix cost
Token Usage Summary
===================
PROVIDER INPUT OUTPUT TOTAL EST. COST
-------- ----- ------ ----- ---------
No usage data available. Run a flow with LLM components first.
Token usage is tracked via exchange headers:
X-LLM-Input-Tokens, X-LLM-Output-Tokens, X-LLM-Total-Tokens
Enable the management API to access /api/metrics for live stats:
helix:
management:
enabled: true
port: 9090
Get the live numbers in the meantime via the management API:
Source¶
cmd/helix/main.go lines 2933-2950 (cmdCost).
See also¶
- Management API guide — enable
/api/metrics. - Metrics & observability
- The token-usage headers are set by the LLM components in
pkg/component/{openai,anthropic,ollama,...}/after every reply.