Skip to content
reaatechREAATECH

@reaatech/otel-cost-exporter-cli

pending npm

Provides a command-line interface to manage OTLP-based cost tracking, including running an OTLP collector service, validating pricing table schemas, and generating cost reports from trace data. It serves as the primary utility for configuring and interacting with the otel-cost-exporter ecosystem.

@reaatech/otel-cost-exporter-cli

npm version License: MIT CI

Status: Pre-1.0 — APIs may change in minor versions. Pin to a specific version in production.

Command-line interface for the otel-cost-exporter. Start a collector service, validate pricing tables, generate cost reports from span data, and inspect configuration — all from the terminal.

Installation

terminal
npm install @reaatech/otel-cost-exporter-cli
# or
pnpm add @reaatech/otel-cost-exporter-cli

Or install globally:

terminal
npm install -g @reaatech/otel-cost-exporter-cli

Commands

otel-cost-exporter serve

Start the OTLP collector service with Prometheus metrics.

terminal
otel-cost-exporter serve [options]
OptionDescriptionDefault
--config <path>Path to YAML configuration file
--port <number>Port for OTLP HTTP receiver4317
--metrics-port <number>Port for Prometheus metrics endpoint8888

The server accepts POST /v1/traces (JSON-encoded OTLP), serves Prometheus metrics at GET /metrics, and exposes health and debug endpoints.

terminal
# Start with custom config
otel-cost-exporter serve --config ./config.yaml
 
# Override ports
otel-cost-exporter serve --port 8080 --metrics-port 9090

otel-cost-exporter report

Read CostSpan JSON from a file or stdin, compute costs, and output results.

terminal
otel-cost-exporter report [options]
OptionDescriptionDefault
--input <path>Path to JSON file containing a CostSpan arraystdin
--format <format>Output format: json or tablejson
--environment <env>Filter spans by deployment environment
terminal
# JSON output
otel-cost-exporter report --input spans.json
 
# Table format filtered by environment
otel-cost-exporter report --input spans.json --format table --environment production
 
# Pipe from stdin
cat spans.json | otel-cost-exporter report

Table output columns: spanId, Model, Provider, In Tok, Out Tok, Total USD.

otel-cost-exporter config

Display the effective configuration with defaults, YAML file overrides, and environment variable resolution.

terminal
otel-cost-exporter config [options]
OptionDescriptionDefault
--format <format>Output format: json or yamljson
terminal
# See merged config as JSON
otel-cost-exporter config
 
# Dump as YAML
otel-cost-exporter config --format yaml

The output shows two sections:

  • default — the built-in DEFAULT_CONFIG values
  • active — merged config from YAML file + environment variables

otel-cost-exporter validate

Validate all bundled and custom pricing tables for schema compliance.

terminal
otel-cost-exporter validate

Reports provider count, model count per provider, and flags any invalid entries:

code
Pricing table version: 2026.04
Last updated: 2026-04-27T00:00:00Z
Providers: 5
  openai: 17 models
  anthropic: 7 models
  google: 7 models
  aws-bedrock: 14 models
  azure: 9 models
Total models: 54
All pricing tables are valid.

Exits with code 1 if any validation errors are found.

Global Options

OptionDescription
--versionPrint the installed version
--helpDisplay help for any command

Docker

A multi-stage Docker image is provided at the repository root:

dockerfile
# docker/Dockerfile
FROM node:22-alpine AS base
RUN npm install -g pnpm@10
# ... multi-stage build for monorepo
CMD ["node", "packages/cli/dist/cli.js", "serve"]
terminal
# Build
docker build -t otel-cost-exporter -f docker/Dockerfile .
 
# Run
docker run -p 4317:4317 -p 8888:8888 otel-cost-exporter

License

MIT