Skip to content

Latest commit

 

History

History
57 lines (48 loc) · 1.71 KB

File metadata and controls

57 lines (48 loc) · 1.71 KB
title CostAnalytics
description CostAnalytics Schema Reference
category ai
zodFile cost
**Source:** `packages/spec/src/ai/cost.zod.ts`

Properties

Property Type Required Description
periodStart string ISO 8601 timestamp
periodEnd string ISO 8601 timestamp
totalCost number
totalRequests integer
totalTokens integer optional
currency string optional
averageCostPerRequest number
averageCostPerToken number optional
averageRequestsPerDay number
costTrend Enum<'increasing' | 'decreasing' | 'stable'> optional
trendPercentage number optional % change vs previous period
byModel object[] optional
byProvider object[] optional
byUser object[] optional
byAgent object[] optional
byOperation object[] optional
byDate object[] optional
topModels object[] optional
topUsers object[] optional
topAgents object[] optional
tokensPerDollar number optional
requestsPerDollar number optional

TypeScript Usage

import { CostAnalyticsSchema } from '@objectstack/spec/ai';
import type { CostAnalytics } from '@objectstack/spec/ai';

// Validate data
const result = CostAnalyticsSchema.parse(data);

// Type-safe usage
const myCostAnalytics: CostAnalytics = {
  periodStart: 'example',
  periodEnd: 'example',
  totalCost: 0,
  // ... other required fields
};