diff --git a/control-plane-java/src/main/resources/db/migration/V25__tripo_standard_task_price.sql b/control-plane-java/src/main/resources/db/migration/V25__tripo_standard_task_price.sql new file mode 100644 index 0000000..a9d3138 --- /dev/null +++ b/control-plane-java/src/main/resources/db/migration/V25__tripo_standard_task_price.sql @@ -0,0 +1,20 @@ +-- Publish the official Tripo list price alongside the platform task price. +-- Tripo documents 1 credit = $0.01 USD and H-series text-to-3D with standard +-- textures costs 20 credits, so the source list price is $0.20 per task. +-- The platform price remains the configured CNY amount and is not presented as +-- a percentage discount unless an explicit discount is configured. +UPDATE model_catalog +SET pricing = pricing || jsonb_build_object( + 'standardPrice', jsonb_build_object( + 'price', 0.20, + 'unit', 'USD / task', + 'credits', 20, + 'priceSource', 'Tripo 官方 API 定价' + ), + 'discountLabel', '标准价' + ), + updated_at = now() +WHERE provider_id = 'provider-vast' + AND upstream_model IN ('v3.1-20260211', 'v3.0-20250812', 'v2.5-20250123') + AND deleted_at IS NULL + AND pricing IS NOT NULL; diff --git a/docs/15-relay-onboarding.md b/docs/15-relay-onboarding.md index acd8476..ee16559 100644 --- a/docs/15-relay-onboarding.md +++ b/docs/15-relay-onboarding.md @@ -1,6 +1,6 @@ # ApiHub、TokenFoundryX、APIPro 与 Tripo 接入清单 -核对日期:2026-09-27。MOYI 代码基线:V24 Tripo 目录迁移及真实异步队列修复。 +核对日期:2026-09-27。MOYI 代码基线:V25 Tripo 标准任务价、目录与真实异步队列修复。 本文记录供应商页面实际展示的模型 ID,不代表对其底层模型身份、宣传能力或官方版本名称的独立认证。目录可见不等于当前 Key 有权限,也不等于已经在 MOYI 实测。 @@ -167,7 +167,7 @@ MOYI 用户对外使用的统一 API Base URL 为 `https://moyi.soulofmodel.com/ - Java 执行器使用 Tripo V3 API Base URL:`https://openapi.tripo3d.com/v3`,提交 `POST /generation/text-to-model`,轮询 `GET /tasks/{task_id}`。 - 当前发布 H 系列 `v3.1-20260211`、`v3.0-20250812`、`v2.5-20250123` 三个异步文生 3D 模型;执行器会保留 Tripo 返回的任务状态和结果链接。 -- 现有适配器发送标准贴图参数(`texture=true`、`pbr=true`),按官方定价折算为每任务 20 credits,即默认 `¥1.44 / task`(按 1 USD = 7.2 CNY;管理员可以在模型与分组中调整售价)。 +- 现有适配器发送标准贴图参数(`texture=true`、`pbr=true`),官方标准价为每任务 20 credits,即 `$0.20 / task`(1 credit = $0.01);平台默认售价 `¥1.44 / task`(按 1 USD = 7.2 CNY;管理员可以在模型与分组中调整售价)。标准价与平台售价分别显示,不把汇率换算当成折扣。 - 若 Key 来自国内 `platform.tripo3d.com`,使用其对应文档与端点;不能假定 `.ai` 和 `.com` 凭据互通。 - 管理端已有 `vast-tripo` / `Tripo 官方` 渠道。可以在渠道管理中保存加密后的 Bearer Token,也可以在服务器 `.env.cloud` 中设置 `TRIPO_API_KEY`;环境变量只作为未配置数据库凭据时的安全回退,并支持后续轮换多个 Key(使用 `|` 分隔的上游 Key 列表时按轮询选择)。 - 配置真实 Key 后,先用一个低成本模型创建任务并轮询到终态,再把该分组发布给用户。不要把 Key 写入代码、SQL 迁移、Git 或聊天记录。 diff --git a/prototype/package.json b/prototype/package.json index e9d20b2..ce63818 100644 --- a/prototype/package.json +++ b/prototype/package.json @@ -4,7 +4,7 @@ "version": "0.1.0", "type": "module", "scripts": { - "test": "node --experimental-strip-types --test tests/chat-stream.test.mjs tests/model-catalog.test.mjs", + "test": "node --experimental-strip-types --test tests/chat-stream.test.mjs tests/model-catalog.test.mjs tests/pricing.test.mjs", "dev": "vite", "build": "vue-tsc --noEmit && vite build", "preview": "vite preview" diff --git a/prototype/src/services/catalog.ts b/prototype/src/services/catalog.ts index 9b30aaa..a6a0f1f 100644 --- a/prototype/src/services/catalog.ts +++ b/prototype/src/services/catalog.ts @@ -39,6 +39,8 @@ export interface CatalogModel { discountLabel?: string exchangeRate?: number priceSource?: string + upstreamCredits?: number + standardPrice?: { price?: number; unit?: string; credits?: number; priceSource?: string } listPriceUsd?: { input?: number; output?: number; cachedInput?: number } } pricingConfigured?: boolean diff --git a/prototype/src/services/pricing.ts b/prototype/src/services/pricing.ts new file mode 100644 index 0000000..84ce451 --- /dev/null +++ b/prototype/src/services/pricing.ts @@ -0,0 +1,90 @@ +export interface DisplayPricing { + price?: number + input?: number + output?: number + cachedInput?: number + unit?: string + discount?: number + discountLabel?: string + exchangeRate?: number + priceSource?: string + upstreamCredits?: number + standardPrice?: { price?: number; unit?: string; credits?: number; priceSource?: string } + listPriceUsd?: { input?: number; output?: number; cachedInput?: number } +} + +function numberLabel(value: number | undefined, currency = '¥') { + if (value === undefined || value === null || !Number.isFinite(value)) return '待配置' + return `${currency}${value.toLocaleString('zh-CN', { maximumFractionDigits: 8 })}` +} + +function unitLabel(unit: string | undefined) { + const value = String(unit || '').trim() + return value.replace(/^cny\s*\/\s*/i, '') || '计费单位' +} + +function unitSuffix(pricing: DisplayPricing) { + return unitLabel(pricing.unit).replace(/^1m\s+/i, '') +} + +function isTokenUnit(unit: string | undefined) { + return String(unit || '').toLowerCase().includes('token') +} + +function formatUsd(value: number | undefined) { + return numberLabel(value, '$') +} + +function fixedStandardPriceLabel(price: NonNullable) { + if (price.price === undefined || !Number.isFinite(price.price)) return undefined + const rawUnit = String(price.unit || 'USD / task').trim() + const match = rawUnit.match(/^([A-Za-z]{3})\s*\/\s*(.+)$/) + const currency = match?.[1]?.toUpperCase() + const symbol = currency === 'USD' ? '$' : currency === 'CNY' ? '¥' : currency ? `${currency} ` : '' + const unit = match?.[2] || rawUnit + const source = price.priceSource ? ` · ${price.priceSource}` : '' + return `${numberLabel(price.price, symbol)} / ${unit}${source}` +} + +/** Standard/list price is shown only when it is explicitly supplied by the source. */ +export function standardPriceLabel(pricing?: DisplayPricing) { + if (!pricing) return '标准价未提供' + const fixed = pricing.standardPrice ? fixedStandardPriceLabel(pricing.standardPrice) : undefined + if (fixed) return fixed + if (pricing.listPriceUsd) { + return `${formatUsd(pricing.listPriceUsd.input)} 输入 / ${formatUsd(pricing.listPriceUsd.output)} 输出 · USD / 1M` + } + const credits = pricing.upstreamCredits ?? pricing.standardPrice?.credits + if (credits !== undefined && Number.isFinite(credits)) { + return `标准价未提供 · 上游 ${credits} credits / ${unitSuffix(pricing)}` + } + return '标准价未提供' +} + +/** A logical model can have several routes. Do not present one route's list price as universal when they differ. */ +export function modelStandardPriceLabel(pricings: Array) { + const values = pricings.filter((pricing): pricing is DisplayPricing => !!pricing) + const listed = values.filter((pricing) => !!pricing.listPriceUsd || !!pricing.standardPrice) + if (listed.length > 0 && listed.length < values.length) return '部分分组标准价见详情' + if (listed.length > 1) { + const keys = new Set(listed.map((pricing) => JSON.stringify({ listPriceUsd: pricing.listPriceUsd, standardPrice: pricing.standardPrice }))) + if (keys.size > 1) return '各分组标准价见详情' + } + return standardPriceLabel(listed[0] || values[0]) +} + +export function platformPriceLabel(pricing?: DisplayPricing) { + if (!pricing) return '价格待配置' + if (isTokenUnit(pricing.unit)) { + return `${numberLabel(pricing.input)} 输入 / ${numberLabel(pricing.output)} 输出 · ${pricing.unit || 'CNY / 1M tokens'}` + } + const price = pricing.price ?? pricing.input + return price === undefined ? `计费单位:${unitLabel(pricing.unit)}` : `平台售价 ${numberLabel(price)} / ${unitSuffix(pricing)}` +} + +export function groupDiscountLabel(pricing?: DisplayPricing, configured = true) { + if (!configured || !pricing) return '价格待配置' + if (pricing.discountLabel && pricing.discountLabel !== '标准价') return pricing.discountLabel + if (pricing.discount !== undefined && Number.isFinite(pricing.discount)) return `${pricing.discount.toLocaleString('zh-CN', { maximumFractionDigits: 1 })}折` + return '折扣未提供' +} diff --git a/prototype/src/types.ts b/prototype/src/types.ts index fdf8976..4285c1a 100644 --- a/prototype/src/types.ts +++ b/prototype/src/types.ts @@ -44,6 +44,8 @@ export interface ModelItem { discountLabel?: string exchangeRate?: number priceSource?: string + upstreamCredits?: number + standardPrice?: { price?: number; unit?: string; credits?: number; priceSource?: string } listPriceUsd?: { input?: number; output?: number; cachedInput?: number } } pricingConfigured?: boolean diff --git a/prototype/src/views/UserConsole.vue b/prototype/src/views/UserConsole.vue index 2a1e578..c00c7e6 100644 --- a/prototype/src/views/UserConsole.vue +++ b/prototype/src/views/UserConsole.vue @@ -39,6 +39,7 @@ import { import type { ApiKeyItem, CallMode, ModelItem, ModelType, TaskItem, TaskStatus } from '../types' import { catalogClient, platformApiBaseUrl, type AsyncTaskResult, type CatalogApiKey, type CatalogModel, type LogicalModel, type CatalogProject, type PlatformOverview, type UserUsageRecord } from '../services/catalog' import { buildModelCatalog } from '../services/model-catalog' +import { groupDiscountLabel as formatGroupDiscountLabel, modelStandardPriceLabel, platformPriceLabel } from '../services/pricing' import { usePagination } from '../composables/usePagination' import ListPagination from '../components/ListPagination.vue' import { copyText, type CopyResult } from '../services/clipboard' @@ -212,36 +213,21 @@ const recentTasks = computed(() => tasks.value.slice(0, 3)) const modelTypes: Array<'全部' | ModelType> = ['全部', '文本', '多模态', '图像', '3D', '视频', '音频'] const callModes: Array<'全部' | CallMode> = ['全部', '同步', '流式', '异步'] -function formatUsdPrice(value: number | undefined) { - if (value === undefined || value === null) return '待配置' - return `$${value.toLocaleString('en-US', { maximumFractionDigits: 6 })}` +function standardPriceLabel(model: GalleryModel) { + return modelStandardPriceLabel(model.groups.map(group => group.pricing)) } -function standardPriceLabel(model: GalleryModel) { - const pricing = model.groups.find(group => group.pricing?.listPriceUsd)?.pricing - if (!pricing?.listPriceUsd) { - const unit = pricing?.unit - const price = pricing?.price ?? pricing?.input - return unit && price !== undefined ? `¥${Number(price).toLocaleString('zh-CN', { maximumFractionDigits: 8 })} / ${unit}` : '标准价待同步' - } - return `${formatUsdPrice(pricing.listPriceUsd.input)} 输入 / ${formatUsdPrice(pricing.listPriceUsd.output)} 输出 · USD / 1M` +function groupStandardPriceLabel(group: ModelItem) { + return modelStandardPriceLabel([group.pricing]) } function groupDiscountLabel(group: ModelItem) { - if (!group.pricingConfigured || !group.pricing) return '价格待配置' - return group.pricing.discountLabel || '折扣待配置' + return formatGroupDiscountLabel(group.pricing, group.pricingConfigured) } function groupPriceLabel(group: ModelItem) { - const pricing = group.pricing - if (!group.pricingConfigured || !pricing) return '当前不可调用:价格待配置' - if (pricing.unit && !String(pricing.unit).toLowerCase().includes('token')) { - const price = pricing.price ?? pricing.input - return price === undefined ? `计费单位:${pricing.unit}` : `¥${Number(price).toLocaleString('zh-CN', { maximumFractionDigits: 8 })} / ${pricing.unit}` - } - const input = pricing.input === undefined ? '待定' : `¥${pricing.input.toLocaleString('zh-CN', { maximumFractionDigits: 8 })}` - const output = pricing.output === undefined ? '待定' : `¥${pricing.output.toLocaleString('zh-CN', { maximumFractionDigits: 8 })}` - return `${input} 输入 / ${output} 输出 · ${pricing.unit || 'CNY / 1M tokens'}` + if (!group.pricingConfigured || !group.pricing) return '当前不可调用:价格待配置' + return platformPriceLabel(group.pricing) } function hasCallableGroup(model: GalleryModel) { @@ -615,7 +601,7 @@ async function createProject() { @@ -773,7 +759,7 @@ $env:OPENAI_API_KEY="你的 MOYI 用户 API Key" {{ group.sourceLabel || '默认分组' }}{{ group.provider }} - 标准价:{{ group.pricing?.listPriceUsd ? `${formatUsdPrice(group.pricing.listPriceUsd.input)} 输入 / ${formatUsdPrice(group.pricing.listPriceUsd.output)} 输出 · USD / 1M` : '待同步' }} · {{ groupPriceLabel(group) }} · 对外 {{ groupDiscountLabel(group) }} + 标准价:{{ groupStandardPriceLabel(group) }} · {{ groupPriceLabel(group) }} · 对外 {{ groupDiscountLabel(group) }} @@ -803,7 +789,7 @@ $env:OPENAI_API_KEY="你的 MOYI 用户 API Key" .model-pricing { display: grid; gap: 6px; margin-top: 10px; padding: 9px 10px; border: 1px solid #ece9f8; border-radius: 8px; color: #687378; background: #faf9ff; font-size: 9px; line-height: 1.55; } .model-pricing span { display: grid; gap: 2px; } .model-pricing strong { color: #4c3e87; font-size: 8px; letter-spacing: .03em; } -.model-pricing em { display: block; color: #687378; font-style: normal; } +.model-pricing em { display: block; color: #687378; font-style: normal; overflow-wrap: anywhere; } .drawer-pricing { line-height: 1.6; } .catalog-group-detail button:disabled { color: #8a6b32; cursor: default; } .request-panel, .response-panel { min-width: 0; } diff --git a/prototype/tests/pricing.test.mjs b/prototype/tests/pricing.test.mjs new file mode 100644 index 0000000..1cc737c --- /dev/null +++ b/prototype/tests/pricing.test.mjs @@ -0,0 +1,35 @@ +import { test } from 'node:test' +import assert from 'node:assert/strict' +import { groupDiscountLabel, modelStandardPriceLabel, platformPriceLabel, standardPriceLabel } from '../src/services/pricing.ts' + +test('fixed-unit pricing shows platform task price without inventing a standard price or discount', () => { + const tripo = { price: 1.44, unit: 'CNY / task', upstreamCredits: 20, exchangeRate: 7.2, priceSource: 'Tripo 官方', standardPrice: { price: 0.2, unit: 'USD / task', credits: 20 } } + assert.equal(standardPriceLabel(tripo), '$0.2 / task') + assert.equal(modelStandardPriceLabel([tripo]), '$0.2 / task') + assert.equal(platformPriceLabel(tripo), '平台售价 ¥1.44 / task') + assert.equal(groupDiscountLabel(tripo), '折扣未提供') +}) + +test('official standard price source is displayed, while a standard-price marker is not treated as a discount', () => { + const tripo = { price: 1.44, unit: 'CNY / task', discountLabel: '标准价', standardPrice: { price: 0.2, unit: 'USD / task', credits: 20, priceSource: 'Tripo 官方 API 定价' } } + assert.equal(standardPriceLabel(tripo), '$0.2 / task · Tripo 官方 API 定价') + assert.equal(groupDiscountLabel(tripo), '折扣未提供') +}) + +test('token pricing retains explicit source list price and discount', () => { + const pricing = { input: 1.2, output: 4.8, unit: 'CNY / 1M tokens', discount: 6.5, discountLabel: '6.5折', listPriceUsd: { input: 1, output: 4 } } + assert.equal(standardPriceLabel(pricing), '$1 输入 / $4 输出 · USD / 1M') + assert.equal(platformPriceLabel(pricing), '¥1.2 输入 / ¥4.8 输出 · CNY / 1M tokens') + assert.equal(groupDiscountLabel(pricing), '6.5折') +}) + +test('different route list prices are not presented as one universal model price', () => { + assert.equal(modelStandardPriceLabel([ + { unit: 'CNY / 1M tokens', listPriceUsd: { input: 1, output: 4 } }, + { unit: 'CNY / 1M tokens', listPriceUsd: { input: 2, output: 8 } }, + ]), '各分组标准价见详情') + assert.equal(modelStandardPriceLabel([ + { unit: 'CNY / 1M tokens', listPriceUsd: { input: 1, output: 4 } }, + { price: 1.44, unit: 'CNY / task' }, + ]), '部分分组标准价见详情') +}) diff --git a/scripts/package-deployment.ps1 b/scripts/package-deployment.ps1 index 45868e8..18a6027 100644 --- a/scripts/package-deployment.ps1 +++ b/scripts/package-deployment.ps1 @@ -19,7 +19,7 @@ try { $env:VITE_AUTH_MODE = 'remote' & node node_modules/vue-tsc/bin/vue-tsc.js --noEmit if ($LASTEXITCODE -ne 0) { throw 'Vue type check failed.' } - & node --experimental-strip-types --test tests/chat-stream.test.mjs tests/model-catalog.test.mjs + & node --experimental-strip-types --test tests/chat-stream.test.mjs tests/model-catalog.test.mjs tests/pricing.test.mjs if ($LASTEXITCODE -ne 0) { throw 'Frontend verification failed.' } & node build-release.mjs if ($LASTEXITCODE -ne 0) { throw 'Vue build failed.' } @@ -60,7 +60,7 @@ $manifest = [ordered]@{ javaRelease = 21 database = 'PostgreSQL 15' redis = 'Tair standard' - checks = @('maven-clean-verify', 'vue-tsc', 'frontend-stream-tests', 'frontend-catalog-tests', 'vite-build') + checks = @('maven-clean-verify', 'vue-tsc', 'frontend-stream-tests', 'frontend-catalog-tests', 'frontend-pricing-tests', 'vite-build') sha256 = $hashes } [IO.File]::WriteAllText((Join-Path $staging 'release-manifest.json'), ($manifest | ConvertTo-Json -Depth 5), [Text.UTF8Encoding]::new($false))