@@ -69,13 +69,23 @@ async def batch_embed(self, input_texts: list[str]) -> list[dict]:
6969 #
7070 # NOTE:
7171 # - `self.model` should follow the LiteLLM model name convention,
72- # e.g. "openai: text-embedding-3-small" or "openrouter: qwen/qwen3-embedding-8b".
72+ # e.g. "openai/ text-embedding-3-small" or "openrouter/ qwen/qwen3-embedding-8b".
7373 # - API keys / base URLs are expected to be configured via LiteLLM
74- # environment variables or global configuration.
75- data = await aembedding (
76- model = self .model ,
77- input = input_texts ,
78- )
74+ # environment variables or passed explicitly below.
75+ kwargs : dict = {
76+ "model" : self .model ,
77+ "input" : input_texts ,
78+ }
79+
80+ # For custom endpoints, we need api_key and api_base
81+ if self .base_url :
82+ kwargs ["api_base" ] = self .base_url
83+
84+ # API key handling
85+ if self .api_key :
86+ kwargs ["api_key" ] = self .api_key
87+
88+ data = await aembedding (** kwargs )
7989 except Exception as exc : # pragma: no cover - defensive logging
8090 logger .error ("Embedding call via LiteLLM failed: %s" , exc )
8191 raise ValueError (f"Embedding API error: { exc } " ) from exc
@@ -168,8 +178,10 @@ def _initialize_models(self, config: Config):
168178 # Use the first embedding spec we encounter as the embedder client
169179 if self .embedder_model is None :
170180 # api_key, base_url = self._resolve_embedding_credentials(spec)
181+ # LiteLLM expects model identifiers in the form "provider/model_name"
182+ # e.g. "openai/text-embedding-3-small" or "openrouter/qwen/qwen3-embedding-8b".
171183 self .embedder_model = EmbedderClient (
172- model_name = spec .model_name ,
184+ model_name = f" { spec .provider } / { spec . model_name } " ,
173185 api_key = spec .api_key ,
174186 base_url = spec .base_url ,
175187 )
0 commit comments