Skip to content

armgit / mem0

Public Imported from GitHub
0

The Memory Layer for AI Agents - Drop-in memory infrastructure for AI agents and apps. Context that persists. Built for production.

feat: support openai compatible llm provider by adding baseUrl to config (#2674)

Frank Zhao9622ac7dff3d
diff --git a/docs/changelog.mdx b/docs/changelog.mdx
index 6f21e8cb6..cc6ab63a0 100644
--- a/docs/changelog.mdx
+++ b/docs/changelog.mdx
@@ -288,6 +288,11 @@ mode: "wide"
<Tab title="TypeScript">
+<Update label="2025-05-27" description="v2.1.27">
+**Improvements:**
+- **OSS:** Added baseURL param in LLM Config.
+</Update>
+
<Update label="2025-05-23" description="v2.1.26">
**Improvements:**
- **Client:** Removed type `string` from `messages` interface
diff --git a/mem0-ts/package.json b/mem0-ts/package.json
index 6c629a9d0..7c53677c1 100644
--- a/mem0-ts/package.json
+++ b/mem0-ts/package.json
@@ -1,6 +1,6 @@
{
"name": "mem0ai",
- "version": "2.1.26",
+ "version": "2.1.27",
"description": "The Memory Layer For Your AI Apps",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
diff --git a/mem0-ts/src/oss/src/config/defaults.ts b/mem0-ts/src/oss/src/config/defaults.ts
index b2c9d19fc..ae2a514be 100644
--- a/mem0-ts/src/oss/src/config/defaults.ts
+++ b/mem0-ts/src/oss/src/config/defaults.ts
@@ -20,6 +20,7 @@ export const DEFAULT_MEMORY_CONFIG: MemoryConfig = {
llm: {
provider: "openai",
config: {
+ baseURL: "https://api.openai.com/v1",
apiKey: process.env.OPENAI_API_KEY || "",
model: "gpt-4-turbo-preview",
modelProperties: undefined,
diff --git a/mem0-ts/src/oss/src/config/manager.ts b/mem0-ts/src/oss/src/config/manager.ts
index 9371b7052..01996e0f8 100644
--- a/mem0-ts/src/oss/src/config/manager.ts
+++ b/mem0-ts/src/oss/src/config/manager.ts
@@ -78,8 +78,9 @@ export class ConfigManager {
} else if (userConf?.model && typeof userConf.model === "string") {
finalModel = userConf.model;
}
-
+
return {
+ baseURL: userConf?.baseURL || defaultConf.baseURL,
apiKey:
userConf?.apiKey !== undefined
? userConf.apiKey
diff --git a/mem0-ts/src/oss/src/llms/openai.ts b/mem0-ts/src/oss/src/llms/openai.ts
index d1e148f56..2d448fb30 100644
--- a/mem0-ts/src/oss/src/llms/openai.ts
+++ b/mem0-ts/src/oss/src/llms/openai.ts
@@ -7,7 +7,7 @@ export class OpenAILLM implements LLM {
private model: string;
constructor(config: LLMConfig) {
- this.openai = new OpenAI({ apiKey: config.apiKey });
+ this.openai = new OpenAI({ apiKey: config.apiKey, baseURL: config.baseURL });
this.model = config.model || "gpt-4o-mini";
}
diff --git a/mem0-ts/src/oss/src/types/index.ts b/mem0-ts/src/oss/src/types/index.ts
index aa2d5d739..b2bdc0a82 100644
--- a/mem0-ts/src/oss/src/types/index.ts
+++ b/mem0-ts/src/oss/src/types/index.ts
@@ -39,6 +39,7 @@ export interface HistoryStoreConfig {
export interface LLMConfig {
provider?: string;
+ baseURL?: string;
config?: Record<string, any>;
apiKey?: string;
model?: string | any;