{"record":{"id":"34ee7b9074d05b9f","repo":"MemPalace/mempalace","slug":"embedding-model-openai-compat-requires-an-endpoi","errorCode":null,"errorMessage":"embedding_model='openai-compat' requires an endpoint — set embedding_api_url in ~/.mempalace/config.json or the MEMPALACE_EMBEDDING_API_URL env var (e.g. http://host:port)","messagePattern":"embedding_model='openai-compat' requires an endpoint — set embedding_api_url in ~/\\.mempalace/config\\.json or the MEMPALACE_EMBEDDING_API_URL env var \\(e\\.g\\. http://host:port\\)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mempalace/embedding.py","lineNumber":649,"sourceCode":"    \"\"\"\n    if device is None or model is None:\n        from .config import MempalaceConfig\n\n        cfg = MempalaceConfig()\n        if device is None:\n            device = cfg.embedding_device\n        if model is None:\n            model = cfg.embedding_model\n\n    # OpenAI-compatible embedding API: bypasses local ONNX entirely. Checked\n    # before device→provider resolution since it needs no hardware accelerator.\n    if model == \"openai-compat\":\n        from .config import MempalaceConfig\n\n        cfg = MempalaceConfig()\n        url = cfg.embedding_api_url\n        if not url:\n            raise ValueError(\n                \"embedding_model='openai-compat' requires an endpoint — set \"\n                \"embedding_api_url in ~/.mempalace/config.json or the \"\n                \"MEMPALACE_EMBEDDING_API_URL env var (e.g. http://host:port)\"\n            )\n        api_model = cfg.embedding_api_model\n        if not api_model:\n            raise ValueError(\n                \"embedding_model='openai-compat' requires a model — set \"\n                \"embedding_api_model in ~/.mempalace/config.json or the \"\n                \"MEMPALACE_EMBEDDING_API_MODEL env var\"\n            )\n        api_key = cfg.embedding_api_key\n        # Include a fingerprint of the key (never the raw secret) so a token\n        # rotation busts the cache in long-lived processes (e.g. MCP server).\n        key_fp = hashlib.sha256((api_key or \"\").encode(\"utf-8\")).hexdigest()[:16]\n        cache_key = (\"openai-compat\", url, api_model, key_fp)\n        cached = _EF_CACHE.get(cache_key)\n        if cached is not None:","sourceCodeStart":631,"sourceCodeEnd":667,"githubUrl":"https://github.com/MemPalace/mempalace/blob/06cb6987f02610784fefbad4b2bd5d026d164ba6/mempalace/embedding.py#L631-L667","documentation":"Raised by get_embedding_function when embedding_model is 'openai-compat' but no endpoint URL is configured. The openai-compat backend bypasses local ONNX entirely and needs a base URL; it reads MempalaceConfig.embedding_api_url (backed by MEMPALACE_EMBEDDING_API_URL env var or ~/.mempalace/config.json) and refuses to guess a default like localhost, since silently hitting the wrong server would embed everything against a mismatched model and poison the store.","triggerScenarios":"Setting MEMPALACE_EMBEDDING_MODEL=openai-compat (or embedding_model='openai-compat' in config.json) without also setting MEMPALACE_EMBEDDING_API_URL or embedding_api_url. Typically after switching from the default local ONNX backend to a server-based one and forgetting the second required key.","commonSituations":"Migrating to LM Studio/vLLM/Ollama embeddings and setting only the model key; assuming a default localhost URL exists; config.json edited by hand with a typo'd key (embedding_api instead of embedding_api_url); env var set in one shell but the process (MCP server) launched from another.","solutions":["Set the URL: export MEMPALACE_EMBEDDING_API_URL=http://127.0.0.1:1234 or add \"embedding_api_url\": \"http://127.0.0.1:1234\" to ~/.mempalace/config.json","Also set the model (MEMPALACE_EMBEDDING_API_MODEL) — it is the next required key and will raise immediately after this one if missing","Restart the MCP server / long-lived process after changing env vars so it picks up the new value","Verify with: python -c \"from mempalace.config import MempalaceConfig; print(MempalaceConfig().embedding_api_url)\""],"exampleFix":"# ~/.mempalace/config.json — before\n{\"embedding_model\": \"openai-compat\"}\n# after\n{\n  \"embedding_model\": \"openai-compat\",\n  \"embedding_api_url\": \"http://127.0.0.1:1234\",\n  \"embedding_api_model\": \"text-embedding-nomic-embed-text-v1.5\"\n}","handlingStrategy":"validation","validationCode":"from mempalace.config import MempalaceConfig\n\ncfg = MempalaceConfig()\nassert cfg.embedding_model != \"openai-compat\" or cfg.embedding_api_url, (\n    \"openai-compat requires MEMPALACE_EMBEDDING_API_URL / embedding_api_url\"\n)","typeGuard":null,"tryCatchPattern":"try:\n    ef = get_embedding_function()\nexcept ValueError as e:\n    if \"requires an endpoint\" in str(e):\n        sys.exit(\"Set MEMPALACE_EMBEDDING_API_URL=http://host:port and retry\")","preventionTips":["Treat openai-compat as a triple: model + api_url + api_model — configure all three at once","Put config in ~/.mempalace/config.json rather than shell env vars for long-lived MCP servers","Print the effective config at pipeline startup to catch missing keys early"],"tags":["config","embedding","openai-compat","setup"],"backgroundTag":null,"analyzedSha":"06cb6987f02610784fefbad4b2bd5d026d164ba6","analyzedAt":"2026-08-15T03:03:36.213Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}