diff --git a/core/llm/llms/HuggingFaceTEI.ts b/core/llm/llms/HuggingFaceTEI.ts index 52580c187..187db8122 100644 --- a/core/llm/llms/HuggingFaceTEI.ts +++ b/core/llm/llms/HuggingFaceTEI.ts @@ -35,14 +35,20 @@ class HuggingFaceTEIEmbeddingsProvider extends BaseLLM { } async doEmbedRequest(batch: string[]): Promise { + const headers: Record = { + "Content-Type": "application/json", + }; + + if (this.apiKey) { + headers["Authorization"] = `Bearer ${this.apiKey}`; + } + const resp = await this.fetch(new URL("embed", this.apiBase), { method: "POST", body: JSON.stringify({ inputs: batch, }), - headers: { - "Content-Type": "application/json", - }, + headers, }); if (!resp.ok) { const text = await resp.text();