diff --git a/extensions/tencent/models.ts b/extensions/tencent/models.ts index 171ffe55bdb..ca5cc3fd964 100644 --- a/extensions/tencent/models.ts +++ b/extensions/tencent/models.ts @@ -1,57 +1,19 @@ +import { buildManifestModelProviderConfig } from "openclaw/plugin-sdk/provider-catalog-shared"; import type { ModelDefinitionConfig } from "openclaw/plugin-sdk/provider-model-shared"; +import manifest from "./openclaw.plugin.json" with { type: "json" }; // ---------- TokenHub provider ---------- -export const TOKENHUB_BASE_URL = "https://tokenhub.tencentmaas.com/v1"; export const TOKENHUB_PROVIDER_ID = "tencent-tokenhub"; -// Hy3 preview pricing ($ per 1M tokens), tiered by input context length. -// Flat rates mirror the first tier; tieredPricing drives actual cost calculation. -const HY3_PREVIEW_COST = { - input: 0.176, - output: 0.587, - cacheRead: 0.059, - cacheWrite: 0, - tieredPricing: [ - { - input: 0.176, - output: 0.587, - cacheRead: 0.059, - cacheWrite: 0, - range: [0, 16_000] as [number, number], - }, - { - input: 0.235, - output: 0.939, - cacheRead: 0.088, - cacheWrite: 0, - range: [16_000, 32_000] as [number, number], - }, - { - input: 0.293, - output: 1.173, - cacheRead: 0.117, - cacheWrite: 0, - range: [32_000] as [number], - }, - ], -}; +const TOKENHUB_MANIFEST_PROVIDER = buildManifestModelProviderConfig({ + providerId: TOKENHUB_PROVIDER_ID, + catalog: manifest.modelCatalog.providers[TOKENHUB_PROVIDER_ID], +}); -export const TOKENHUB_MODEL_CATALOG: ModelDefinitionConfig[] = [ - { - id: "hy3-preview", - name: "Hy3 preview (TokenHub)", - reasoning: true, - input: ["text"], - contextWindow: 256_000, - maxTokens: 64_000, - cost: HY3_PREVIEW_COST, - compat: { - supportsUsageInStreaming: true, - supportsReasoningEffort: true, - }, - }, -]; +export const TOKENHUB_BASE_URL = TOKENHUB_MANIFEST_PROVIDER.baseUrl; + +export const TOKENHUB_MODEL_CATALOG: ModelDefinitionConfig[] = TOKENHUB_MANIFEST_PROVIDER.models; export function buildTokenHubModelDefinition( model: (typeof TOKENHUB_MODEL_CATALOG)[number], diff --git a/extensions/tencent/openclaw.plugin.json b/extensions/tencent/openclaw.plugin.json index 820de8cf240..8affed248b4 100644 --- a/extensions/tencent/openclaw.plugin.json +++ b/extensions/tencent/openclaw.plugin.json @@ -6,6 +6,60 @@ "enabledByDefault": true, "providerDiscoveryEntry": "./provider-discovery.ts", "providers": ["tencent-tokenhub"], + "modelCatalog": { + "providers": { + "tencent-tokenhub": { + "baseUrl": "https://tokenhub.tencentmaas.com/v1", + "api": "openai-completions", + "models": [ + { + "id": "hy3-preview", + "name": "Hy3 preview (TokenHub)", + "reasoning": true, + "input": ["text"], + "contextWindow": 256000, + "maxTokens": 64000, + "cost": { + "input": 0.176, + "output": 0.587, + "cacheRead": 0.059, + "cacheWrite": 0, + "tieredPricing": [ + { + "input": 0.176, + "output": 0.587, + "cacheRead": 0.059, + "cacheWrite": 0, + "range": [0, 16000] + }, + { + "input": 0.235, + "output": 0.939, + "cacheRead": 0.088, + "cacheWrite": 0, + "range": [16000, 32000] + }, + { + "input": 0.293, + "output": 1.173, + "cacheRead": 0.117, + "cacheWrite": 0, + "range": [32000] + } + ] + }, + "compat": { + "supportsUsageInStreaming": true, + "supportsReasoningEffort": true + } + } + ] + } + }, + "discovery": { + "tencent-tokenhub": "static" + } + }, "providerAuthEnvVars": { "tencent-tokenhub": ["TOKENHUB_API_KEY"] },