Repository navigation
Description
Problem
Basic Memory's experimental LiteLLM embedding provider currently supports provider/model selection, dimensions, role-specific input_type, batching, and request concurrency, but it does not expose an api_base / custom endpoint setting for embedding calls.
That makes it awkward or impossible to use Basic Memory with OpenAI-compatible embedding servers that are not hosted at the default provider endpoint.
A concrete example is running llama-server --embedding directly and exposing its OpenAI-compatible /v1/embeddings API. LiteLLM supports this shape by calling embeddings with an openai/... model string and an api_base, but Basic Memory does not currently provide a config field that reaches litellm.aembedding(...).
Why this matters
This is useful for local and self-hosted embedding deployments.
For example, Ollama can accept batched embedding input, but in some local setups it still runs embedding work through a single llama.cpp slot, which makes large Basic Memory reindexes extremely slow. Running llama-server --embedding directly with multiple slots can be materially faster while still exposing an OpenAI-compatible embeddings endpoint.
Current code shape
From a quick read of current main:
-
src/basic_memory/repository/litellm_provider.pyLiteLLMEmbeddingProvideracceptsapi_key,timeout, dimensions, batch size, concurrency, and role settings._embed()builds params forlitellm.aembedding(...).- The params include
model,input,drop_params,timeout, optionallydimensions,api_key, andinput_type. - There is no
api_base.
-
src/basic_memory/config.py- Semantic embedding config includes provider, model, dimensions, dimension forwarding, batch size, request concurrency, document/query input types, sync batch size, and FastEmbed runtime knobs.
- There is no endpoint/base URL field for semantic embedding providers.
-
src/basic_memory/repository/embedding_provider_factory.py- The factory passes LiteLLM model, batch size, request concurrency, input types, and dimension forwarding into
LiteLLMEmbeddingProvider. - There is no endpoint/base URL field in the provider cache key or provider constructor call.
- The factory passes LiteLLM model, batch size, request concurrency, input types, and dimension forwarding into
Suggested solution
Add api_base option and pass it to the LiteLLM embedding providers.
Activity
phernandez commentedon Jun 17, 2026
@claude can you look at this?
claude commentedon Jun 17, 2026
Claude finished @phernandez's task in 3m 2s —— View job • Create PR ➔
Implementing
api_basesupport for LiteLLM embedding providersapi_basethrough config → factory → provider →litellm.aembedding()semantic_embedding_api_basefield toBasicMemoryConfiginconfig.pyapi_baseparam toLiteLLMEmbeddingProvider(init, runtime_log_attrs, identity_key,_embed)embedding_provider_factory.pycache key and factory to passapi_baseapi_baseforwarding (provider + factory)Changes made
src/basic_memory/config.py— newsemantic_embedding_api_base: str | Nonefield (defaultNone), positioned near the other LiteLLM-specific config fields. Documented as applicable only whensemantic_embedding_provider='litellm'.src/basic_memory/repository/litellm_provider.py:__init__— newapi_base: str | None = Nonekeyword param, stored asself._api_baseruntime_log_attrs— includesapi_basein startup log output when setidentity_key— encodesapi_baseso changing the endpoint invalidates cached vectors_embed— passesapi_basetolitellm.aembedding(**params)when setsrc/basic_memory/repository/embedding_provider_factory.py:ProviderCacheKeytype — addedstr | Noneslot forapi_base_provider_cache_key— includesapp_config.semantic_embedding_api_basecreate_embedding_provider— passesapi_base=app_config.semantic_embedding_api_basetoLiteLLMEmbeddingProvidertests/repository/test_litellm_provider.py— five new tests:test_litellm_provider_api_base_forwarded— verifiesapi_basereacheslitellm.aembeddingtest_litellm_provider_api_base_omitted_when_none— verifiesapi_baseis absent by defaulttest_runtime_log_attrs_includes_api_base_when_settest_runtime_log_attrs_omits_api_base_when_not_settest_identity_key_includes_api_basetest_factory_forwards_litellm_api_base— verifies the factory wires the config field throughUsage example (after merging)
{ "semantic_embedding_provider": "litellm", "semantic_embedding_model": "openai/my-model", "semantic_embedding_api_base": "http://localhost:8080", "semantic_embedding_dimensions": 1536 }Or via environment variable:
BASIC_MEMORY_SEMANTIC_EMBEDDING_API_BASE=http://localhost:8080Push status
The commit is ready locally but the push was denied (
Permission to basicmachines-co/basic-memory.git denied to github-actions[bot]). A maintainer will need to push or merge the branchclaude/issue-1005-20260617-2159.kingpro1985 commentedon Jun 18, 2026
I saw this while looking at custom model/provider setup issues: "[FEATURE] Add api_base support for LiteLLM semantic embedding providers".
If it helps your testing, CloudGPU exposes a hosted OpenAI-compatible endpoint that can route to GPT, Claude, Gemini, DeepSeek, Kimi and GLM behind one API key.
Base URL: https://gpuapis.com/api/v1
Setup guide: https://gpuapis.com/use-cases/deepseek-gemini-claude-api/
I can share a small test key/credit and a cURL request if you want to verify it in your current client before doing any integration work.
feat(core): add LiteLLM API base and API key config
feat(core): add LiteLLM API base and API key config
feat(core): add LiteLLM API base and API key config