Shared domain types, Zod schemas, GenAI semantic convention constants, and a Pino-based logger factory for the `@reaatech/otel-cost-exporter-*` ecosystem. Exports TypeScript types (`CostSpan`, `PriceEntry`, `CostBreakdown`), their Zod validation schemas, and utility functions like `parseIntervalMs()` and `createLogger()`.
Status: Pre-1.0 — APIs may change in minor versions. Pin to a specific version in production.
Core domain types, Zod schemas, GenAI semantic conventions, and shared utilities for the @reaatech/otel-cost-exporter-* ecosystem. This package is the single source of truth for all LLM cost domain shapes used across the exporter monorepo.
Validates pricing entries — positive token prices, ISO 8601 effective date
CostSpanSchema
Validates span structure with nested cost breakdown and telemetry context
ConfigSchema
Full configuration validation — pricing, metrics, export, and logging sections
GenAI Semantic Conventions
Export
Attribute Name
GEN_AI_SYSTEM
gen_ai.system
GEN_AI_REQUEST_MODEL
gen_ai.request.model
GEN_AI_USAGE_INPUT_TOKENS
gen_ai.usage.input_tokens
GEN_AI_USAGE_OUTPUT_TOKENS
gen_ai.usage.output_tokens
GEN_AI_USAGE_CACHE_READ_TOKENS
gen_ai.usage.cache_read_input_tokens
GEN_AI_USAGE_CACHE_CREATION_TOKENS
gen_ai.usage.cache_creation_input_tokens
SEMCONV_VERSION
Pinned semantic conventions version
Constants
Export
Value
Description
TOKENS_PER_UNIT
1000000
Tokens per pricing unit (1M)
roundTo(value, decimals)
Function
Round a number to N decimal places
Logging
Export
Description
createLogger(level, format)
Pino logger factory — accepts `“debug"
Utilities
Export
Description
parseIntervalMs(value)
Parse a duration string (24h, 5m, 30s, 1h30m) into milliseconds
Usage Pattern
Every schema export has a matching type export. Use the schema for runtime validation and the type for compile-time checking:
typescript
import { PriceEntrySchema, type PriceEntry } from "@reaatech/otel-cost-exporter-core";// Parse at the boundary — throws ZodError on invalid datafunction validatePrice(raw: unknown): PriceEntry { return PriceEntrySchema.parse(raw);}