Package com.tnsai.llm.cost
Class UsageRecord
java.lang.Object
com.tnsai.llm.cost.UsageRecord
Record of a single LLM API call usage.
UsageRecord captures detailed information about each API call, including token counts, costs, and metadata for analysis.
Captured Information
- Request ID and timestamp
- Model and provider information
- Token counts (input, output, cached)
- Calculated costs
- Optional metadata (agent ID, task type, etc.)
Usage Example
UsageRecord record = UsageRecord.builder()
.modelId("gpt-4o")
.inputTokens(1000)
.outputTokens(500)
.build();
System.out.println("Cost: $" + record.getTotalCost());
-
Method Details
-
builder
-
getId
-
getTimestamp
-
getModelId
-
getProvider
-
getInputTokens
public long getInputTokens() -
getOutputTokens
public long getOutputTokens() -
getCachedInputTokens
public long getCachedInputTokens() -
getTotalTokens
public long getTotalTokens() -
getInputCost
-
getOutputCost
-
getCachedInputCost
-
getTotalCost
-
getLatencyMs
public long getLatencyMs() -
getSpec
-
getSpec
-
toString
-