@nodaro/shared 3.62.0 → 3.63.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-6CSXMWL4.cjs → chunk-2PU3AGGS.cjs} +27 -4
- package/dist/chunk-2PU3AGGS.cjs.map +1 -0
- package/dist/{chunk-CC4V2B7S.js → chunk-34QLPTSA.js} +3 -3
- package/dist/{chunk-CC4V2B7S.js.map → chunk-34QLPTSA.js.map} +1 -1
- package/dist/{chunk-G4U3HW6W.js → chunk-3K24DWOH.js} +3 -3
- package/dist/{chunk-G4U3HW6W.js.map → chunk-3K24DWOH.js.map} +1 -1
- package/dist/{chunk-GSFB537T.js → chunk-4DVWXEB6.js} +23 -4
- package/dist/chunk-4DVWXEB6.js.map +1 -0
- package/dist/{chunk-ZES6EZC4.js → chunk-4MMZD63H.js} +3 -3
- package/dist/{chunk-ZES6EZC4.js.map → chunk-4MMZD63H.js.map} +1 -1
- package/dist/{chunk-N7OUQK7E.cjs → chunk-63H4C56Q.cjs} +8 -8
- package/dist/{chunk-N7OUQK7E.cjs.map → chunk-63H4C56Q.cjs.map} +1 -1
- package/dist/{chunk-2D5LQFV4.cjs → chunk-6BZC2ZHC.cjs} +9 -9
- package/dist/{chunk-2D5LQFV4.cjs.map → chunk-6BZC2ZHC.cjs.map} +1 -1
- package/dist/{chunk-3OYO3XCC.js → chunk-6M563QE6.js} +71 -9
- package/dist/chunk-6M563QE6.js.map +1 -0
- package/dist/{chunk-IDTKF5EX.cjs → chunk-6TGB7ECA.cjs} +7 -7
- package/dist/{chunk-IDTKF5EX.cjs.map → chunk-6TGB7ECA.cjs.map} +1 -1
- package/dist/{chunk-2HZGDZZN.cjs → chunk-6XUG4L7X.cjs} +6 -6
- package/dist/{chunk-2HZGDZZN.cjs.map → chunk-6XUG4L7X.cjs.map} +1 -1
- package/dist/{chunk-CIPPPT7E.cjs → chunk-77WU3V3J.cjs} +6 -6
- package/dist/{chunk-CIPPPT7E.cjs.map → chunk-77WU3V3J.cjs.map} +1 -1
- package/dist/{chunk-C7POAYFE.js → chunk-AE3AAJ4O.js} +3 -3
- package/dist/{chunk-C7POAYFE.js.map → chunk-AE3AAJ4O.js.map} +1 -1
- package/dist/{chunk-NGKKNSK6.js → chunk-BMJVKYVB.js} +36 -15
- package/dist/chunk-BMJVKYVB.js.map +1 -0
- package/dist/{chunk-YCXRSWCQ.js → chunk-CZ5IQB3L.js} +3 -3
- package/dist/{chunk-YCXRSWCQ.js.map → chunk-CZ5IQB3L.js.map} +1 -1
- package/dist/{chunk-E2HZTGYX.js → chunk-EPXGG27L.js} +7 -7
- package/dist/chunk-EPXGG27L.js.map +1 -0
- package/dist/{chunk-3M4BNKFJ.cjs → chunk-F6WGGYQW.cjs} +167 -3
- package/dist/chunk-F6WGGYQW.cjs.map +1 -0
- package/dist/{chunk-7FCTCWHD.js → chunk-FXGNRYQQ.js} +3 -3
- package/dist/{chunk-7FCTCWHD.js.map → chunk-FXGNRYQQ.js.map} +1 -1
- package/dist/{chunk-QWYFHQYK.cjs → chunk-GMBDLNLD.cjs} +86 -62
- package/dist/chunk-GMBDLNLD.cjs.map +1 -0
- package/dist/{chunk-KJSRPHJ2.cjs → chunk-GSKLPI3J.cjs} +100 -46
- package/dist/chunk-GSKLPI3J.cjs.map +1 -0
- package/dist/{chunk-S5TMRJMX.js → chunk-HBXF6RUU.js} +4 -4
- package/dist/{chunk-S5TMRJMX.js.map → chunk-HBXF6RUU.js.map} +1 -1
- package/dist/{chunk-S24ZBUB4.js → chunk-HWQ2SYNA.js} +6 -32
- package/dist/chunk-HWQ2SYNA.js.map +1 -0
- package/dist/{chunk-JJNNM23P.js → chunk-IY3Y462W.js} +3 -3
- package/dist/{chunk-JJNNM23P.js.map → chunk-IY3Y462W.js.map} +1 -1
- package/dist/{chunk-JZGZ26YB.js → chunk-KCZHQH2O.js} +4 -4
- package/dist/{chunk-JZGZ26YB.js.map → chunk-KCZHQH2O.js.map} +1 -1
- package/dist/{chunk-FVII3KHN.js → chunk-KMGCHV6O.js} +163 -4
- package/dist/chunk-KMGCHV6O.js.map +1 -0
- package/dist/{chunk-4ZEFP2FQ.cjs → chunk-L2TVY6XN.cjs} +4 -4
- package/dist/{chunk-4ZEFP2FQ.cjs.map → chunk-L2TVY6XN.cjs.map} +1 -1
- package/dist/{chunk-TRVWMKNE.cjs → chunk-LH72PQO2.cjs} +204 -52
- package/dist/chunk-LH72PQO2.cjs.map +1 -0
- package/dist/{chunk-HRY7KGAE.cjs → chunk-LMAQUR55.cjs} +6 -6
- package/dist/{chunk-HRY7KGAE.cjs.map → chunk-LMAQUR55.cjs.map} +1 -1
- package/dist/{chunk-MYJQELFN.cjs → chunk-M5OCFGHF.cjs} +254 -7
- package/dist/chunk-M5OCFGHF.cjs.map +1 -0
- package/dist/{chunk-I2RQB7VG.js → chunk-MD4XHED4.js} +3 -3
- package/dist/{chunk-I2RQB7VG.js.map → chunk-MD4XHED4.js.map} +1 -1
- package/dist/{chunk-6G7NN4S4.js → chunk-NIAFR5EE.js} +2 -2
- package/dist/chunk-NIAFR5EE.js.map +1 -0
- package/dist/{chunk-CF4S4N5X.js → chunk-O2QOBA6Q.js} +2 -2
- package/dist/{chunk-CF4S4N5X.js.map → chunk-O2QOBA6Q.js.map} +1 -1
- package/dist/{chunk-4GGLKRYI.cjs → chunk-O6TBB4IF.cjs} +2 -2
- package/dist/{chunk-4GGLKRYI.cjs.map → chunk-O6TBB4IF.cjs.map} +1 -1
- package/dist/{chunk-UDDVDQMF.js → chunk-OV3JTKBY.js} +166 -25
- package/dist/chunk-OV3JTKBY.js.map +1 -0
- package/dist/{chunk-5YYN5X57.js → chunk-PSKZKLDG.js} +252 -8
- package/dist/chunk-PSKZKLDG.js.map +1 -0
- package/dist/{chunk-IWWVPR3W.cjs → chunk-TM5JYSJF.cjs} +95 -19
- package/dist/chunk-TM5JYSJF.cjs.map +1 -0
- package/dist/{chunk-G3KVK7OU.cjs → chunk-V5EEQR2U.cjs} +21 -21
- package/dist/{chunk-G3KVK7OU.cjs.map → chunk-V5EEQR2U.cjs.map} +1 -1
- package/dist/{chunk-AOJ6B7K4.cjs → chunk-WZVIBAKN.cjs} +12 -12
- package/dist/chunk-WZVIBAKN.cjs.map +1 -0
- package/dist/{chunk-5M43XMRB.cjs → chunk-X5BAFW3Q.cjs} +8 -8
- package/dist/{chunk-5M43XMRB.cjs.map → chunk-X5BAFW3Q.cjs.map} +1 -1
- package/dist/{chunk-SYWR5G3T.js → chunk-XBTYGQ6Z.js} +51 -7
- package/dist/chunk-XBTYGQ6Z.js.map +1 -0
- package/dist/{chunk-AFYTX4AI.cjs → chunk-XGGZWA4A.cjs} +107 -50
- package/dist/chunk-XGGZWA4A.cjs.map +1 -0
- package/dist/{chunk-VACPZPUA.cjs → chunk-XGVJGNZW.cjs} +5 -5
- package/dist/{chunk-VACPZPUA.cjs.map → chunk-XGVJGNZW.cjs.map} +1 -1
- package/dist/{chunk-2W745U4A.cjs → chunk-Y35JQPT6.cjs} +42 -70
- package/dist/chunk-Y35JQPT6.cjs.map +1 -0
- package/dist/{chunk-KYMHFVAZ.cjs → chunk-Y4GCJJPF.cjs} +2 -2
- package/dist/chunk-Y4GCJJPF.cjs.map +1 -0
- package/dist/{chunk-PTD6EDUU.js → chunk-YUER7TJG.js} +3 -3
- package/dist/{chunk-PTD6EDUU.js.map → chunk-YUER7TJG.js.map} +1 -1
- package/dist/{chunk-Y6X7UJSD.js → chunk-YX6TFX7H.js} +66 -14
- package/dist/chunk-YX6TFX7H.js.map +1 -0
- package/dist/{chunk-TWF2OSH4.cjs → chunk-ZPE2ZTJ4.cjs} +4 -4
- package/dist/{chunk-TWF2OSH4.cjs.map → chunk-ZPE2ZTJ4.cjs.map} +1 -1
- package/dist/entries/apps.cjs +42 -42
- package/dist/entries/apps.js +7 -7
- package/dist/entries/credits.cjs +237 -169
- package/dist/entries/credits.d.cts +163 -16
- package/dist/entries/credits.d.ts +163 -16
- package/dist/entries/credits.js +10 -10
- package/dist/entries/llm-models.cjs +77 -57
- package/dist/entries/llm-models.d.cts +85 -6
- package/dist/entries/llm-models.d.ts +85 -6
- package/dist/entries/llm-models.js +2 -2
- package/dist/entries/media.cjs +63 -63
- package/dist/entries/media.d.cts +8 -0
- package/dist/entries/media.d.ts +8 -0
- package/dist/entries/media.js +1 -1
- package/dist/entries/model-catalog.cjs +121 -105
- package/dist/entries/model-catalog.d.cts +48 -18
- package/dist/entries/model-catalog.d.ts +48 -18
- package/dist/entries/model-catalog.js +4 -4
- package/dist/entries/models.cjs +418 -322
- package/dist/entries/models.d.cts +71 -5
- package/dist/entries/models.d.ts +71 -5
- package/dist/entries/models.js +5 -5
- package/dist/entries/nodes.cjs +216 -208
- package/dist/entries/nodes.d.cts +22 -6
- package/dist/entries/nodes.d.ts +22 -6
- package/dist/entries/nodes.js +8 -8
- package/dist/entries/pipeline.cjs +152 -152
- package/dist/entries/pipeline.d.cts +3 -3
- package/dist/entries/pipeline.d.ts +3 -3
- package/dist/entries/pipeline.js +3 -3
- package/dist/entries/runtime-config.cjs +29 -29
- package/dist/entries/runtime-config.d.cts +10 -7
- package/dist/entries/runtime-config.d.ts +10 -7
- package/dist/entries/runtime-config.js +1 -1
- package/dist/entries/social.cjs +177 -177
- package/dist/entries/social.js +2 -2
- package/dist/entries/types.d.cts +8 -0
- package/dist/entries/types.d.ts +8 -0
- package/dist/entries/ugc.cjs +71 -71
- package/dist/entries/ugc.js +4 -4
- package/dist/entries/video.cjs +154 -150
- package/dist/entries/video.d.cts +11 -2
- package/dist/entries/video.d.ts +11 -2
- package/dist/entries/video.js +6 -6
- package/dist/entries/workflow.d.cts +1 -1
- package/dist/entries/workflow.d.ts +1 -1
- package/dist/index.cjs +1727 -1515
- package/dist/index.d.cts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +23 -23
- package/dist/{model-catalog-CCEcv08q.d.cts → model-catalog-C_Eo35tL.d.cts} +30 -0
- package/dist/{model-catalog-CCEcv08q.d.ts → model-catalog-C_Eo35tL.d.ts} +30 -0
- package/dist/{model-constants-Cf3zaITt.d.cts → model-constants-Bg4ccSQb.d.ts} +138 -25
- package/dist/{model-constants-B88p6XR0.d.ts → model-constants-DWcxOmaY.d.cts} +138 -25
- package/package.json +1 -1
- package/src/__tests__/credit-identifiers.test.ts +29 -0
- package/src/__tests__/extend-providers.test.ts +106 -26
- package/src/__tests__/gvp-supported-providers.test.ts +27 -2
- package/src/__tests__/lip-sync-audio-rate.test.ts +74 -0
- package/src/__tests__/lip-sync-levers.test.ts +31 -0
- package/src/__tests__/llm-models.test.ts +132 -3
- package/src/__tests__/llm-price-key.test.ts +152 -1
- package/src/__tests__/nemotron-transcribe-pricing.test.ts +61 -0
- package/src/__tests__/normalize-node-params.test.ts +25 -0
- package/src/__tests__/pixverse-v6-max-catalog.test.ts +271 -0
- package/src/__tests__/prompt-length-limits.test.ts +4 -0
- package/src/__tests__/seedance-task-type.test.ts +13 -3
- package/src/__tests__/transcribe-capabilities.test.ts +39 -2
- package/src/__tests__/transcribe-preflight.test.ts +50 -1
- package/src/__tests__/video-audio-capability.test.ts +35 -6
- package/src/__tests__/video-resolution-billed-as-named.test.ts +30 -0
- package/src/__tests__/video-upscale-params.test.ts +62 -0
- package/src/catalog-projection.ts +8 -0
- package/src/credit-estimators/index.ts +10 -0
- package/src/credit-estimators/nemotron-transcribe.ts +87 -0
- package/src/credit-identifiers.ts +109 -35
- package/src/entries/credits.ts +12 -1
- package/src/entries/llm-models.ts +6 -0
- package/src/entries/model-catalog.ts +9 -0
- package/src/entries/models.ts +35 -0
- package/src/entries/nodes.ts +2 -0
- package/src/entries/video.ts +1 -1
- package/src/freecut-protocol.ts +8 -0
- package/src/lip-sync-levers.ts +56 -0
- package/src/lip-sync-pricing.ts +91 -1
- package/src/llm-models.ts +249 -4
- package/src/model-catalog.ts +250 -4
- package/src/model-constants.ts +277 -30
- package/src/model-tree.ts +2 -1
- package/src/nodaro-video-upscale.ts +48 -0
- package/src/node-default-mappings.ts +3 -0
- package/src/normalize-node-params.ts +49 -1
- package/src/runtime-config/contract.ts +10 -7
- package/src/seedance-draft.ts +2 -1
- package/src/transcribe-preflight.ts +58 -7
- package/src/video-duration.ts +9 -0
- package/src/video-ui-defaults.ts +5 -3
- package/src/video-upscale-params.ts +67 -0
- package/dist/chunk-2W745U4A.cjs.map +0 -1
- package/dist/chunk-3M4BNKFJ.cjs.map +0 -1
- package/dist/chunk-3OYO3XCC.js.map +0 -1
- package/dist/chunk-5YYN5X57.js.map +0 -1
- package/dist/chunk-6CSXMWL4.cjs.map +0 -1
- package/dist/chunk-6G7NN4S4.js.map +0 -1
- package/dist/chunk-AFYTX4AI.cjs.map +0 -1
- package/dist/chunk-AOJ6B7K4.cjs.map +0 -1
- package/dist/chunk-E2HZTGYX.js.map +0 -1
- package/dist/chunk-FVII3KHN.js.map +0 -1
- package/dist/chunk-GSFB537T.js.map +0 -1
- package/dist/chunk-IWWVPR3W.cjs.map +0 -1
- package/dist/chunk-KJSRPHJ2.cjs.map +0 -1
- package/dist/chunk-KYMHFVAZ.cjs.map +0 -1
- package/dist/chunk-MYJQELFN.cjs.map +0 -1
- package/dist/chunk-NGKKNSK6.js.map +0 -1
- package/dist/chunk-QWYFHQYK.cjs.map +0 -1
- package/dist/chunk-S24ZBUB4.js.map +0 -1
- package/dist/chunk-SYWR5G3T.js.map +0 -1
- package/dist/chunk-TRVWMKNE.cjs.map +0 -1
- package/dist/chunk-UDDVDQMF.js.map +0 -1
- package/dist/chunk-Y6X7UJSD.js.map +0 -1
package/src/lip-sync-pricing.ts
CHANGED
|
@@ -7,7 +7,78 @@
|
|
|
7
7
|
* (e.g. `kling-avatar:60s`) so credit reservation scales with input length.
|
|
8
8
|
*
|
|
9
9
|
* InfiniTalk still enforces a 15s upstream cap.
|
|
10
|
+
*
|
|
11
|
+
* A model listed in {@link LIP_SYNC_AUDIO_RATES} is priced differently: at a
|
|
12
|
+
* per-second RATE times the seconds of its audio, never by bucket.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { unitQuoteCreditId } from "./credit-estimators/unit-quote.js"
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A lip-sync model charged at a per-second rate: the rate's one-second price
|
|
19
|
+
* row times the seconds of the audio that drives it, rounded up once and marked
|
|
20
|
+
* up once by the pricing chain that charges every per-unit rate.
|
|
21
|
+
*/
|
|
22
|
+
export interface LipSyncAudioRate {
|
|
23
|
+
/** The one-second price row (`model_pricing`, else `STATIC_CREDIT_COSTS`). */
|
|
24
|
+
readonly rateId: string
|
|
25
|
+
/** The fewest seconds a run is charged. Shorter audio is padded with silence to this length before the model sees it. */
|
|
26
|
+
readonly minSeconds: number
|
|
27
|
+
/** The longest audio the model takes. Longer audio is refused before anything is held. */
|
|
28
|
+
readonly maxSeconds: number
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** OmniHuman 2.0's one-second price row. */
|
|
32
|
+
export const OMNIHUMAN_2_0_PER_SECOND_CREDIT_ID = "omnihuman-2-0:per-second"
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The lip-sync models charged per second of audio at a rate (decided
|
|
36
|
+
* 2026-11-11 for OmniHuman 2.0). Every price of such a run, its quote and its
|
|
37
|
+
* hold are the rate × {@link lipSyncBilledSeconds}.
|
|
38
|
+
*/
|
|
39
|
+
export const LIP_SYNC_AUDIO_RATES: Readonly<Record<string, LipSyncAudioRate>> = {
|
|
40
|
+
// OmniHuman 2.0 (KIE): audio from 4 to 300 seconds; the output is as long as the audio.
|
|
41
|
+
"omnihuman-2-0": { rateId: OMNIHUMAN_2_0_PER_SECOND_CREDIT_ID, minSeconds: 4, maxSeconds: 300 },
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** The per-second rate a lip-sync model is charged at, or undefined for every model priced another way. */
|
|
45
|
+
export function lipSyncAudioRateOf(provider: unknown): LipSyncAudioRate | undefined {
|
|
46
|
+
return typeof provider === "string" && Object.prototype.hasOwnProperty.call(LIP_SYNC_AUDIO_RATES, provider)
|
|
47
|
+
? LIP_SYNC_AUDIO_RATES[provider]
|
|
48
|
+
: undefined
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The seconds a run of a per-second-rate model is charged for audio measured at
|
|
53
|
+
* `measuredSec`: rounded up to a whole second, and at least the rate's minimum.
|
|
54
|
+
* THE one place this rounding happens — the route, the workflow run, the
|
|
55
|
+
* estimates and the provider's own cost all read it. Pass the length of the
|
|
56
|
+
* audio as it was given, never of a copy padded to the minimum (a padded clip
|
|
57
|
+
* runs a hair past it and would round up a whole second more).
|
|
58
|
+
*/
|
|
59
|
+
export function lipSyncBilledSeconds(rate: LipSyncAudioRate, measuredSec: number): number {
|
|
60
|
+
if (!Number.isFinite(measuredSec) || measuredSec <= 0) return rate.minSeconds
|
|
61
|
+
return Math.max(rate.minSeconds, Math.ceil(measuredSec))
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The length the editor quotes a lip-sync run on while its audio's length is
|
|
66
|
+
* not known yet — the 15 seconds every model priced by its audio shows then
|
|
67
|
+
* (a bucketed model's `:15s` row), marked as an estimate.
|
|
10
68
|
*/
|
|
69
|
+
export const LIP_SYNC_UNMEASURED_ESTIMATE_SECONDS = 15
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* The seconds an ESTIMATE prices a per-second-rate run at: the billed seconds
|
|
73
|
+
* of the audio when its length is known (at most the model's maximum, the most
|
|
74
|
+
* a run can be charged), else `unknownSec` — by default the maximum, so a
|
|
75
|
+
* server estimate never quotes below what the run may hold; the editor passes
|
|
76
|
+
* {@link LIP_SYNC_UNMEASURED_ESTIMATE_SECONDS} and shows the figure as an estimate.
|
|
77
|
+
*/
|
|
78
|
+
export function lipSyncEstimateSeconds(rate: LipSyncAudioRate, knownSec: number | undefined, unknownSec: number = rate.maxSeconds): number {
|
|
79
|
+
if (knownSec === undefined || !Number.isFinite(knownSec) || knownSec <= 0) return lipSyncBilledSeconds(rate, unknownSec)
|
|
80
|
+
return lipSyncBilledSeconds(rate, Math.min(knownSec, rate.maxSeconds))
|
|
81
|
+
}
|
|
11
82
|
|
|
12
83
|
export const LIP_SYNC_DURATION_BUCKETS = [15, 30, 60, 120, 300] as const
|
|
13
84
|
|
|
@@ -42,13 +113,32 @@ export const LIP_SYNC_MAX_AUDIO_SECONDS: Record<string, number> = {
|
|
|
42
113
|
"sync-lipsync-v3": 300,
|
|
43
114
|
// Volcengine (KIE) — video-to-video dubbing, per-second, 5-min ceiling.
|
|
44
115
|
"volcengine-lipsync": 300,
|
|
116
|
+
// The per-second-rate models: their own maximum (longer audio is refused, never trimmed).
|
|
117
|
+
...Object.fromEntries(Object.entries(LIP_SYNC_AUDIO_RATES).map(([provider, rate]) => [provider, rate.maxSeconds])),
|
|
45
118
|
}
|
|
46
119
|
|
|
47
120
|
export function getLipSyncMaxAudioSeconds(provider: string): number {
|
|
48
121
|
return LIP_SYNC_MAX_AUDIO_SECONDS[provider] ?? 15
|
|
49
122
|
}
|
|
50
123
|
|
|
51
|
-
/**
|
|
124
|
+
/**
|
|
125
|
+
* The id whose price is a 15-second run of a lip-sync model priced by the
|
|
126
|
+
* length of its audio — the bucket row of a bucketed model (`<provider>:15s`),
|
|
127
|
+
* the 15-second quote of a per-second-rate model — or undefined for a model
|
|
128
|
+
* with one price. A model menu shows a per-second rate from it.
|
|
129
|
+
*/
|
|
130
|
+
export function lipSyncFifteenSecondCreditId(provider: string): string | undefined {
|
|
131
|
+
const rate = lipSyncAudioRateOf(provider)
|
|
132
|
+
if (rate) return unitQuoteCreditId(rate.rateId, LIP_SYNC_UNMEASURED_ESTIMATE_SECONDS)
|
|
133
|
+
return isPerSecondLipSyncProvider(provider) ? `${provider}:${LIP_SYNC_UNMEASURED_ESTIMATE_SECONDS}s` : undefined
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Providers whose credit cost varies with audio duration, priced by BUCKET
|
|
138
|
+
* (`<provider>:<bucket>s`). A model charged at a per-second rate
|
|
139
|
+
* ({@link LIP_SYNC_AUDIO_RATES}) is never listed here: every caller that
|
|
140
|
+
* branches on this set would bucket it.
|
|
141
|
+
*/
|
|
52
142
|
const PER_SECOND_LIP_SYNC_PROVIDERS = new Set([
|
|
53
143
|
"kling-avatar",
|
|
54
144
|
"kling-avatar-pro",
|
package/src/llm-models.ts
CHANGED
|
@@ -75,6 +75,18 @@ export interface LlmModelDef {
|
|
|
75
75
|
* Capability-driven so `llmCompleteStructured` never hardcodes provider ids.
|
|
76
76
|
*/
|
|
77
77
|
structuredOutputMode?: "anthropic-tool" | "kie-response-format" | "responses-json-schema"
|
|
78
|
+
/**
|
|
79
|
+
* For a model with NO trusted `structuredOutputMode`: the wire field a
|
|
80
|
+
* structured call still sends its schema in, as a hint the model reads but
|
|
81
|
+
* the provider was not found to hold its answer to. Read through
|
|
82
|
+
* {@link structuredWireMode}, which every request builder uses; everything
|
|
83
|
+
* that decides TRUST (STRUCTURED_VISION_MODELS, the structured-model
|
|
84
|
+
* filters) keeps reading `structuredOutputMode` alone, so a hinted model is
|
|
85
|
+
* never offered where guaranteed structured output is required. Every answer
|
|
86
|
+
* is still parsed, validated and re-asked by `llmCompleteStructured`, as for
|
|
87
|
+
* any model. Never set together with `structuredOutputMode` (registry test).
|
|
88
|
+
*/
|
|
89
|
+
structuredOutputHint?: "kie-response-format" | "responses-json-schema"
|
|
78
90
|
/** If set, fallback to direct Anthropic SDK with this model ID when KIE.ai fails */
|
|
79
91
|
directFallbackModel?: string
|
|
80
92
|
/**
|
|
@@ -118,6 +130,27 @@ export interface LlmModelDef {
|
|
|
118
130
|
directOnly?: true
|
|
119
131
|
/** Effort levels this model accepts (ascending). Absent/empty = no effort lever, picker hidden. */
|
|
120
132
|
reasoningEfforts?: readonly LlmReasoningEffort[]
|
|
133
|
+
/**
|
|
134
|
+
* true = a REQUESTED effort below this model's lowest level is sent as that
|
|
135
|
+
* lowest level, never as nothing ({@link effectiveReasoningEffort}): with no
|
|
136
|
+
* effort on the wire the provider runs this model at its HIGHEST level, so
|
|
137
|
+
* dropping a `none` request would buy the most reasoning instead of the
|
|
138
|
+
* least. Auto — no effort requested at all — still sends nothing. Absent =
|
|
139
|
+
* a request below the lowest level is dropped (Auto), the usual rule.
|
|
140
|
+
*/
|
|
141
|
+
effortBelowLowestSendsLowest?: true
|
|
142
|
+
/**
|
|
143
|
+
* true = the PRICE of a call on this model depends on whether it sends a
|
|
144
|
+
* reasoning effort, not only on its lane: the aggregator adds input of its
|
|
145
|
+
* own to every call, whose size depends on it. So the model's price key
|
|
146
|
+
* names the effort a call sends ({@link llmPriceKey}: `:effort-<level>`),
|
|
147
|
+
* and every estimate surface quotes that call. The sizes themselves are
|
|
148
|
+
* backend data (`backend/src/lib/pricing/llm-cost.ts`), held to this flag by
|
|
149
|
+
* a backend test. No model sets it today (GPT-6.1 Terra did for part of
|
|
150
|
+
* 2026-11-12, until its aggregator's added input stopped depending on the
|
|
151
|
+
* effort).
|
|
152
|
+
*/
|
|
153
|
+
effortPriced?: true
|
|
121
154
|
/**
|
|
122
155
|
* Effort levels available on the DIRECT lane, when the vendor's own API
|
|
123
156
|
* accepts more than the aggregator does. Absent = the direct lane offers the
|
|
@@ -564,6 +597,54 @@ export const LLM_MODELS: readonly LlmModelDef[] = [
|
|
|
564
597
|
// ended early (one declined the task, one stopped on RECITATION).
|
|
565
598
|
thinkingDefaultOn: true,
|
|
566
599
|
},
|
|
600
|
+
{
|
|
601
|
+
id: "gemini-4-carbon",
|
|
602
|
+
displayName: "Gemini 4 Carbon",
|
|
603
|
+
series: "Gemini",
|
|
604
|
+
desc: "Deepest-reasoning Gemini, 1M context",
|
|
605
|
+
tier: "premium",
|
|
606
|
+
kieFormat: "chat-completions",
|
|
607
|
+
// KIE serves it on the OpenAI-compatible dialect under this slug
|
|
608
|
+
// (docs.kie.ai/market/gemini/gemini-4-carbon-openai — Argon's page with the
|
|
609
|
+
// name swapped). Unlike Argon's, this lane passed its probe (2026-11-12):
|
|
610
|
+
// every call answered, images read, a stream ended cleanly, no empty 200,
|
|
611
|
+
// no negative counts, no code-execution fences. KIE flags it "Chat only",
|
|
612
|
+
// like Argon: it may not back a tool-loop feature (none does today).
|
|
613
|
+
kieSlugOrModel: "gemini-4-carbon-openai",
|
|
614
|
+
vendor: "google",
|
|
615
|
+
// NO trusted `structuredOutputMode` (decided 2026-11-12): KIE did NOT
|
|
616
|
+
// enforce a `response_format` json_schema — both probe calls came back as
|
|
617
|
+
// JSON holding an off-enum value in the enum field ("cheerful and
|
|
618
|
+
// energized" for happy | sad). So it is not a STRUCTURED_VISION_MODELS
|
|
619
|
+
// member (not offered by describe-to-picker), and every answer is parsed,
|
|
620
|
+
// validated and re-asked by `llmCompleteStructured`.
|
|
621
|
+
// The schema still goes on the wire, as a hint (`structuredOutputHint`): as
|
|
622
|
+
// `response_format` on KIE (the probe's replies followed its shape, only the
|
|
623
|
+
// enum slipped) and as `responseJsonSchema` on the direct Google lane,
|
|
624
|
+
// which enforced it in the probe — on every attempt, the re-ask included.
|
|
625
|
+
structuredOutputHint: "kie-response-format",
|
|
626
|
+
supportsImages: true,
|
|
627
|
+
// The registry's usual 16384, as Argon. Every call is floored to the
|
|
628
|
+
// default 32768 (`thinkingDefaultOn`, below): Google lists an output cap of
|
|
629
|
+
// 32,768 (models.list) and accepted maxOutputTokens 65536; KIE's doc
|
|
630
|
+
// states up to 65,536 tokens, thinking included.
|
|
631
|
+
maxOutputTokens: 16384,
|
|
632
|
+
// KIE first, Google as the reliability fallback (and Advanced mode) — no
|
|
633
|
+
// `preferDirect`, no `directOnly`. Google serves `models/gemini-4-carbon`
|
|
634
|
+
// beside Argon (models.list, 2026-11-12).
|
|
635
|
+
directGeminiModel: "gemini-4-carbon",
|
|
636
|
+
// KIE's documented `reasoning_effort` enum, and the direct lane's ladder
|
|
637
|
+
// too: Google 400s thinkingLevel MINIMAL on this model ("not supported")
|
|
638
|
+
// and answers LOW / MEDIUM / HIGH (probed 2026-11-12) — Argon's shape. So
|
|
639
|
+
// no `none` (it maps to MINIMAL in the direct client) and no
|
|
640
|
+
// `directReasoningEfforts`: a `none` request clamps to Auto on both lanes.
|
|
641
|
+
reasoningEfforts: ["low", "medium", "high"],
|
|
642
|
+
// Reasons with no thinking param sent on both lanes: KIE's `total_tokens`
|
|
643
|
+
// ran well past prompt + completion on every no-effort call (its dialect
|
|
644
|
+
// reports no reasoning split), and Google's no-level call reported thought
|
|
645
|
+
// tokens. No `reasoningOutputFloor`: both lanes take the default 32768.
|
|
646
|
+
thinkingDefaultOn: true,
|
|
647
|
+
},
|
|
567
648
|
{
|
|
568
649
|
id: "claude-opus-4.7",
|
|
569
650
|
displayName: "Claude Opus 4.7",
|
|
@@ -807,6 +888,43 @@ export const LLM_MODELS: readonly LlmModelDef[] = [
|
|
|
807
888
|
supportsTemperature: false,
|
|
808
889
|
thinkingDefaultOn: true,
|
|
809
890
|
},
|
|
891
|
+
{
|
|
892
|
+
id: "gpt-6.1-terra",
|
|
893
|
+
displayName: "GPT-6.1 Terra",
|
|
894
|
+
series: "GPT",
|
|
895
|
+
desc: "Fast, efficient GPT-6.1, sharp visual reasoning",
|
|
896
|
+
tier: "standard",
|
|
897
|
+
kieFormat: "responses",
|
|
898
|
+
// The GPT-6 wire (codex/v1/responses, derived from `vendor`); KIE's doc is
|
|
899
|
+
// 6.1 Sol's page with the name swapped and `none` added to the effort enum.
|
|
900
|
+
// Live-probed 2026-11-12: non-stream 16/16, `text.format` json_schema
|
|
901
|
+
// ENFORCED (asked for prose, it returned schema JSON with the enum
|
|
902
|
+
// honoured), data-URI vision, SSE deltas. Unlike luna / sol / 6.1 sol it
|
|
903
|
+
// reports REAL top-level `usage.input_tokens` — see `kieInputUntrusted` in
|
|
904
|
+
// backend/src/lib/llm/kie-cost.ts.
|
|
905
|
+
//
|
|
906
|
+
// KIE's endpoint adds its own instructions to every call and counts them as
|
|
907
|
+
// input. The hold and the estimate count them too
|
|
908
|
+
// (backend/src/lib/pricing/llm-cost.ts, `llmLaneAddedInputTokens`). They
|
|
909
|
+
// were several times larger with an effort sent on the morning of
|
|
910
|
+
// 2026-11-12 and the same size either way by that afternoon, so its price
|
|
911
|
+
// does not depend on the effort: not `effortPriced` (re-measure if KIE's
|
|
912
|
+
// reported input jumps again).
|
|
913
|
+
kieSlugOrModel: "gpt-6-1-terra",
|
|
914
|
+
vendor: "openai",
|
|
915
|
+
structuredOutputMode: "responses-json-schema",
|
|
916
|
+
supportsImages: true,
|
|
917
|
+
maxOutputTokens: 16384,
|
|
918
|
+
// NO `none` (decided 2026-11-12): KIE answers it, but a `none` sent on the
|
|
919
|
+
// wire is answered as an effort (it echoed `medium`) while reasoning no
|
|
920
|
+
// more than Auto. Clamping maps a `none` request to nothing sent (Auto).
|
|
921
|
+
reasoningEfforts: ["low", "medium", "high", "xhigh", "max"],
|
|
922
|
+
// Same doc as 6.1 Sol: no temperature lever.
|
|
923
|
+
supportsTemperature: false,
|
|
924
|
+
// NO `thinkingDefaultOn`: with no effort sent (and at low / medium / high)
|
|
925
|
+
// the probe reported 0 reasoning tokens; only xhigh (8) and max (27)
|
|
926
|
+
// reasoned, and those already floor the cap (`raiseToReasoningFloor`).
|
|
927
|
+
},
|
|
810
928
|
{
|
|
811
929
|
id: "grok-4.6",
|
|
812
930
|
displayName: "Grok 4.6",
|
|
@@ -1036,12 +1154,49 @@ export const LLM_MODELS: readonly LlmModelDef[] = [
|
|
|
1036
1154
|
// KIE's documented enum. The endpoint accepted xhigh/none without error but
|
|
1037
1155
|
// never echoes an effort back, so nothing beyond the doc is verifiable.
|
|
1038
1156
|
reasoningEfforts: ["low", "medium", "high"],
|
|
1157
|
+
// Decided 2026-11-12: a request below `low` (`none`) is sent as `low`,
|
|
1158
|
+
// never as nothing — KIE runs Kimi at its highest level when no effort is
|
|
1159
|
+
// sent (K3.1 Pro's no-effort replies echoed `max`). Auto still sends nothing.
|
|
1160
|
+
effortBelowLowestSendsLowest: true,
|
|
1039
1161
|
// The doc lists no `temperature` field at all.
|
|
1040
1162
|
supportsTemperature: false,
|
|
1041
1163
|
// "Reasons by default" per KIE's doc (its usage reports no reasoning-token
|
|
1042
1164
|
// split, so this is the doc's word, not a measurement).
|
|
1043
1165
|
thinkingDefaultOn: true,
|
|
1044
1166
|
},
|
|
1167
|
+
{
|
|
1168
|
+
id: "kimi-k3.1-pro",
|
|
1169
|
+
displayName: "Kimi K3.1 Pro",
|
|
1170
|
+
series: "Kimi",
|
|
1171
|
+
desc: "Kimi tuned for coding and research, 1M context",
|
|
1172
|
+
tier: "premium",
|
|
1173
|
+
kieFormat: "responses",
|
|
1174
|
+
// Same openai/v1/responses family path and wire as kimi-k3 (KIE's doc is
|
|
1175
|
+
// K3's page with the name and the effort enum changed). Live-probed
|
|
1176
|
+
// 2026-11-12: non-stream 9/9, `text.format` json_schema ENFORCED (asked for
|
|
1177
|
+
// prose, it returned schema JSON with the enum honoured), data-URI vision,
|
|
1178
|
+
// real `usage.input_tokens` and `credits_consumed`. Its stream sends
|
|
1179
|
+
// `response.reasoning_text.delta` frames apart from the
|
|
1180
|
+
// `response.output_text.delta` ones, and only the latter are the answer.
|
|
1181
|
+
kieSlugOrModel: "kimi-k3-1-pro",
|
|
1182
|
+
vendor: "moonshot",
|
|
1183
|
+
structuredOutputMode: "responses-json-schema",
|
|
1184
|
+
supportsImages: true,
|
|
1185
|
+
maxOutputTokens: 16384,
|
|
1186
|
+
// KIE's documented enum (K3's was low / medium / high). Each level was
|
|
1187
|
+
// echoed back. An off-enum `medium` answered too (echoed as `high`), so it
|
|
1188
|
+
// is not offered: a `medium` request clamps down to `low`.
|
|
1189
|
+
reasoningEfforts: ["low", "high", "max"],
|
|
1190
|
+
// Decided 2026-11-12: a request below `low` (`none`) is sent as `low`,
|
|
1191
|
+
// never as nothing — with no effort sent KIE runs it at `max` (the probe's
|
|
1192
|
+
// no-effort replies echoed `max`). Auto still sends nothing.
|
|
1193
|
+
effortBelowLowestSendsLowest: true,
|
|
1194
|
+
// The doc lists no `temperature` field at all, as K3's.
|
|
1195
|
+
supportsTemperature: false,
|
|
1196
|
+
// Measured: every probe call reported reasoning tokens (20 to 163), the
|
|
1197
|
+
// no-effort ones included (they echoed effort `max`).
|
|
1198
|
+
thinkingDefaultOn: true,
|
|
1199
|
+
},
|
|
1045
1200
|
{
|
|
1046
1201
|
id: "deepseek-v4.1-flash",
|
|
1047
1202
|
displayName: "DeepSeek V4.1 Flash",
|
|
@@ -1099,6 +1254,31 @@ export const STRUCTURED_VISION_MODELS = LLM_MODELS.filter(
|
|
|
1099
1254
|
(m) => m.supportsImages && m.structuredOutputMode != null,
|
|
1100
1255
|
)
|
|
1101
1256
|
|
|
1257
|
+
/**
|
|
1258
|
+
* How a structured call's schema goes on the wire for `model`: its trusted
|
|
1259
|
+
* `structuredOutputMode`, else its `structuredOutputHint`; undefined = the
|
|
1260
|
+
* schema is not sent at all (a model with neither: plain text, parsed and
|
|
1261
|
+
* re-asked). What the request builders read — never a TRUST decision, which
|
|
1262
|
+
* reads `structuredOutputMode` alone.
|
|
1263
|
+
*/
|
|
1264
|
+
export function structuredWireMode(
|
|
1265
|
+
model: Pick<LlmModelDef, "structuredOutputMode" | "structuredOutputHint">,
|
|
1266
|
+
): LlmModelDef["structuredOutputMode"] {
|
|
1267
|
+
return model.structuredOutputMode ?? model.structuredOutputHint
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
/**
|
|
1271
|
+
* Does a structured call on `modelId` (unset = `feature`'s default model) put
|
|
1272
|
+
* its schema on the wire ({@link structuredWireMode})? What a request's size
|
|
1273
|
+
* counts the schema by — a schema that is not sent is not read by the model.
|
|
1274
|
+
* A model the registry does not know counts as yes (the larger size).
|
|
1275
|
+
*/
|
|
1276
|
+
export function llmSendsSchema(modelId: string | undefined, feature?: string): boolean {
|
|
1277
|
+
const id = modelId || (feature ? LLM_FEATURE_DEFAULTS[feature as LlmFeature] : undefined)
|
|
1278
|
+
const model = id ? getLlmModel(id) : undefined
|
|
1279
|
+
return !model || structuredWireMode(model) !== undefined
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1102
1282
|
/**
|
|
1103
1283
|
* Models {@link STRUCTURED_VISION_MODELS} carries that describe-to-picker does
|
|
1104
1284
|
* NOT offer — now none.
|
|
@@ -1376,6 +1556,12 @@ export const LLM_MODALITY_CAPS: Record<string, { image: boolean; video: boolean;
|
|
|
1376
1556
|
// video-analysis tier + pricing decision. That waits on a Video Analysis
|
|
1377
1557
|
// bake-off; flip these two flags ONLY together with its outcome.
|
|
1378
1558
|
"gemini-4-argon": { image: true, video: false, audio: false },
|
|
1559
|
+
// gemini-4-carbon is IMAGE-ONLY for now, by decision (2026-11-12): the model
|
|
1560
|
+
// reads video and audio, but full caps would auto-enroll it in
|
|
1561
|
+
// VIDEO_ANALYSIS_LLM_MODELS (derived below). Its video + audio input comes in
|
|
1562
|
+
// a follow-up change that also decides its Video Analysis enrolment; flip
|
|
1563
|
+
// these two flags ONLY together with that.
|
|
1564
|
+
"gemini-4-carbon": { image: true, video: false, audio: false },
|
|
1379
1565
|
"claude-haiku-4.5": { image: true, video: false, audio: false },
|
|
1380
1566
|
"claude-haiku-5.5": { image: true, video: false, audio: false },
|
|
1381
1567
|
"claude-sonnet-4.6": { image: true, video: false, audio: false },
|
|
@@ -1392,6 +1578,8 @@ export const LLM_MODALITY_CAPS: Record<string, { image: boolean; video: boolean;
|
|
|
1392
1578
|
"gpt-6-luna": { image: true, video: false, audio: false },
|
|
1393
1579
|
"gpt-6-sol": { image: true, video: false, audio: false },
|
|
1394
1580
|
"gpt-6.1-sol": { image: true, video: false, audio: false },
|
|
1581
|
+
// KIE's doc also takes files (PDFs, documents); that input is not wired here.
|
|
1582
|
+
"gpt-6.1-terra": { image: true, video: false, audio: false },
|
|
1395
1583
|
"grok-4.6": { image: true, video: false, audio: false },
|
|
1396
1584
|
"grok-4.7": { image: true, video: false, audio: false },
|
|
1397
1585
|
"claude-sonnet-5": { image: true, video: false, audio: false },
|
|
@@ -1402,6 +1590,7 @@ export const LLM_MODALITY_CAPS: Record<string, { image: boolean; video: boolean;
|
|
|
1402
1590
|
"claude-fable-5": { image: true, video: false, audio: false },
|
|
1403
1591
|
// KIE documents text + image input only for both.
|
|
1404
1592
|
"kimi-k3": { image: true, video: false, audio: false },
|
|
1593
|
+
"kimi-k3.1-pro": { image: true, video: false, audio: false },
|
|
1405
1594
|
"deepseek-v4.1-flash": { image: true, video: false, audio: false },
|
|
1406
1595
|
}
|
|
1407
1596
|
|
|
@@ -1479,7 +1668,12 @@ export function availableReasoningEfforts(
|
|
|
1479
1668
|
return model.reasoningEfforts ?? []
|
|
1480
1669
|
}
|
|
1481
1670
|
|
|
1482
|
-
/**
|
|
1671
|
+
/**
|
|
1672
|
+
* Highest level the model supports that is ≤ the requested level; undefined =
|
|
1673
|
+
* treat as Auto. A request below the model's lowest level is dropped (Auto) —
|
|
1674
|
+
* except on a model that declares `effortBelowLowestSendsLowest`, where it is
|
|
1675
|
+
* sent as that lowest level. No request at all is always Auto.
|
|
1676
|
+
*/
|
|
1483
1677
|
export function effectiveReasoningEffort(
|
|
1484
1678
|
modelId: string | undefined,
|
|
1485
1679
|
requested?: string,
|
|
@@ -1493,6 +1687,7 @@ export function effectiveReasoningEffort(
|
|
|
1493
1687
|
for (const l of levels) {
|
|
1494
1688
|
if (EFFORT_RANK[l] <= EFFORT_RANK[req] && (best === undefined || EFFORT_RANK[l] > EFFORT_RANK[best])) best = l
|
|
1495
1689
|
}
|
|
1690
|
+
if (best === undefined && getLlmModel(modelId ?? "")?.effortBelowLowestSendsLowest) return levels[0]
|
|
1496
1691
|
return best
|
|
1497
1692
|
}
|
|
1498
1693
|
|
|
@@ -1610,12 +1805,16 @@ export function llmServesDirect(
|
|
|
1610
1805
|
* `POST /v1/credits/model-costs` (or `GET /v1/credits/model-cost?model=`) for
|
|
1611
1806
|
* the call's estimated price: `<feature>:<modelId>`, plus `:direct` when the
|
|
1612
1807
|
* call is served on the vendor's own API ({@link llmServesDirect}), which is
|
|
1613
|
-
* priced at the direct rate
|
|
1808
|
+
* priced at the direct rate, or — on a model whose price depends on the effort
|
|
1809
|
+
* (`effortPriced`, served on the aggregator) — `:effort-<level>` naming the
|
|
1810
|
+
* effort the call sends. On every other model the effort changes the key only
|
|
1811
|
+
* through its lane. Read back by {@link parseLlmPriceKeyModel}.
|
|
1614
1812
|
*
|
|
1615
1813
|
* With no `reasoningEffort` the default effort of the feature the call
|
|
1616
1814
|
* borrows its defaults from applies ({@link llmDefaultsFeature},
|
|
1617
1815
|
* {@link defaultReasoningEffort}) — the effort the call then runs at — so the
|
|
1618
|
-
* key names the lane the call is held and
|
|
1816
|
+
* key names the lane (and, where it matters, the effort) the call is held and
|
|
1817
|
+
* charged on.
|
|
1619
1818
|
*
|
|
1620
1819
|
* `modelId` must already be resolved: the model the call runs on, never empty
|
|
1621
1820
|
* (a caller with no model passes the feature's default, `LLM_FEATURE_DEFAULTS`
|
|
@@ -1629,7 +1828,53 @@ export function llmPriceKey(
|
|
|
1629
1828
|
): string {
|
|
1630
1829
|
if (!modelId) throw new TypeError(`llmPriceKey: modelId must be a resolved model id (feature "${feature}")`)
|
|
1631
1830
|
const effort = reasoningEffort ?? defaultReasoningEffort(llmDefaultsFeature(feature), modelId)
|
|
1632
|
-
|
|
1831
|
+
if (llmServesDirect(modelId, effort, advancedMode)) return `${feature}:${modelId}${LLM_PRICE_KEY_DIRECT}`
|
|
1832
|
+
// A model whose price depends on the effort (`effortPriced`) names the one
|
|
1833
|
+
// the call sends — clamped as the aggregator's wire clamps it, so a level it
|
|
1834
|
+
// does not offer is the effort that is really sent (or none). Every other
|
|
1835
|
+
// model's key is unchanged.
|
|
1836
|
+
const sent = getLlmModel(modelId)?.effortPriced ? effectiveReasoningEffort(modelId, effort) : undefined
|
|
1837
|
+
return sent ? `${feature}:${modelId}${LLM_PRICE_KEY_EFFORT}${sent}` : `${feature}:${modelId}`
|
|
1838
|
+
}
|
|
1839
|
+
|
|
1840
|
+
/** The price-key suffix of a call served on the vendor's own API (see {@link llmPriceKey}). */
|
|
1841
|
+
export const LLM_PRICE_KEY_DIRECT = ":direct"
|
|
1842
|
+
/** The price-key suffix naming the effort a call sends, on an `effortPriced` model: `:effort-<level>`. */
|
|
1843
|
+
export const LLM_PRICE_KEY_EFFORT = ":effort-"
|
|
1844
|
+
|
|
1845
|
+
/** A price key's model part, read back by {@link parseLlmPriceKeyModel}. */
|
|
1846
|
+
export interface LlmPriceKeyModel {
|
|
1847
|
+
modelId: string
|
|
1848
|
+
/** Present only for a key that names the direct lane. */
|
|
1849
|
+
lane?: "direct"
|
|
1850
|
+
/** Present only for a key that names an effort (an `effortPriced` model's). */
|
|
1851
|
+
reasoningEffort?: LlmReasoningEffort
|
|
1852
|
+
}
|
|
1853
|
+
|
|
1854
|
+
const REGISTRY_MODEL_IDS: ReadonlySet<string> = new Set(LLM_MODEL_IDS)
|
|
1855
|
+
|
|
1856
|
+
/**
|
|
1857
|
+
* The part of a price key after its `<feature>:` — `<modelId>`,
|
|
1858
|
+
* `<modelId>:direct` or `<modelId>:effort-<level>` — read back, or null for
|
|
1859
|
+
* anything that is not a key {@link llmPriceKey} could build: a model that is
|
|
1860
|
+
* not a registry id (never a borrowed slug), an effort on a model whose price
|
|
1861
|
+
* does not depend on it, a level it does not offer on the aggregator, any
|
|
1862
|
+
* other suffix. The one reader both the server and the editor use, so every
|
|
1863
|
+
* key names exactly one price.
|
|
1864
|
+
*/
|
|
1865
|
+
export function parseLlmPriceKeyModel(tail: string): LlmPriceKeyModel | null {
|
|
1866
|
+
if (REGISTRY_MODEL_IDS.has(tail)) return { modelId: tail }
|
|
1867
|
+
if (tail.endsWith(LLM_PRICE_KEY_DIRECT)) {
|
|
1868
|
+
const modelId = tail.slice(0, -LLM_PRICE_KEY_DIRECT.length)
|
|
1869
|
+
return REGISTRY_MODEL_IDS.has(modelId) ? { modelId, lane: "direct" } : null
|
|
1870
|
+
}
|
|
1871
|
+
const at = tail.lastIndexOf(LLM_PRICE_KEY_EFFORT)
|
|
1872
|
+
if (at <= 0) return null
|
|
1873
|
+
const modelId = tail.slice(0, at)
|
|
1874
|
+
const level = tail.slice(at + LLM_PRICE_KEY_EFFORT.length) as LlmReasoningEffort
|
|
1875
|
+
const model = REGISTRY_MODEL_IDS.has(modelId) ? getLlmModel(modelId) : undefined
|
|
1876
|
+
if (!model?.effortPriced || !availableReasoningEfforts(modelId).includes(level)) return null
|
|
1877
|
+
return { modelId, reasoningEffort: level }
|
|
1633
1878
|
}
|
|
1634
1879
|
|
|
1635
1880
|
/**
|