{"record":{"id":"389aab10139690dd","repo":"microsoft/semantic-kernel","slug":"ollama-embedding-model-id-is-not-set","errorCode":null,"errorMessage":"Ollama embedding model ID is not set.","messagePattern":"Ollama embedding model ID is not set\\.","errorType":"exception","errorClass":"ServiceInitializationError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/ai/ollama/services/ollama_text_embedding.py","lineNumber":69,"sourceCode":"            ai_model_id (Optional[str]): The model name. (Optional)\n            host (Optional[str]): URL of the Ollama server, defaults to None and\n                will use the default Ollama service address: http://127.0.0.1:11434. (Optional)\n            client (Optional[AsyncClient]): A custom Ollama client to use for the service. (Optional)\n            env_file_path (str | None): Use the environment settings file as a fallback to using env vars.\n            env_file_encoding (str | None): The encoding of the environment settings file, defaults to 'utf-8'.\n        \"\"\"\n        try:\n            ollama_settings = OllamaSettings(\n                embedding_model_id=ai_model_id,\n                host=host,\n                env_file_path=env_file_path,\n                env_file_encoding=env_file_encoding,\n            )\n        except ValidationError as ex:\n            raise ServiceInitializationError(\"Failed to create Ollama settings.\", ex) from ex\n\n        if not ollama_settings.embedding_model_id:\n            raise ServiceInitializationError(\"Ollama embedding model ID is not set.\")\n\n        super().__init__(\n            service_id=service_id or ollama_settings.embedding_model_id,\n            ai_model_id=ollama_settings.embedding_model_id,\n            client=client or AsyncClient(host=ollama_settings.host),\n        )\n\n    @override\n    async def generate_embeddings(\n        self,\n        texts: list[str],\n        settings: \"PromptExecutionSettings | None\" = None,\n        **kwargs: Any,\n    ) -> ndarray:\n        raw_embeddings = await self.generate_raw_embeddings(texts, settings, **kwargs)\n        return array(raw_embeddings)\n\n    @override","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/ai/ollama/services/ollama_text_embedding.py#L51-L87","documentation":"Thrown by the OllamaTextEmbedding constructor when the resolved embedding_model_id is empty or None after merging the ai_model_id argument with the OLLAMA_EMBEDDING_MODEL_ID environment variable. Without a model identifier the service cannot call the Ollama /api/embeddings endpoint, so it aborts. Raised as ServiceInitializationError before any network call.","triggerScenarios":"Constructing OllamaTextEmbedding() with ai_model_id omitted while OLLAMA_EMBEDDING_MODEL_ID is not set in the environment or .env file. Also triggered by passing ai_model_id=None explicitly.","commonSituations":"New project with no .env configured; using a shared OLLAMA_HOST but forgetting the model-id env var; env var name typo (OLLAMA_EMBEDDING_MODEL instead of OLLAMA_EMBEDDING_MODEL_ID); pulling a text model but not an embedding model (ollama pull nomic-embed-text).","solutions":["Pass the model name directly: OllamaTextEmbedding(ai_model_id='nomic-embed-text')","Set the env var: export OLLAMA_EMBEDDING_MODEL_ID=nomic-embed-text","Add OLLAMA_EMBEDDING_MODEL_ID to your .env and pass env_file_path","Ensure the embedding model is pulled: ollama pull nomic-embed-text"],"exampleFix":"// before\nembedder = OllamaTextEmbedding()\n// after\nembedder = OllamaTextEmbedding(ai_model_id='nomic-embed-text')","handlingStrategy":"validation","validationCode":"import os\n\nmodel_id = 'nomic-embed-text'\nif not model_id and not os.environ.get('OLLAMA_EMBEDDING_MODEL_ID'):\n    raise RuntimeError('OLLAMA_EMBEDDING_MODEL_ID is not set and no ai_model_id provided')\n\nfrom semantic_kernel.connectors.ai.ollama import OllamaTextEmbedding\nembedder = OllamaTextEmbedding(ai_model_id=model_id)","typeGuard":null,"tryCatchPattern":"from semantic_kernel.exceptions.service_exceptions import ServiceInitializationError\n\ntry:\n    embedder = OllamaTextEmbedding()\nexcept ServiceInitializationError as e:\n    if 'embedding model ID' in str(e):\n        embedder = OllamaTextEmbedding(ai_model_id=os.environ['FALLBACK_EMBEDDING_MODEL'])\n    else:\n        raise","preventionTips":["Set OLLAMA_EMBEDDING_MODEL_ID in your .env from the start","Pull the embedding model before first use: ollama pull nomic-embed-text","Validate required embedding config at application startup"],"tags":["ollama","configuration","model-id","embeddings","initialization"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}