{"record":{"id":"224e025b5515c76f","repo":"mem0ai/mem0","slug":"huggingface-embedder-requires-an-inference-endpoin","errorCode":null,"errorMessage":"HuggingFace embedder requires an inference endpoint. Set `huggingfaceBaseUrl` (or `baseURL`) in the embedder config, or the HUGGINGFACE_BASE_URL environment variable (e.g. a TEI server at http://localhost:8080/v1).","messagePattern":"HuggingFace embedder requires an inference endpoint\\. Set `huggingfaceBaseUrl` \\(or `baseURL`\\) in the embedder config, or the HUGGINGFACE_BASE_URL environment variable \\(e\\.g\\. a TEI server at http://localhost:8080/v1\\)\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"mem0-ts/src/oss/src/embeddings/huggingface.ts","lineNumber":30,"sourceCode":" * `openai` client pointed at that base URL. No new dependency is required.\n *\n * A base URL is required. The Python provider's alternative local\n * `sentence-transformers` path has no lightweight TypeScript equivalent, so\n * hosted inference is the supported TS mode.\n */\nexport class HuggingFaceEmbedder implements Embedder {\n  private openai: OpenAI;\n  private model: string;\n\n  constructor(config: EmbeddingConfig) {\n    const baseURL =\n      config.huggingfaceBaseUrl ||\n      config.baseURL ||\n      config.url ||\n      process.env.HUGGINGFACE_BASE_URL;\n\n    if (!baseURL) {\n      throw new Error(\n        \"HuggingFace embedder requires an inference endpoint. Set \" +\n          \"`huggingfaceBaseUrl` (or `baseURL`) in the embedder config, or the \" +\n          \"HUGGINGFACE_BASE_URL environment variable (e.g. a TEI server at \" +\n          \"http://localhost:8080/v1).\",\n      );\n    }\n\n    this.openai = new OpenAI({\n      apiKey: config.apiKey || process.env.HUGGINGFACE_API_KEY || \"hf\",\n      baseURL,\n    });\n    // TEI ignores the model field; default mirrors the Python provider.\n    this.model = config.model || \"tei\";\n  }\n\n  async embed(text: string): Promise<number[]> {\n    const response = await this.openai.embeddings.create({\n      model: this.model,","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0-ts/src/oss/src/embeddings/huggingface.ts#L12-L48","documentation":"Thrown by the HuggingFaceEmbedder constructor when no inference endpoint can be resolved. Unlike other providers, this embedder does not call the HF Hub API — it speaks the OpenAI-compatible protocol to a self-hosted Text-Embeddings-Inference (TEI) server, so a base URL is mandatory. Resolution order: config.huggingfaceBaseUrl, config.baseURL, config.url, then process.env.HUGGINGFACE_BASE_URL. All four unset -> this error.","triggerScenarios":"EmbeddingConfig with only apiKey and model (copied from the OpenAI provider); HUGGINGFACE_BASE_URL set in the local shell but not in the deployed environment; base URL placed under modelProperties where this embedder does not read it.","commonSituations":"Running TEI in Docker (http://localhost:8080) locally but forgetting to configure the URL in Kubernetes/Vercel; assuming the provider calls hf.co inference endpoints (it targets TEI servers); env var named differently (HF_API_BASE vs HUGGINGFACE_BASE_URL).","solutions":["Set the URL in config: embedder: { provider: 'huggingface', config: { huggingfaceBaseUrl: 'http://localhost:8080/v1', apiKey: 'hf' } }","Or export HUGGINGFACE_BASE_URL=http://localhost:8080/v1 in the runtime environment","Verify the TEI server is up: curl $HUGGINGFACE_BASE_URL/models — it must expose the OpenAI-compatible /embeddings route"],"exampleFix":"// before\nembedder: { provider: 'huggingface', config: { apiKey: 'hf_xxx', model: 'tei' } }\n\n// after\nembedder: {\n  provider: 'huggingface',\n  config: { huggingfaceBaseUrl: 'http://localhost:8080/v1', apiKey: 'hf_xxx' },\n}","handlingStrategy":"validation","validationCode":"const HF_BASE = process.env.HUGGINGFACE_BASE_URL ?? 'http://localhost:8080/v1';\nif (!HF_BASE) throw new Error('TEI base URL required for huggingface embedder');\nembedder: { provider: 'huggingface', config: { huggingfaceBaseUrl: HF_BASE } }","typeGuard":"const isTeiBaseUrl = (u: unknown): u is string =>\n  typeof u === 'string' && /^https?:\\/\\//.test(u);","tryCatchPattern":null,"preventionTips":["Always set huggingfaceBaseUrl explicitly in config; do not depend on ambient env vars in deployed environments","Remember this provider targets a self-hosted TEI server, not the HF Hub — provision the server first","Add a startup curl/health check against $BASE/models to confirm the server is reachable before building Memory"],"tags":["huggingface","tei","embeddings","validation","config","self-hosted"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}