Document invocation observation and cost reporting

This commit is contained in:
2026-11-22 18:38:11 +00:00
parent d4509b163e
commit 20c5ea47af
22 changed files with 231 additions and 52 deletions

View File

@@ -574,7 +574,7 @@ type TokenUsage struct {
ReasoningTokens int `json:"reasoning_tokens"`
// TotalTokens is the reported total-token count.
TotalTokens int `json:"total_tokens"`
// CachedTokens is the reported cached-input-token count.
// CachedTokens is the reported input-token cache-read count.
CachedTokens int `json:"cached_tokens"`
// CacheWriteTokens is the reported cache-write-token count.
CacheWriteTokens int `json:"cache_write_tokens"`
@@ -660,7 +660,9 @@ type StructuredOutputJSONSpec struct {
// treated as known and zero counts as unknown for observation only; the legacy
// interface cannot distinguish omitted zero from measured zero. An explicit
// UsagePresence can report known zero counts. Result usage sums the supplied
// Usage values independently of presence.
// Usage values independently of presence. A non-nil CostUSD is copied and
// retained for attempt accounting even when returned alongside an error;
// non-finite values are treated as unknown before configured-zero fallback.
type LLMClient interface {
Generate(context.Context, GenerateRequest) (*GenerateResponse, error)
}