Bug Report: OpenAIEmbedder ignores baseURL config
Summary
The OpenAIEmbedder class in mem0 TypeScript SDK does not use the baseURL configuration parameter when initializing the OpenAI client, forcing users to manually set process.env.OPENAI_BASE_URL as a workaround.
Steps to Reproduce
-
Configure mem0 with a custom OpenAI-compatible API endpoint (e.g., NVIDIA API, local Ollama):
const memory = new Memory({
embedder: {
provider: "openai",
config: {
apiKey: "sk-xxx",
baseURL: "https://integrate.api.nvidia.com/v1",
model: "nvidia/llama-3.1-nv-embedqa-1b-v1"
}
}
});
-
Initialize the memory instance
-
Attempt to add or search memories
-
Error occurs because the OpenAI client connects to default OpenAI URL instead of the custom baseURL
Expected Behavior
The OpenAIEmbedder should respect the baseURL configuration parameter, similar to how OpenAILLM does.
Actual Behavior
The OpenAIEmbedder constructor only passes apiKey to the OpenAI client, ignoring baseURL:
var OpenAIEmbedder = class {
constructor(config) {
this.openai = new import_openai.default({ apiKey: config.apiKey }); // ❌ baseURL is ignored
// ...
}
}
Workaround
Users are forced to set environment variables manually before initializing mem0:
process.env.OPENAI_BASE_URL = customBaseURL;
process.env.OPENAI_API_BASE = customBaseURL;
const memory = new Memory({ /* config */ });
Comparison with OpenAILLM
The OpenAILLM class correctly implements baseURL support:
var OpenAILLM = class {
constructor(config) {
this.openai = new import_openai2.default({
apiKey: config.apiKey,
baseURL: config.baseURL // ✅ Correctly uses baseURL
});
// ...
}
}
Environment
- mem0ai version: 2.2.4
- Node.js version: 20.x
- OS: Linux
Proposed Fix
Update the OpenAIEmbedder class in src/oss/src/embeddings/openai.ts:
var OpenAIEmbedder = class {
constructor(config) {
this.openai = new import_openai.default({
apiKey: config.apiKey,
baseURL: config.baseURL // ✅ Add this line
});
this.model = config.model || "text-embedding-3-small";
this.embeddingDims = config.embeddingDims || 1536;
}
// ...
}
Impact
This affects all users who:
- Use custom OpenAI-compatible API endpoints (NVIDIA, local models, etc.)
- Cannot or prefer not to set global environment variables
- Want to keep configuration clean and explicit
Additional Notes
- The same issue may exist in
AzureOpenAIEmbedder class
- Users should not need to rely on environment variable hacks for a standard configuration parameter
- This inconsistency between
OpenAILLM and OpenAIEmbedder is confusing and error-prone
Bug Report: OpenAIEmbedder ignores baseURL config
Summary
The
OpenAIEmbedderclass in mem0 TypeScript SDK does not use thebaseURLconfiguration parameter when initializing the OpenAI client, forcing users to manually setprocess.env.OPENAI_BASE_URLas a workaround.Steps to Reproduce
Configure mem0 with a custom OpenAI-compatible API endpoint (e.g., NVIDIA API, local Ollama):
Initialize the memory instance
Attempt to add or search memories
Error occurs because the OpenAI client connects to default OpenAI URL instead of the custom baseURL
Expected Behavior
The
OpenAIEmbeddershould respect thebaseURLconfiguration parameter, similar to howOpenAILLMdoes.Actual Behavior
The
OpenAIEmbedderconstructor only passesapiKeyto the OpenAI client, ignoringbaseURL:Workaround
Users are forced to set environment variables manually before initializing mem0:
Comparison with OpenAILLM
The
OpenAILLMclass correctly implementsbaseURLsupport:Environment
Proposed Fix
Update the
OpenAIEmbedderclass insrc/oss/src/embeddings/openai.ts:Impact
This affects all users who:
Additional Notes
AzureOpenAIEmbedderclassOpenAILLMandOpenAIEmbedderis confusing and error-prone