{"record":{"id":"85a9bebd92d81a52","repo":"calesthio/OpenMontage","slug":"pricing-is-unknown-for-a-custom-ark-endpoint-model","errorCode":null,"errorMessage":"pricing is unknown for a custom Ark Endpoint/Model; set custom_price_cny_per_million_tokens before a paid create","messagePattern":"pricing is unknown for a custom Ark Endpoint/Model; set custom_price_cny_per_million_tokens before a paid create","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"tools/video/seedance_ark.py","lineNumber":429,"sourceCode":"            rate = self.PRICE_CNY_PER_MILLION[variant][condition][resolution]\n        except KeyError:\n            # A custom Endpoint/Model may have different pricing.  Returning\n            # zero is safer than presenting a fabricated official estimate.\n            return 0.0\n        return round(self.estimate_token_usage(inputs) * rate / 1_000_000, 4)\n\n    def estimate_cost(self, inputs: dict[str, Any]) -> float:\n        cny_per_usd = self._get_cny_per_usd()\n        return round(self.estimate_cost_cny(inputs) / cny_per_usd, 4)\n\n    @staticmethod\n    def _get_custom_price(inputs: dict[str, Any], *, required: bool) -> float:\n        try:\n            raw = inputs[\"custom_price_cny_per_million_tokens\"]\n        except KeyError as exc:\n            if not required:\n                return 0.0\n            raise ValueError(\n                \"pricing is unknown for a custom Ark Endpoint/Model; \"\n                \"set custom_price_cny_per_million_tokens before a paid create\"\n            ) from exc\n        try:\n            value = float(raw)\n        except (TypeError, ValueError) as exc:\n            raise ValueError(\n                \"custom_price_cny_per_million_tokens must be a finite \"\n                \"number greater than 0\"\n            ) from exc\n        if not math.isfinite(value) or value <= 0:\n            raise ValueError(\n                \"custom_price_cny_per_million_tokens must be a finite \"\n                \"number greater than 0\"\n            )\n        return value\n\n    @staticmethod","sourceCodeStart":411,"sourceCodeEnd":447,"githubUrl":"https://github.com/calesthio/OpenMontage/blob/95e1c3d0ab93482159818560f6a8c8e866b9139f/tools/video/seedance_ark.py#L411-L447","documentation":"Raised by `_get_custom_price(inputs, required=True)`: the request targets a custom Ark Endpoint/Model (an endpoint ID or model outside the tool's built-in pricing table), and no `custom_price_cny_per_million_tokens` was supplied in inputs. Because a paid generation POST is about to happen, the tool refuses to create a task whose cost cannot be computed — this protects the cost-tracking/budget-governance contract, and per the code comment in `execute()`, all cost parsing happens BEFORE the paid POST so a pricing gap never leaves an untracked task behind.","triggerScenarios":"Calling seedance_ark with `model` or an Ark Endpoint ID not in the pricing table, `task_action` generate/create (dry_run/estimate paths pass `required=False`), and omitting `custom_price_cny_per_million_tokens`.","commonSituations":"Users switching from the known Seedance models to a newly released or fine-tuned endpoint; using a dedicated endpoint ID (ep-xxxx) for reserved capacity where per-token pricing is account-specific; dry-run succeeding (price not required there) followed by a real execute that fails.","solutions":["Look up the endpoint's price on the Volcengine Ark console (CNY per million tokens) and pass it: `custom_price_cny_per_million_tokens: <value>`","Or switch `model` back to a built-in Seedance variant whose pricing the tool knows","Confirm the value is per million tokens in CNY — a per-call or USD figure will silently mis-estimate cost"],"exampleFix":"# before\ninputs = {\"model\": \"ep-20240903144xxx\", \"prompt\": \"...\", \"task_action\": \"generate\"}\n# after\ninputs = {\n    \"model\": \"ep-20240903144xxx\",\n    \"prompt\": \"...\",\n    \"task_action\": \"generate\",\n    \"custom_price_cny_per_million_tokens\": 15.0,\n}","handlingStrategy":"validation","validationCode":"if using_custom_model(inputs) and \"custom_price_cny_per_million_tokens\" not in inputs:\n    raise ValueError(\n        \"custom endpoint detected: set custom_price_cny_per_million_tokens \"\n        \"(CNY per million tokens from the Ark console) before generate/create\"\n    )","typeGuard":null,"tryCatchPattern":"try:\n    result = ark.execute(inputs)\nexcept ValueError as e:\n    if \"custom_price_cny_per_million_tokens\" in str(e):\n        # fetch price from your billing config, add to inputs, retry once\n        inputs[\"custom_price_cny_per_million_tokens\"] = PRICES[inputs[\"model\"]]\n        result = ark.execute(inputs)\n    else:\n        raise","preventionTips":["Maintain a model→price table in your config for any custom endpoints you use","Call dry_run first — it validates and surfaces this gap without spending"],"tags":["seedance","ark","pricing","cost-tracking","input-validation"],"backgroundTag":null,"analyzedSha":"95e1c3d0ab93482159818560f6a8c8e866b9139f","analyzedAt":"2026-08-15T06:31:20.014Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}