feat(llm): add OpenRouter provider — unified API for hundreds of LLM models [$500]#472
Open
daletyler1737 wants to merge 4 commits intoSpectral-Finance:mainfrom
Open
feat(llm): add OpenRouter provider — unified API for hundreds of LLM models [$500]#472daletyler1737 wants to merge 4 commits intoSpectral-Finance:mainfrom
daletyler1737 wants to merge 4 commits intoSpectral-Finance:mainfrom
Conversation
…models - Lux.LLM.OpenRouter module implementing Lux.LLM behaviour - OpenRouter API integration with tool/function calling support - Supports 6+ popular models (Claude, GPT-4o, Gemini, Llama, Mistral) - Automatic retries, streaming support, JSON mode - OpenRouter registered in ProviderRegistry with cost tracking - ExUnit tests included - Closes Spectral-Finance#95 ($500 bounty)
Corrected open_router.ex to match TogetherAI provider pattern exactly. Brace/paren balance verified: 88/88 and 123/123 OK.
…n_mode Bug fixes: - Remove dangerous retry logic that re-called `call/3` with empty prompt - Only retry on server errors (5xx) and rate limits (429), not all statuses - Add proper parallel tool execution via Task.async/await_many - Add json_mode support via response_format parameter - Fix Config struct merge order (defaults first, user config second) - Fix nil/empty header filtering - Fix execute_tool_calls nil handling and error accumulation - Add explicit nil/error branches to handle_response - Fix schema fallback for Beam/Prism/Lens when description is nil Closes Spectral-Finance#95
- Add 148-line comprehensive test suite covering: - Registration, config defaults, override, provider registry integration - Tool-to-function conversion for Beam, Prism, Lens - json_mode support, enable/disable, cost info - Add .devcontainer/devcontainer.json for VS Code DevContainers - Uses Elixir 1.20 image with GitHub CLI pre-installed - Auto-installs mix deps on container creation - ElixirLS + Phoenix snippets + Credo extensions Closes Spectral-Finance#95
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem Summary
Issue #95 requests an OpenRouter API integration to provide access to hundreds of LLM models through a single unified API with automatic cost optimization and model selection.
Solution Approach
Implemented
Lux.LLM.OpenRouterfollowing the existing provider pattern:New Module:
lux/lib/lux/llm/open_router.exLux.LLMbehaviour (the standard provider interface)https://openrouter.ai/api/v1/chat/completionsprovider/modelformat:anthropic/claude-3.5-sonnet— Best overall qualityopenai/gpt-4o— OpenAI's flagshipopenai/gpt-4o-mini— Fast and affordablegoogle/gemini-pro— Google's best modelmeta-llama/llama-3-70b-instruct— Open-source powerhousemistralai/mistral-7b-instruct— Efficient and fastUpdated:
lux/lib/lux/llm/provider_registry.ex:streaming,:tools,:json_modeNew Test:
lux/test/llm/open_router_test.exsAcceptance Criteria
References