Skip to content

feat: add success only duration billing for video generation - #585

Merged
chenyme merged 1 commit into
devfrom
billing
Aug 7, 2026
Merged

feat: add success only duration billing for video generation#585
chenyme merged 1 commit into
devfrom
billing

Conversation

@chenyme

@chenyme chenyme commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Add duration-based billing for video generation while ensuring only successfully delivered videos are charged.

This change:

  • Restricts duration pricing to active models with the video_gen capability.
  • Validates duration pricing in both the admin UI and backend.
  • Uses provider-reported video duration when available.
  • Falls back to the requested duration, with 6 seconds as the default.
  • Rounds fractional durations up to the next whole second.
  • Sums durations when multiple videos are generated.
  • Persists video duration in attachment metadata.
  • Displays video duration in message cards, inline previews, file previews, and shared conversations.
  • Prevents token, call, latency, or non-video requests from accidentally producing duration charges.
  • Releases billing reservations when video generation fails or is canceled.
  • Charges only results marked billable with a successful video-generation status.

Change type

  • Bug fix
  • Feature
  • Documentation
  • Refactor
  • Configuration / deployment
  • Security hardening
  • Other

Affected areas

  • Frontend / UI
  • Backend / API
  • Authentication / authorization
  • Conversations / streaming
  • Files / RAG / extraction
  • Model routing / providers
  • MCP / tools
  • Billing / payments
  • Admin console
  • Deployment / Docker / configuration
  • Documentation

Verification

  • go test ./...
  • pnpm check
  • Targeted duration parsing and billing tests
  • git diff --check

Configuration, migration, and compatibility notes

  • No new environment variables or manual database migrations are required.
  • Existing token-, call-, and tier-based pricing modes remain unchanged.
  • Duration pricing can only be configured for models with the video_gen capability.
  • Video duration defaults to 6 seconds when no usable duration is provided.
  • Existing video attachments without duration metadata remain compatible.
  • Failed, canceled, empty, or unavailable video results are not charged.

Documentation

  • Documentation is not needed for this change.
  • Documentation was updated.
  • Documentation still needs to be updated.

Security and privacy

  • No secrets, tokens, credentials, local configuration, or personal data are included.
  • Billing authorization and settlement remain scoped to the authenticated user.
  • Failed video requests release their reserved billing budget.

Checklist

  • I searched existing issues and pull requests.
  • Changes are focused and do not include unrelated refactors.
  • Tests or static verification were run where practical.
  • User-facing behavior, deployment steps, API contracts, or configuration changes are documented.
  • Generated artifacts are included only when this project explicitly requires them.
  • Caches, build output, .pyc files, .env files, and local storage data are not committed.

@chenyme chenyme self-assigned this Aug 7, 2026
@chenyme
chenyme merged commit febffcd into dev Aug 7, 2026
11 checks passed
@chenyme
chenyme deleted the billing branch August 7, 2026 03:37
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