video model costs (#2383)
Docker Image CI / build-and-push-image (push) Has been cancelled
Maintain Release Merge PR / update-release-pr (push) Has been cancelled
release-please / release-please (push) Has been cancelled
test / test-backend (24.x) (push) Has been cancelled
test / API tests (node env, api-test) (24.x) (push) Has been cancelled
test / puterjs (node env, vitest) (24.x) (push) Has been cancelled

This commit is contained in:
Neal Shah
2026-01-30 22:33:36 +05:30
committed by GitHub
parent aa508a74dc
commit af62835d48
2 changed files with 64 additions and 4 deletions
@@ -95,8 +95,45 @@ class OpenAIVideoGenerationService extends BaseService {
},
};
models () {
return OPENAI_VIDEO_MODELS;
async models () {
// Import cost map dynamically
const costMapModule = await import('../../../MeteringService/costMaps/openaiVideoCostMap.ts');
const OPENAI_VIDEO_COST_MAP = costMapModule.OPENAI_VIDEO_COST_MAP;
// Convert microcents to cents (divide by 1,000,000)
const microCentsToCents = (microCents) => microCents / 1_000_000;
return OPENAI_VIDEO_MODELS.map(model => {
const result = { ...model };
// Get cost for default usage key
const defaultCostMicroCents = OPENAI_VIDEO_COST_MAP[model.defaultUsageKey];
if ( defaultCostMicroCents !== undefined ) {
const perSecondCost = microCentsToCents(defaultCostMicroCents);
result.costs_currency = 'usd-cents';
result.costs = {
'per-second': perSecondCost,
'default-duration-per-video': perSecondCost * DEFAULT_DURATION_SECONDS,
};
result.output_cost_key = 'default-duration-per-video';
}
// Add cost for xl variant if it exists (sora-2-pro only)
if ( model.id === 'sora-2-pro' ) {
const xlCostMicroCents = OPENAI_VIDEO_COST_MAP['openai:sora-2-pro:xl'];
if ( xlCostMicroCents !== undefined ) {
if ( ! result.costs ) {
result.costs = {};
result.costs_currency = 'usd-cents';
}
const perSecondXlCost = microCentsToCents(xlCostMicroCents);
result.costs['per-second-xl'] = perSecondXlCost;
result.costs['default-duration-per-video-xl'] = perSecondXlCost * DEFAULT_DURATION_SECONDS;
}
}
return result;
});
}
async generateVideo (params) {
@@ -199,12 +199,35 @@ class TogetherVideoGenerationService extends BaseService {
}
async models () {
if ( models.length > 0 ) {
if ( models.length > 0 && models[0].costs_currency ) {
return models;
}
const { TOGETHER_VIDEO_GENERATION_MODELS } = await import('./models.js');
models = TOGETHER_VIDEO_GENERATION_MODELS;
const costMapModule = await import('../../../MeteringService/costMaps/togetherCostMap.ts');
const TOGETHER_COST_MAP = costMapModule.TOGETHER_COST_MAP;
// Convert microcents to cents (divide by 1,000,000)
const microCentsToCents = (microCents) => microCents / 1_000_000;
models = TOGETHER_VIDEO_GENERATION_MODELS.map(model => {
const result = { ...model };
// Convert model ID from 'togetherai:google/veo-3.0' to cost key 'together-video:google/veo-3.0'
const costKey = model.id.replace('togetherai:', 'together-video:');
const costMicroCents = TOGETHER_COST_MAP[costKey];
if ( costMicroCents !== undefined && costMicroCents > 0 ) {
result.costs_currency = 'usd-cents';
result.costs = {
'per-video': microCentsToCents(costMicroCents),
};
result.output_cost_key = 'per-video';
}
return result;
});
return models;
}