#17566: memory-lancedb: support local OpenAI-compatible embeddings
extensions: memory-lancedb
size: M
Cluster:
Memory Database Enhancements
## Summary
- allow custom OpenAI-compatible embedding endpoints via `embedding.baseUrl`
- allow custom model ids and explicit vector sizing via `embedding.dimensions`
- switch embedding calls to raw OpenAI-compatible `/embeddings` HTTP for broader local-provider compatibility
- enforce embedding dimension consistency at runtime to prevent LanceDB vector mismatch errors
- extend tests for custom-model/dimensions/baseUrl validation paths
## Validation
- `pnpm vitest run extensions/memory-lancedb/index.test.ts`
## Linked issue
Closes https://github.com/openclaw/openclaw/issues/17564
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Adds support for local OpenAI-compatible embedding endpoints in the `memory-lancedb` plugin by replacing the OpenAI SDK with raw `fetch` calls, adding `embedding.baseUrl` and `embedding.dimensions` configuration options, and enforcing dimension consistency at runtime.
- Replaced `openai` SDK with raw HTTP `fetch` for broader local-provider compatibility (e.g., LM Studio, llama.cpp, vLLM), with 30s timeout via `AbortSignal.timeout()`
- Added `embedding.baseUrl` for custom endpoints and `embedding.dimensions` for explicit vector sizing on custom models
- Split `requestDimensions` (sent to API only when explicitly configured) from `expectedDimensions` (always validated against response) to maintain backward compatibility with providers that reject unknown fields
- Removed unused `openai` dependency from `package.json` (~28MB savings at plugin install time)
- Comprehensive config validation: type/range checks for dimensions, empty-string rejection for baseUrl, env-var resolution for baseUrl/apiKey
- Good test coverage for new validation paths (custom model + dimensions, empty baseUrl, dimension type/range, unknown model without dimensions)
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge — clean implementation with proper validation, error handling, and test coverage.
- The changes are well-scoped: replace OpenAI SDK with raw fetch for broader compatibility, add new config options with thorough validation, and remove the unused dependency. The follow-up commit addressed all previously flagged issues (timeout, conditional dimensions in request body, unused dep removal). Code paths have good test coverage, error handling is consistent, and the dimension validation split (requestDimensions vs expectedDimensions) correctly preserves backward compatibility. No security concerns — baseUrl is admin-configured, API keys are properly handled, and there are no injection vectors.
- No files require special attention.
<sub>Last reviewed commit: 3f758e6</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Closes https://github.com/openclaw/openclaw/issues/8118
Most Similar PRs
#20771: feat(memory-lancedb): support custom OpenAI-compatible embedding pr...
by marcodelpin · 2026-02-19
89.4%
#17874: feat(memory-lancedb): Custom OpenAI BaseURL & Dimensions Support
by rish2jain · 2026-02-16
85.6%
#10550: feat(memory-lancedb): local embeddings via node-llama-cpp
by namick · 2026-02-06
85.5%
#19006: feat(memory-lancedb): OpenAI-compatible baseUrl + Ollama provider +...
by martinsen-assistant · 2026-02-17
85.5%
#17030: feat(memory-lancedb): support Ollama and OpenAI-compatible embeddin...
by nightfullstar · 2026-02-15
82.4%
#17701: fix(memory-lancedb): add gemini-embedding-001 and baseUrl support
by Phineas1500 · 2026-02-16
79.1%
#21816: Add configurable `dimensions` for embedding models (Matryoshka supp...
by matthewspear · 2026-02-20
76.9%
#22692: fix(memory-lancedb): [P1] add missing runtime deps — plugin broken ...
by mahsumaktas · 2026-02-21
76.8%
#15896: fix(memory-lancedb): capture even with injected recall context
by aelaguiz · 2026-02-14
75.7%
#15639: fix(memory): serialize local embedding initialization to avoid dupl...
by SubtleSpark · 2026-02-13
74.8%