Feature Request: Support custom OpenAI base URL
Description
Currently, open-mem only supports the official OpenAI API endpoint (https://api.openai.com/v1). This prevents users from using compatible third-party services like SiliconFlow (硅基流动), DeepSeek, or self-hosted OpenAI-compatible APIs.
Current Behavior
The ModelConfig interface only accepts apiKey, and the OpenAI provider is initialized without a baseURL parameter:
https://github.com/clopca/open-mem/blob/main/src/ai/provider.ts#L64-L69
case "openai": {
const { createOpenAI } = require("@ai-sdk/openai");
const openai = createOpenAI({ apiKey: config.apiKey }); // No baseURL option
return openai(config.model);
}
Expected Behavior
Allow users to specify a custom base URL for OpenAI-compatible providers via:
- Environment variable:
OPENAI_BASE_URL
- Configuration option in config file
Use Cases
- SiliconFlow (硅基流动):
https://api.siliconflow.cn/v1
- DeepSeek:
https://api.deepseek.com/v1
- Self-hosted models: Custom local endpoints
- Other OpenAI-compatible services: OpenRouter, Azure OpenAI, etc.
Proposed Solution
1. Update ModelConfig interface (provider.ts)
export interface ModelConfig {
provider: ProviderType;
model: string;
apiKey?: string;
baseURL?: string; // Add this
}
2. Pass baseURL to createOpenAI (provider.ts)
case "openai": {
const { createOpenAI } = require("@ai-sdk/openai");
const openai = createOpenAI({
apiKey: config.apiKey,
baseURL: config.baseURL // Add this
});
return openai(config.model);
}
3. Read from environment (config.ts)
Add OPENAI_BASE_URL environment variable support alongside existing OPENAI_API_KEY.
Alternative Considered
If adding baseURL to ModelConfig affects other providers, we could use a generic options field or provider-specific configuration.
Additional Context
The @ai-sdk/openai package already supports baseURL option: https://sdk.vercel.ai/providers/ai-sdk-providers/openai#custom-base-url
This feature would greatly benefit users in regions where OpenAI API access is restricted or expensive, allowing them to use local/cheaper alternatives while maintaining compatibility.
Feature Request: Support custom OpenAI base URL
Description
Currently, open-mem only supports the official OpenAI API endpoint (
https://api.openai.com/v1). This prevents users from using compatible third-party services like SiliconFlow (硅基流动), DeepSeek, or self-hosted OpenAI-compatible APIs.Current Behavior
The
ModelConfiginterface only acceptsapiKey, and the OpenAI provider is initialized without abaseURLparameter:https://github.com/clopca/open-mem/blob/main/src/ai/provider.ts#L64-L69
Expected Behavior
Allow users to specify a custom base URL for OpenAI-compatible providers via:
OPENAI_BASE_URLUse Cases
https://api.siliconflow.cn/v1https://api.deepseek.com/v1Proposed Solution
1. Update
ModelConfiginterface (provider.ts)2. Pass baseURL to createOpenAI (provider.ts)
3. Read from environment (config.ts)
Add
OPENAI_BASE_URLenvironment variable support alongside existingOPENAI_API_KEY.Alternative Considered
If adding
baseURLtoModelConfigaffects other providers, we could use a genericoptionsfield or provider-specific configuration.Additional Context
The
@ai-sdk/openaipackage already supportsbaseURLoption: https://sdk.vercel.ai/providers/ai-sdk-providers/openai#custom-base-urlThis feature would greatly benefit users in regions where OpenAI API access is restricted or expensive, allowing them to use local/cheaper alternatives while maintaining compatibility.