feat: add OpenRouter as LLM and embedding provider#56
feat: add OpenRouter as LLM and embedding provider#56oglenyaboss wants to merge 3 commits intorepowise-dev:mainfrom
Conversation
Add OpenRouter as a first-class provider, enabling access to 200+ models (Claude, GPT, Gemini, Llama, Qwen, etc.) through a single API key. LLM provider: - New OpenRouterProvider using OpenAI-compatible endpoint - Supports generate() and stream_chat() (ChatProvider protocol) - Sets recommended HTTP-Referer and X-Title headers - Default model: anthropic/claude-sonnet-4.6 - Rate limits: 60 RPM / 200K TPM - Cost tracking intentionally disabled (OpenRouter proxies models with varying prices — users should check the OpenRouter dashboard) Embedding provider: - New OpenRouterEmbedder for vector search and chat - Default model: google/gemini-embedding-001 (768 dims) - One OPENROUTER_API_KEY covers both LLM and embeddings Integration: - Registered in LLM and embedding registries (lazy import) - CLI auto-detection from OPENROUTER_API_KEY env var - Interactive provider selection in `repowise init` - Embedder selection in `repowise serve` - Server provider catalog for web UI - No new pip dependency (uses existing openai package) Tests: - 13 unit tests (construction, generation, error mapping, headers) - Registry test updated (builtin count 6 → 7) - Integration test (skipped without OPENROUTER_API_KEY)
|
This is really thorough, probably the most complete provider PR we've gotten. LLM + embedder + CLI + server catalog all done, and the honest known limitations section is appreciated. One thing to fix before merge:
Also flagging for awareness (not blocking):
Should be a quick fix, happy to merge after (1). |
Remove the cost_tracker parameter and unreachable if-block from generate(). OpenRouter proxies 200+ models with varying prices, so cost tracking is documented as unsupported — users should check the OpenRouter dashboard instead.
- stream_chat: text deltas, tool calls, rate limit error (3 tests) - OpenRouterEmbedder: construction, dimensions, embedding, base URL (12 tests)
|
Thanks for the review!
|
Summary
OPENROUTER_API_KEYrepowise init(doc generation) andrepowise serve(chat/search) work with OpenRouter out of the boxopenaipackage (OpenAI-compatible API)LLM Provider
OpenRouterProviderwithgenerate()+stream_chat()supportanthropic/claude-sonnet-4.6HTTP-RefererandX-Titleheaders for OpenRouter dashboard trackingEmbedding Provider
OpenRouterEmbedderfor semantic search and chat RAGgoogle/gemini-embedding-001(768 dims)Integration Points
OPENROUTER_API_KEYenv varrepowise initandrepowise serveKnown Limitations
/api/v1/modelsendpoint.qwen/qwen3.6-plusvia OpenRouter. Chat and embedding functionality was not integration-tested but follows the same OpenAI-compatible patterns as the existing OpenAI provider.Test plan
OPENROUTER_API_KEY)repowise initwith OpenRouter on a real project (328 wiki pages generated successfully)