diff --git a/.env.example b/.env.example index ce8e222..bc4a9eb 100644 --- a/.env.example +++ b/.env.example @@ -58,6 +58,11 @@ MAA_ENV_PATH=/home/your-user/.env # EMBEDDING_API_BASE=https://openrouter.ai/api/v1 # EMBEDDING_MODEL=qwen/qwen3-embedding-8b +# API key for non-OpenRouter authenticated endpoints (vLLM with --api-key, +# custom hosted embedding services). Not needed for OpenRouter (uses +# OPENROUTER_API_KEY) or local unauthenticated providers. +# EMBEDDING_API_KEY=your-key-here + # ── Strongly Recommended ────────────────────────────── # LLM extraction token limit — 1024 is too small, causes fabric truncation diff --git a/docker/worker/services/embedding.py b/docker/worker/services/embedding.py index b9d6ee6..450d746 100644 --- a/docker/worker/services/embedding.py +++ b/docker/worker/services/embedding.py @@ -11,6 +11,7 @@ import httpx logger = logging.getLogger("cognitive-worker.embedding") OPENROUTER_API_KEY = os.environ.get("OPENROUTER_API_KEY", "") +EMBEDDING_API_KEY = os.environ.get("EMBEDDING_API_KEY") # no fallback — explicit per-branch EMBEDDING_DIMS = int(os.environ.get("EMBEDDING_DIMS", "4096")) EMBEDDING_API_BASE = os.environ.get( "EMBEDDING_API_BASE", "https://openrouter.ai/api/v1" @@ -33,6 +34,9 @@ async def get_embedding(text: str) -> list[float]: headers["Authorization"] = f"Bearer {OPENROUTER_API_KEY}" headers["HTTP-Referer"] = "https://localhost" headers["X-Title"] = "Cognitive-Agent-MaaS" + elif EMBEDDING_API_KEY: + headers["Authorization"] = f"Bearer {EMBEDDING_API_KEY}" + # else: no auth header — localhost or unauthenticated endpoint payload = { "model": EMBEDDING_MODEL, diff --git a/setup/install.md b/setup/install.md index 948da5c..b148e9d 100644 --- a/setup/install.md +++ b/setup/install.md @@ -95,6 +95,11 @@ EMBEDDING_DIMS=4096 # EMBEDDING_API_BASE=https://openrouter.ai/api/v1 # EMBEDDING_MODEL=qwen/qwen3-embedding-8b +# Optional — API key for non-OpenRouter authenticated embedding endpoints +# (vLLM with --api-key, custom hosted services). Not needed for OpenRouter +# or local unauthenticated providers. +# EMBEDDING_API_KEY=your-key-here + # Optional ICARUS_OBSIDIAN=1 ICARUS_RESULT_MAX_CHARS=500