Skip to content

fix(langfuse): use Langfuse-standard keys in usageDetails#107

Merged
flore2003 merged 2 commits into
mainfrom
fix/langfuse-usage-detail-keys
Apr 14, 2026
Merged

fix(langfuse): use Langfuse-standard keys in usageDetails#107
flore2003 merged 2 commits into
mainfrom
fix/langfuse-usage-detail-keys

Conversation

@flore2003
Copy link
Copy Markdown
Member

Summary

  • Fix usageDetails keys in the Langfuse middleware to match Langfuse's expected naming convention (input, output, total, cache_read_input, cache_creation_input, reasoning_output) instead of custom keys (inputTokens, outputTokens, promptTokens, completionTokens, cacheReadInputTokens, cacheWriteInputTokens, reasoningOutputTokens)
  • This enables Langfuse's automatic cost inference (model price definitions key on input/output) and correct UI aggregation (Langfuse groups usage types by substring matching on input/output)
  • Reference: https://langfuse.com/docs/observability/features/token-and-cost-tracking

Test plan

  • All 9 existing tests updated and passing

The usageDetails keys (inputTokens, outputTokens, promptTokens, etc.)
did not match Langfuse's expected naming convention (input, output,
total, etc.), preventing cost inference and correct UI aggregation.
@flore2003 flore2003 merged commit 589219e into main Apr 14, 2026
2 checks passed
@flore2003 flore2003 deleted the fix/langfuse-usage-detail-keys branch April 14, 2026 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant