Skip to content

fix OpenAI embedder baseurl#4275

Merged
deshraj merged 3 commits intomem0ai:mainfrom
amahuli03:4268/fix-openai-embedder-baseurl
Mar 13, 2026
Merged

fix OpenAI embedder baseurl#4275
deshraj merged 3 commits intomem0ai:mainfrom
amahuli03:4268/fix-openai-embedder-baseurl

Conversation

@amahuli03
Copy link
Copy Markdown
Contributor

Description

The TypeScript SDK's OpenAIEmbedder ignores the baseURL and url configuration parameters, forcing all embedding requests to api.openai.com. This breaks support for custom endpoints like OpenRouter, Azure, and local providers.

This mirrors the fix already applied to the Python SDK (issue #1144)

Fixes #4268

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Test Script (please provide)

Manually verified by instantiating OpenAIEmbedder with url: "http://localhost:9999/v1" and calling embed(). Before the fix, the request defaulted to api.openai.com. After the fix, the connection error confirms the request targeted localhost:9999/v1/embeddings as expected.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • New and existing unit tests pass locally with my changes
  • I have checked my code and corrected any misspellings

Maintainer Checklist

Part of fixing OpenAIEmbedder ignoring custom base URLs (mirrors Python SDK fix for mem0ai#1144).
The Zod schema already validates baseURL. This adds it to the TypeScript interface.
Previously the constructor only passed apiKey, causing all requests to default to api.openai.com. Now baseURL (with url as fallback) is forwarded, enabling custom endpoints like OpenRouter, Azure, and local providers.
Ensures baseURL is preserved when merging user config with defaults, so it reaches OpenAIEmbedder when using the Memory class.
@kartik-mem0 kartik-mem0 requested review from kartik-mem0 and whysosaket and removed request for kartik-mem0 March 13, 2026 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants