feat(llm): add OpenRouter as a native LLM provider#363
Open
amiraijaz wants to merge 1 commit intoSmythOS:mainfrom
Open
feat(llm): add OpenRouter as a native LLM provider#363amiraijaz wants to merge 1 commit intoSmythOS:mainfrom
amiraijaz wants to merge 1 commit intoSmythOS:mainfrom
Conversation
Adds OpenRouter as a first-class LLM connector, giving SmythOS agents access to 100+ models (Mistral, Llama, Qwen, Gemma, DeepSeek, Phi, Command R+) through a single OpenRouter API key and zero changes to the core engine. ## What changed ### New: OpenRouter connector - Full implementation of all 4 abstract LLMConnector methods: request, streamRequest, reqBodyAdapter, reportUsage - Streaming via EventEmitter + setImmediate (prevents race conditions) - Tool calling (function calling) support - JSON response format support - OpenRouter-specific headers: HTTP-Referer and X-Title ### Modified: LLM service registry (+3 lines) - Import, register, and init OpenRouterConnector ### Modified: Model catalog (+7 entries) - openrouter/mistral-large - openrouter/meta-llama/llama-3.3-70b - openrouter/qwen/qwen-2.5-72b - openrouter/google/gemma-3-27b - openrouter/deepseek/deepseek-r1 - openrouter/microsoft/phi-4 - openrouter/cohere/command-r-plus ### New: Integration tests (5 tests, all passing) - Simple prompt, system message, JSON mode, streaming, tool calling ## Why a dedicated connector (not reusing OpenAIConnector) OpenRouter requires HTTP-Referer and X-Title headers that the existing OpenAI connector cannot send. A dedicated connector also provides a foundation for future features: provider routing config and per-request cost tracking via the usage.cost field in every OpenRouter response. ## Why OpenRouter (not just Groq) Groq = speed (LPU hardware, ~15 curated models) OpenRouter = choice (100+ models, automatic fallback, day-of release) They are complementary, not redundant. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
|
@amiraijaz Thanks for putting this together and taking the time to make this contribution. Adding OpenRouter is a great fit for the platform. We'll do our own tests end to end on our to make sure everything works correctly and then we'll get this merged. Thanks again for the contribution :) |
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.
Summary
OpenRouterConnector— a dedicated LLM connector giving SmythOS agentsaccess to 100+ models (Mistral, Llama, Qwen, Gemma, DeepSeek, Phi, Command R+)
through a single OpenRouter API key
LLM.service/index.ts(+3 lines, zero changes to core engine)models.tsunder a new#region OpenRoutersection— all passing against the live API
Why OpenRouter and not just Groq
Groq = speed (LPU hardware, ~15 curated models)
OpenRouter = choice (100+ models, automatic provider fallback, day-of-release availability)
They are complementary, not redundant. Users wanting Mistral, Llama 3.3, Qwen 2.5,
Gemma 3, or DeepSeek R1 currently have no path in SmythOS. This PR fixes that
with one connector.
Why a dedicated connector (not reusing OpenAIConnector)
OpenRouter requires identifying HTTP headers (
HTTP-Referer,X-Title) that theexisting OpenAI connector has no mechanism to send. A dedicated connector also
provides a clean foundation for future OpenRouter-specific features such as
provider routing config and per-request cost tracking via the
usage.costfieldreturned in every OpenRouter response.
Files changed
connectors/OpenRouter.class.tsLLM.service/index.tsmodels.ts#region OpenRoutertests/integration/003-LLM/openrouter/openrouter.test.tsTest plan
responseFormat: json) works