{"record":{"id":"e0ce74019a6a9846","repo":"BerriAI/litellm","slug":"embedding-model-is-required-for-semantic-keyword-m","errorCode":null,"errorMessage":"embedding_model is required for semantic keyword matching","messagePattern":"embedding_model is required for semantic keyword matching","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/router_strategy/complexity_router/complexity_router.py","lineNumber":1467,"sourceCode":"        if not matches:\n            return None\n        return max(matches, key=lambda match: TIER_SEVERITY_ORDER.index(match.tier))\n\n    def _get_or_create_semantic_routelayer(self) -> SemanticRouter:\n        \"\"\"Build (once) a SemanticRouter with one route per tier, utterances = that tier's keywords.\"\"\"\n        if self._semantic_routelayer is not None:\n            return self._semantic_routelayer\n\n        from semantic_router.routers import SemanticRouter\n        from semantic_router.routers.base import Route\n\n        from litellm.router_strategy.auto_router.litellm_encoder import (\n            LiteLLMRouterEncoder,\n        )\n\n        embedding_model: Final = self.config.embedding_model\n        if embedding_model is None:\n            raise ValueError(\"embedding_model is required for semantic keyword matching\")\n\n        rules: Final = self.config.keyword_tier_rules or []\n        ordered_tiers: Final = tuple(dict.fromkeys(rule.tier.value for rule in rules))\n        routes: Final = [\n            Route(\n                name=tier,\n                utterances=[keyword for rule in rules if rule.tier.value == tier for keyword in rule.keywords],\n                score_threshold=self.config.match_threshold,\n            )\n            for tier in ordered_tiers\n        ]\n        routelayer: Final = SemanticRouter(\n            routes=routes,\n            encoder=LiteLLMRouterEncoder(\n                litellm_router_instance=self.litellm_router_instance,\n                model_name=embedding_model,\n                score_threshold=self.config.match_threshold,\n            ),","sourceCodeStart":1449,"sourceCodeEnd":1485,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/router_strategy/complexity_router/complexity_router.py#L1449-L1485","documentation":"Config guard in the complexity router: semantic keyword matching was requested, which routes utterances via embeddings, but no embedding_model is configured to build the SemanticRouter layer with.","triggerScenarios":"Thrown at litellm/router_strategy/complexity_router/complexity_router.py:1467 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set embedding_model in the config to enable semantic keyword matching."],"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"}