Skip to content

fix(usage): account for cached token pricing#1837

Open
ryanngit wants to merge 1 commit into
decolua:masterfrom
ryanngit:cache-aware-usage-pricing
Open

fix(usage): account for cached token pricing#1837
ryanngit wants to merge 1 commit into
decolua:masterfrom
ryanngit:cache-aware-usage-pricing

Conversation

@ryanngit

Copy link
Copy Markdown

Summary

  • update OpenAI Standard API pricing and GPT fallback ordering for cache-aware estimates
  • calculate usage with uncached input, cached input, cache write, output, reasoning, and cache-savings buckets
  • preserve cache/reasoning metadata, avoid double-saving streaming usage, and surface breakdowns in usage views
  • add focused pricing/cache regression coverage

Verification

  • checked current official OpenAI pricing page for Standard API rates
  • node --check open-sse/providers/pricing.js
  • node --check open-sse/utils/usageTracking.js
  • node --check src/lib/db/repos/usageRepo.js
  • node --check open-sse/handlers/chatCore/streamingHandler.js
  • direct Node pricing/cache assertions passed
  • git diff --check
  • NEXT_DIST_DIR=.next-upstream-pricing-build NEXT_TRACING_ROOT_MODE=workspace npm run build

Note

  • local Vitest config could not run in this checkout because node_modules is symlinked to the live patch repo and does not include vitest; the added test matches the existing Vitest test style and direct Node assertions cover the same pricing cases.

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