176 lines
8.5 KiB
Python
176 lines
8.5 KiB
Python
from __future__ import annotations
|
|
|
|
from datetime import datetime, timedelta, timezone
|
|
from typing import Any
|
|
|
|
from app.enums.model_pricing import (
|
|
ModelPricingBillingMode,
|
|
ModelPricingCalculatorVersion,
|
|
ModelPricingCategory,
|
|
ModelPricingProvider,
|
|
PricingBillBy,
|
|
)
|
|
|
|
|
|
CST = timezone(timedelta(hours=8))
|
|
SOURCE_URL = "https://www.volcengine.com/docs/82379/1544106"
|
|
SOURCE_UPDATED_AT = datetime(2026, 7, 9, 12, 2, 6, tzinfo=CST)
|
|
|
|
# 文档更新时间不等于价格真实生效时间。初始化仅创建草稿;提交前必须逐模型核实并修改。
|
|
PROPOSED_EFFECTIVE_FROM = SOURCE_UPDATED_AT
|
|
|
|
|
|
def volcengine_pricing_seed_rules() -> list[dict[str, Any]]:
|
|
common = {
|
|
"provider": ModelPricingProvider.VOLCENGINE.value,
|
|
"publish_status": "draft",
|
|
"currency": "CNY",
|
|
"rule_schema_version": 1,
|
|
"source_url": SOURCE_URL,
|
|
"source_updated_at": SOURCE_UPDATED_AT,
|
|
"effective_from": PROPOSED_EFFECTIVE_FROM,
|
|
"remark_prefix": "初始化草稿:effective_from 仅为建议值,发布前必须核对火山真实生效时间。",
|
|
}
|
|
rules = [
|
|
{
|
|
**common,
|
|
"model_name": "doubao-seed-2-0-lite-260215",
|
|
"model_category": ModelPricingCategory.TEXT.value,
|
|
"billing_mode": ModelPricingBillingMode.TEXT_TOKEN_TIERED.value,
|
|
"calculator_version": ModelPricingCalculatorVersion.TEXT_TOKEN_TIERED_V1.value,
|
|
"version_code": "volc_20260709_v1",
|
|
"rule_json": {
|
|
"unit": "CNY_per_million_tokens",
|
|
"cache_storage_rate_per_million_token_hour": "0.017",
|
|
"tiers": [
|
|
{"max_context_tokens": 32000, "input_rate": "0.6", "audio_input_rate": "9", "output_rate": "3.6", "cached_input_rate": "0.12", "cached_audio_input_rate": "1.8"},
|
|
{"max_context_tokens": 128000, "input_rate": "0.9", "audio_input_rate": "13.5", "output_rate": "5.4", "cached_input_rate": "0.18", "cached_audio_input_rate": "2.7"},
|
|
{"max_context_tokens": 256000, "input_rate": "1.8", "audio_input_rate": "27", "output_rate": "10.8", "cached_input_rate": "0.36", "cached_audio_input_rate": "5.4"},
|
|
],
|
|
},
|
|
"remark": "豆包 Seed 2.0 Lite,按上下文长度分档。",
|
|
},
|
|
{
|
|
**common,
|
|
"model_name": "doubao-seedream-5-0-pro-260628",
|
|
"model_category": ModelPricingCategory.IMAGE.value,
|
|
"billing_mode": ModelPricingBillingMode.IMAGE_INPUT_OUTPUT_TIERED.value,
|
|
"calculator_version": ModelPricingCalculatorVersion.IMAGE_INPUT_OUTPUT_TIERED_V1.value,
|
|
"version_code": "volc_20260709_v1",
|
|
"rule_json": {
|
|
"unit": "CNY_per_image",
|
|
"free_input_images": 1,
|
|
"input_image_rate": "0.02",
|
|
"output_tiers": [
|
|
{"max_pixels": 2360000, "rate": "0.30"},
|
|
{"max_pixels": None, "rate": "0.60"},
|
|
],
|
|
"bill_by": PricingBillBy.SUCCESSFUL_OUTPUT_COUNT.value,
|
|
},
|
|
"remark": "Seedream 5.0 Pro:输入图和逐张输出像素分档计价。",
|
|
},
|
|
{
|
|
**common,
|
|
"model_name": "doubao-seedream-5-0-260128",
|
|
"model_category": ModelPricingCategory.IMAGE.value,
|
|
"billing_mode": ModelPricingBillingMode.IMAGE_PER_OUTPUT.value,
|
|
"calculator_version": ModelPricingCalculatorVersion.IMAGE_PER_OUTPUT_V1.value,
|
|
"version_code": "volc_20260709_v1",
|
|
"rule_json": {"unit": "CNY_per_image", "output_rate": "0.22", "bill_by": PricingBillBy.SUCCESSFUL_OUTPUT_COUNT.value},
|
|
"remark": "Seedream 5.0:按同步接口实际成功输出图片数量计价。",
|
|
},
|
|
{
|
|
**common,
|
|
"model_name": "doubao-seedance-2-0-260128",
|
|
"model_category": ModelPricingCategory.VIDEO.value,
|
|
"billing_mode": ModelPricingBillingMode.VIDEO_TOKEN_RATE.value,
|
|
"calculator_version": ModelPricingCalculatorVersion.VIDEO_PIXEL_TOKEN_V1.value,
|
|
"version_code": "volc_20260709_v1",
|
|
"rule_json": {
|
|
"unit": "CNY_per_million_tokens",
|
|
"token_formula_description": "(input_video_seconds + output_video_seconds) * width * height * fps / 1024",
|
|
"default_fps": 30,
|
|
"dimension_map": {},
|
|
"rates": [
|
|
{"resolutions": ["480p", "720p"], "has_input_video": False, "rate": "46"},
|
|
{"resolutions": ["480p", "720p"], "has_input_video": True, "rate": "28"},
|
|
{"resolutions": ["1080p"], "has_input_video": False, "rate": "51"},
|
|
{"resolutions": ["1080p"], "has_input_video": True, "rate": "31"},
|
|
{"resolutions": ["4k"], "has_input_video": False, "rate": "26"},
|
|
{"resolutions": ["4k"], "has_input_video": True, "rate": "16"},
|
|
],
|
|
},
|
|
"remark": "Seedance 2.0 标准版;dimension_map 空时只接受 Provider 实际 Token,不猜比例像素。",
|
|
},
|
|
{
|
|
**common,
|
|
"model_name": "doubao-seedance-2-0-fast-260128",
|
|
"model_category": ModelPricingCategory.VIDEO.value,
|
|
"billing_mode": ModelPricingBillingMode.VIDEO_TOKEN_RATE.value,
|
|
"calculator_version": ModelPricingCalculatorVersion.VIDEO_PIXEL_TOKEN_V1.value,
|
|
"version_code": "volc_20260709_v1",
|
|
"rule_json": {
|
|
"unit": "CNY_per_million_tokens",
|
|
"default_fps": 30,
|
|
"dimension_map": {},
|
|
"rates": [
|
|
{"resolutions": ["480p", "720p"], "has_input_video": False, "rate": "37"},
|
|
{"resolutions": ["480p", "720p"], "has_input_video": True, "rate": "22"},
|
|
],
|
|
},
|
|
"remark": "Seedance 2.0 Fast;仅配置支持的价格档位。",
|
|
},
|
|
{
|
|
**common,
|
|
"model_name": "doubao-seedance-2-0-mini-260615",
|
|
"model_category": ModelPricingCategory.VIDEO.value,
|
|
"billing_mode": ModelPricingBillingMode.VIDEO_TOKEN_RATE.value,
|
|
"calculator_version": ModelPricingCalculatorVersion.VIDEO_PIXEL_TOKEN_V1.value,
|
|
"version_code": "volc_20260709_v1",
|
|
"rule_json": {
|
|
"unit": "CNY_per_million_tokens",
|
|
"default_fps": 30,
|
|
"dimension_map": {},
|
|
"rates": [
|
|
{"resolutions": ["480p", "720p"], "has_input_video": False, "rate": "23"},
|
|
{"resolutions": ["480p", "720p"], "has_input_video": True, "rate": "14"},
|
|
],
|
|
},
|
|
"remark": "Seedance 2.0 Mini;仅配置支持的价格档位。",
|
|
},
|
|
{
|
|
**common,
|
|
"model_name": "doubao-seedance-1-5-pro-251215",
|
|
"model_category": ModelPricingCategory.VIDEO.value,
|
|
"billing_mode": ModelPricingBillingMode.VIDEO_TOKEN_RATE.value,
|
|
"calculator_version": ModelPricingCalculatorVersion.VIDEO_PIXEL_TOKEN_V1.value,
|
|
"version_code": "volc_20260709_v1",
|
|
"rule_json": {
|
|
"unit": "CNY_per_million_tokens",
|
|
"default_fps": 30,
|
|
"dimension_map": {},
|
|
"rates": [
|
|
{"inference_modes": ["online"], "generate_audio": False, "rate": "8"},
|
|
{"inference_modes": ["online"], "generate_audio": True, "rate": "16"},
|
|
{"inference_modes": ["flex", "batch"], "generate_audio": False, "rate": "4"},
|
|
{"inference_modes": ["flex", "batch"], "generate_audio": True, "rate": "8"},
|
|
],
|
|
},
|
|
"remark": "Seedance 1.5 Pro,按推理模式与有声/无声选择 Token 单价。",
|
|
},
|
|
{
|
|
**common,
|
|
"model_name": "doubao-seedance-1-0-pro-250528",
|
|
"model_category": ModelPricingCategory.VIDEO.value,
|
|
"billing_mode": ModelPricingBillingMode.VIDEO_TOKEN_RATE.value,
|
|
"calculator_version": ModelPricingCalculatorVersion.VIDEO_PIXEL_TOKEN_V1.value,
|
|
"version_code": "volc_20260709_v1",
|
|
"rule_json": {"unit": "CNY_per_million_tokens", "default_fps": 30, "dimension_map": {}, "rates": [{"rate": "15"}]},
|
|
"remark": "Seedance 1.0 Pro 固定 Token 单价。",
|
|
},
|
|
]
|
|
for item in rules:
|
|
prefix = item.pop("remark_prefix")
|
|
item["remark"] = f"{prefix} {item.get('remark') or ''}".strip()
|
|
return rules
|