{"record":{"id":"192af8a2bb9df20b","repo":"rohitg00/ai-engineering-from-scratch","slug":"llm-model-override-r-is-not-in-the-pricing-regis","errorCode":null,"errorMessage":"LLM_MODEL={override!r} is not in the pricing registry (known: {known})","messagePattern":"LLM_MODEL=(.+?) is not in the pricing registry \\(known: (.+?)\\)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"phases/11-llm-engineering/13-production-app/code/production_app.py","lineNumber":31,"sourceCode":"from enum import Enum\nfrom typing import AsyncGenerator\n\n\nclass ModelName(Enum):\n    CLAUDE_SONNET = \"claude-sonnet-5\"\n    GPT_4O = \"gpt-4o\"\n    GPT_4O_MINI = \"gpt-4o-mini\"\n\n\ndef resolve_primary_model() -> ModelName:\n    override = (os.environ.get(\"LLM_MODEL\") or \"\").strip()\n    if not override:\n        return ModelName.CLAUDE_SONNET\n    for model in ModelName:\n        if model.value == override:\n            return model\n    known = \", \".join(m.value for m in ModelName)\n    raise ValueError(f\"LLM_MODEL={override!r} is not in the pricing registry (known: {known})\")\n\n\nPRIMARY_MODEL = resolve_primary_model()\n\n\nMODEL_PRICING = {\n    ModelName.CLAUDE_SONNET: {\"input\": 3.00, \"output\": 15.00},\n    ModelName.GPT_4O: {\"input\": 2.50, \"output\": 10.00},\n    ModelName.GPT_4O_MINI: {\"input\": 0.15, \"output\": 0.60},\n}\n\nFALLBACK_CHAIN = [PRIMARY_MODEL] + [m for m in ModelName if m is not PRIMARY_MODEL]\n\n\n@dataclass\nclass RequestLog:\n    request_id: str\n    user_id: str","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/rohitg00/ai-engineering-from-scratch/blob/39ea8a1c6d0b61f071226eff7ede4d4105fed820/phases/11-llm-engineering/13-production-app/code/production_app.py#L13-L49","documentation":"Module-import-time guard in resolve_primary_model: the LLM_MODEL env var was set and non-empty, but its value matches no ModelName enum entry, so no pricing row exists for it. The raise fires at import (while binding PRIMARY_MODEL), before any request is served.","triggerScenarios":"Thrown at phases/11-llm-engineering/13-production-app/code/production_app.py:31 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Unset LLM_MODEL to fall back to the default claude-sonnet-5","Set LLM_MODEL to a known enum value: claude-sonnet-5, gpt-4o, or gpt-4o-mini","Add the model to the ModelName enum and its pricing entry before selecting it"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"39ea8a1c6d0b61f071226eff7ede4d4105fed820","analyzedAt":"2026-08-26T03:13:46.626Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}