Skip to content

billing design: multiplier functors for search fees#11721

Draft
voodoohop wants to merge 2 commits into
mainfrom
codex/billing-multiplier-functors
Draft

billing design: multiplier functors for search fees#11721
voodoohop wants to merge 2 commits into
mainfrom
codex/billing-multiplier-functors

Conversation

@voodoohop

Copy link
Copy Markdown
Member

Multiplier-functor billing for Gemini and Perplexity, split out from #11683 for comparison.

  • Moves dynamic billing into priceMultiplier functors with multiplier, description, catalog billing metadata, and apply(context) runtime logic
  • Handles Gemini 2.5 grounded-prompt fee, Gemini 3.x per-query fee, and Gemini 3.1 Pro long-context rates above 200K prompt tokens
  • Adds Perplexity per-request search fees ($5/$12/$14/$14 per 1K by model), preferring bounded provider-reported usage.cost.request_cost when present
  • Exposes the functor description through /models billing metadata for pricing tables
  • Sanitizes non-stream public usage and keeps moderation telemetry with tracking overrides
  • Always uses registry-selected Perplexity search_context_size

Validation:

  • enter: npx vitest run test/pricing-data.test.ts test/aliases.test.ts — 217 passed
  • gen: targeted npx vitest run test/generation-vcr.test.ts --testNamePattern='Perplexity request cost|provider-reported Perplexity|moderation telemetry|streaming chat completions bill' — 3 passed
  • gen: npm run typecheck clean
  • npx biome check clean on changed files

Deploy: safe before pollinations/gateway#7 because static fees cover non-stream. Pin bump tracked in #11703.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DEV-FEATURE New functionality request

Projects

Status: To Do

Development

Successfully merging this pull request may close these issues.

1 participant