feat: add OpenAI-compatible embedding provider - #158
HosseinShahabadi wants to merge 1 commit into
Conversation
Adds support for any OpenAI-compatible embeddings endpoint (OpenAI, OpenRouter, Azure OpenAI, Together AI, etc.) as an alternative to fastembed. New env vars: EMBEDDING_PROVIDER=openai, OPENAI_API_KEY, OPENAI_BASE_URL, OPENAI_VECTOR_SIZE. Vector size is auto-detected at startup via a probe request if OPENAI_VECTOR_SIZE is not set explicitly.
|
@HosseinShahabadi, letting you know I've opened #187 as a draft for the same feature. Yours is the newest of three open OpenAI-compatible PRs (#92, #111, #158) and it felt wrong to add a fourth without saying anything. #158 has gone stale against master and hasn't been reviewed. The pattern I see is that this repo is short on review bandwidth, and the one piece of guidance we've actually got from a maintainer (@kacperlukawski in #55, asking for "just OpenAI embeddings, but nothing else") hasn't been met by any of the three, since all of them ship refactors alongside the feature. So mine is additive only: 26 lines touched in existing files, one new provider, FastEmbed left alone. If you'd rather push #158 across the line yourself, I'll close mine and help with the rebase. I just want the feature to exist. |
Summary
Adds support for any OpenAI-compatible embeddings endpoint as an
alternative to fastembed. This allows users to use OpenAI, OpenRouter,
Azure OpenAI, Together AI, or any other compatible provider without
needing to run a local model.
Changes
embeddings/types.py— addedOPENAItoEmbeddingProviderTypeenumembeddings/openai.py— new provider implementingEmbeddingProviderembeddings/factory.py— added openai branch tocreate_embedding_providersettings.py— addedOPENAI_API_KEY,OPENAI_BASE_URL,OPENAI_VECTOR_SIZEfieldsREADME.md— documented new env vars and usage examplesNew environment variables
OPENAI_API_KEYOPENAI_BASE_URLhttps://api.openai.com/v1OPENAI_VECTOR_SIZEExample (OpenRouter)
Testing
Tested locally with OpenRouter +
qwen/qwen3-embedding-4bagainsta local Qdrant instance. Both
qdrant-storeandqdrant-findtoolswork correctly via MCP inspector.