{"record":{"id":"49f507c9404e11ea","repo":"BerriAI/litellm","slug":"prompt-characters-must-be-provided-for-tts-calls","errorCode":null,"errorMessage":"prompt_characters must be provided for tts calls. prompt_characters={prompt_characters}, model={model}, custom_llm_provider={custom_llm_provider}, call_type={call_type}","messagePattern":"prompt_characters must be provided for tts calls\\. prompt_characters=(.+?), model=(.+?), custom_llm_provider=(.+?), call_type=(.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/cost_calculator.py","lineNumber":495,"sourceCode":"    \"\"\"\n    if model_with_provider in model_cost_ref:  # Option 2. use model with provider, model = \"openai/gpt-4\"\n        model = model_with_provider\n    elif model in model_cost_ref:  # Option 1. use model passed, model=\"gpt-4\"\n        model = model\n    elif (\n        model_without_prefix in model_cost_ref\n    ):  # Option 3. if user passed model=\"bedrock/anthropic.claude-3\", use model=\"anthropic.claude-3\"\n        model = model_without_prefix\n\n    # see this https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models\n    if call_type == \"speech\" or call_type == \"aspeech\":\n        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(","sourceCodeStart":477,"sourceCodeEnd":513,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/cost_calculator.py#L477-L513","documentation":"Error \"prompt_characters must be provided for tts calls. prompt_characters={prompt_characters}, model={model}, custom_llm_provider={custom_llm_provider}, call_type={call_type}\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/cost_calculator.py:495 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Provide prompt_characters for TTS cost calculation so the per-character cost can be computed.","Pass the input text length of the speech request as prompt_characters."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}