{"record":{"id":"d071850110625da6","repo":"BerriAI/litellm","slug":"model-is-required-in-dotprompt-metadata","errorCode":null,"errorMessage":"Model is required in dotprompt metadata","messagePattern":"Model is required in dotprompt metadata","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"litellm/proxy/prompts/prompt_endpoints.py","lineNumber":1235,"sourceCode":"        user_api_base,\n        user_max_tokens,\n        user_model,\n        user_request_timeout,\n        user_temperature,\n        version,\n    )\n\n    try:\n        # Parse the dotprompt content and create PromptTemplate\n        prompt_manager: Final = PromptManager()\n        frontmatter, template_content = prompt_manager._parse_frontmatter(content=request.dotprompt_content)\n\n        # Create PromptTemplate to leverage existing parameter extraction logic\n        template: Final = PromptTemplate(content=template_content, metadata=frontmatter, template_id=\"test_prompt\")\n\n        # Extract model from template\n        if not template.model:\n            raise HTTPException(status_code=400, detail=\"Model is required in dotprompt metadata\")\n\n        # Always render the template to extract system messages and other metadata\n        variables: Final = request.prompt_variables or {}\n        rendered_content: Final = prompt_manager.jinja_env.from_string(template_content).render(**variables)\n\n        # Convert rendered content to messages using DotpromptManager's method\n        dotprompt_manager: Final = DotpromptManager()\n        rendered_messages: Final = dotprompt_manager._convert_to_messages(rendered_content=rendered_content)\n\n        if not rendered_messages:\n            raise HTTPException(status_code=400, detail=\"No messages found in rendered prompt\")\n\n        # If conversation history is provided, use it but preserve system messages\n        if request.conversation_history:\n            # Extract system messages from rendered prompt\n            system_messages: Final = [msg for msg in rendered_messages if msg.get(\"role\") == \"system\"]\n            # Use conversation history for user/assistant messages\n            messages = system_messages + request.conversation_history","sourceCodeStart":1217,"sourceCodeEnd":1253,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/prompts/prompt_endpoints.py#L1217-L1253","documentation":"Dotprompt ingestion guard: after parsing the frontmatter of the supplied dotprompt content, the template metadata contains no 'model' field. The model is mandatory because the resulting prompt spec must be routable to a provider; the request is rejected with 400 before any rendering/storage.","triggerScenarios":"Thrown at litellm/proxy/prompts/prompt_endpoints.py:1235 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add a model field to the dotprompt frontmatter/metadata of the .prompt file."],"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-14T00:17:10.932Z"}