Skip to content

Conversation

@vincentkoc
Copy link
Member

@vincentkoc vincentkoc commented Nov 8, 2025

Details

This PR adds cost tracking support for video generation models (OpenAI Sora and Google Veo3). The implementation introduces video-specific pricing calculations based on video duration in seconds, extending the existing cost calculation framework.

Key Changes:

  • Adds video output price field to ModelPrice record
  • Implements video generation cost calculator using duration-based pricing
  • Updates cost service to detect and handle video generation models

Change checklist

  • User facing
  • Documentation update

Issues

  • Resolves #
  • OPIK-

Testing

n.a see #3993 for SDK testing to push trace for cost.

Documentation

n.a

Example

Screenshot 2025-11-07 at 18 31 09

@vincentkoc vincentkoc marked this pull request as ready for review November 8, 2025 00:18
@vincentkoc vincentkoc requested a review from a team as a code owner November 8, 2025 00:18
Copilot AI review requested due to automatic review settings November 8, 2025 00:18
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds cost tracking support for video generation models (OpenAI Sora and Google Veo3). The implementation introduces video-specific pricing calculations based on video duration in seconds, extending the existing cost calculation framework.

Key Changes:

  • Adds video output price field to ModelPrice record
  • Implements video generation cost calculator using duration-based pricing
  • Updates cost service to detect and handle video generation models

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
CostServiceTest.java Adds test coverage for video generation cost calculation using duration
SpanCostCalculator.java Implements videoGenerationCost method for duration-based pricing
ModelPrice.java Extends record with videoOutputPrice field
CostService.java Updates model price parsing to handle video generation mode and pricing
ModelCostData.java Adds fields for video pricing and mode identification

@github-actions
Copy link
Contributor

github-actions bot commented Nov 8, 2025

Backend Tests Results

  284 files    284 suites   50m 33s ⏱️
5 422 tests 5 414 ✅ 8 💤 0 ❌
5 355 runs  5 347 ✅ 8 💤 0 ❌

Results for commit 60cc926.

@vincentkoc vincentkoc added the test-environment Deploy Opik adhoc environment label Nov 8, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 8, 2025

🔄 Test environment deployment started

Building images for PR #3995...

You can monitor the build progress here.

@CometActions
Copy link
Collaborator

Test environment is now available!

Access Information

The deployment has completed successfully and the version has been verified.

BigDecimal videoOutputPrice = Optional.ofNullable(modelCost.outputCostPerVideoPerSecond())
.map(BigDecimal::new)
.orElse(BigDecimal.ZERO);
String mode = Optional.ofNullable(modelCost.mode()).orElse("text_generation");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know the possible values here?

Comment on lines 110 to +121
BiFunction<ModelPrice, Map<String, Integer>, BigDecimal> calculator = SpanCostCalculator::defaultCost;
if (cacheCreationInputTokenPrice.compareTo(BigDecimal.ZERO) > 0
|| cacheReadInputTokenPrice.compareTo(BigDecimal.ZERO) > 0) {
calculator = PROVIDERS_CACHE_COST_CALCULATOR.getOrDefault(provider,
SpanCostCalculator::textGenerationCost);
} else if (inputPrice.compareTo(BigDecimal.ZERO) > 0 || outputPrice.compareTo(BigDecimal.ZERO) > 0) {
calculator = SpanCostCalculator::textGenerationCost;
}
if ("video_generation".equalsIgnoreCase(mode) && videoOutputPrice.compareTo(BigDecimal.ZERO) > 0) {
calculator = SpanCostCalculator::videoGenerationCost;
} else
if (cacheCreationInputTokenPrice.compareTo(BigDecimal.ZERO) > 0
|| cacheReadInputTokenPrice.compareTo(BigDecimal.ZERO) > 0) {
calculator = PROVIDERS_CACHE_COST_CALCULATOR.getOrDefault(provider,
SpanCostCalculator::textGenerationCost);
} else
if (inputPrice.compareTo(BigDecimal.ZERO) > 0 || outputPrice.compareTo(BigDecimal.ZERO) > 0) {
calculator = SpanCostCalculator::textGenerationCost;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make it a factory?

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

Labels

test-environment Deploy Opik adhoc environment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants