{"record":{"id":"e535293573ae6d88","repo":"BerriAI/litellm","slug":"cost-for-tts-call-is-none-prompt-cost-prompt-co","errorCode":null,"errorMessage":"cost for tts call is None. prompt_cost={_prompt_cost}, completion_cost={_completion_cost}, model={model_without_prefix}, custom_llm_provider={custom_llm_provider}, prompt_characters={prompt_characters}, completion_characters={completion_characters}","messagePattern":"cost for tts call is None\\. prompt_cost=(.+?), completion_cost=(.+?), model=(.+?), custom_llm_provider=(.+?), prompt_characters=(.+?), completion_characters=(.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/cost_calculator.py","lineNumber":507,"sourceCode":"        speech_model_info = litellm.get_model_info(model=model_without_prefix, custom_llm_provider=custom_llm_provider)\n        cost_metric: Final = select_cost_metric_for_model(speech_model_info)\n        prompt_cost: float = 0.0\n        completion_cost: float = 0.0\n        if cost_metric == \"cost_per_character\":\n            if prompt_characters is None:\n                raise ValueError(\n                    f\"prompt_characters must be provided for tts calls. prompt_characters={prompt_characters}, model={model}, custom_llm_provider={custom_llm_provider}, call_type={call_type}\"\n                )\n            _prompt_cost, _completion_cost = _generic_cost_per_character(\n                model=model_without_prefix,\n                custom_llm_provider=custom_llm_provider,\n                prompt_characters=prompt_characters,\n                completion_characters=0,\n                custom_prompt_cost=None,\n                custom_completion_cost=0,\n            )\n            if _prompt_cost is None or _completion_cost is None:\n                raise ValueError(\n                    f\"cost for tts call is None. prompt_cost={_prompt_cost}, completion_cost={_completion_cost}, model={model_without_prefix}, custom_llm_provider={custom_llm_provider}, prompt_characters={prompt_characters}, completion_characters={completion_characters}\"\n                )\n            prompt_cost = _prompt_cost\n            completion_cost = _completion_cost\n        elif cost_metric == \"cost_per_token\":\n            prompt_cost, completion_cost = generic_cost_per_token(\n                model=model_without_prefix,\n                usage=usage_block,\n                custom_llm_provider=custom_llm_provider,\n                service_tier=service_tier,\n                data_residency=data_residency,\n            )\n\n        return prompt_cost, completion_cost\n    elif call_type == \"arerank\" or call_type == \"rerank\":\n        return rerank_cost(\n            model=model,\n            custom_llm_provider=custom_llm_provider,","sourceCodeStart":489,"sourceCodeEnd":525,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/cost_calculator.py#L489-L525","documentation":"After a per-character TTS cost lookup succeeds, _generic_cost_per_character must return numeric prompt/completion costs. If either comes back None (model missing per-character pricing in the cost map despite the metric selection, or a custom-cost path returning None), the calculator refuses to emit a None cost and raises ValueError with full context.","triggerScenarios":"A speech model whose model_info selects cost_per_character but whose cost map entry lacks input_cost_per_character / custom prices; a LiteLLM version whose model_prices file omits the TTS model's character pricing; custom_cost set to None paths.","commonSituations":"Brand-new or regional TTS models not yet in the bundled model_prices_and_context_window.json; stale pricing data after upgrades; forked cost maps that dropped pricing keys.","solutions":["Update LiteLLM to pick up current pricing data (pip install -U litellm).","Register pricing for the model with litellm.register_model({model: {'input_cost_per_character': ...}}).","Verify the model entry has character pricing keys via litellm.get_model_info(model).","If pricing genuinely is unknown, compute cost yourself from provider billing instead of relying on completion_cost."],"exampleFix":"# before\ncost = litellm.completion_cost(model=\"tts-1-hd\", call_type=\"speech\",\n                             prompt=\"hi\", prompt_characters=2)  # ValueError: cost is None\n\n# after\nlitellm.register_model({\n    \"tts-1-hd\": {\"input_cost_per_character\": 0.000015},\n})\ncost = litellm.completion_cost(model=\"tts-1-hd\", call_type=\"speech\",\n                             prompt=\"hi\", prompt_characters=2)","handlingStrategy":"fallback","validationCode":"info = litellm.get_model_info(model=model) or {}\nif not info.get(\"input_cost_per_character\"):\n    raise MissingPricing(model)  # register pricing before calling","typeGuard":"def has_character_pricing(model: str) -> bool:\n    try:\n        info = litellm.get_model_info(model=model) or {}\n    except Exception:\n        return False\n    return info.get(\"input_cost_per_character\") is not None","tryCatchPattern":"try:\n    cost = litellm.completion_cost(...)\nexcept ValueError as e:\n    if \"cost for tts call is None\" in str(e):\n        litellm.register_model({model: {\"input_cost_per_character\": fallback_price}})\n        cost = litellm.completion_cost(...)\n    else:\n        raise","preventionTips":["Pin a recent LiteLLM version so bundled pricing data is current.","Register explicit pricing for every TTS model you bill at startup.","Monitor cost logs for zero/None costs after version upgrades."],"tags":["litellm","cost-calculation","tts","pricing-data"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}