feat(openrouter): add open router to model block#1172
Conversation
There was a problem hiding this comment.
Greptile Summary
This PR adds OpenRouter as a new AI model provider to the Sim platform, enabling unified access to multiple AI models through OpenRouter's API gateway. The implementation follows the established provider pattern used by other providers like Ollama and OpenAI.
The changes introduce several key components:
- API Integration: A new
/api/providers/openrouter/modelsendpoint that fetches available models from OpenRouter's public API, applies deduplication, and prefixes model IDs withopenrouter/ - State Management: A new Zustand store (
stores/openrouter/store.ts) that manages OpenRouter models with loading states, following the same pattern as the Ollama store - Provider Configuration: Updates to the provider system including model definitions, update functions, and integration with the existing provider utilities
- UI Integration: Updates to the agent block to include OpenRouter models in the model selection dropdown alongside existing Ollama and base models
- Provider Implementation: A complete provider implementation that reuses the OpenAI client with OpenRouter's base URL, supporting streaming responses, tool calls, and comprehensive error handling
The integration maintains consistency with the existing codebase architecture by using dynamic model fetching (similar to Ollama), proper state management patterns, and following the established provider interface. OpenRouter models are fetched at runtime and automatically integrated into the UI, ensuring users have access to the latest available models without manual updates.
PR Description Notes:
- The PR description is incomplete with "IN PROG" in the summary and unchecked checkboxes
- Missing issue reference number
- No testing information provided
- Type of change not selected
Confidence score: 3/5
- This PR requires careful review due to several type safety concerns and incomplete documentation
- Score lowered due to extensive use of
anytypes,@ts-ignoredirective, and missing model validation in the OpenRouter provider implementation - Pay close attention to
apps/sim/providers/openrouter/index.tsfor type safety issues and error handling patterns
Context used:
Context - Avoid using type assertions to 'any' in TypeScript. Instead, ensure proper type definitions are used to maintain type safety. (link)
7 files reviewed, 4 comments
4b79cee to
6ecd557
Compare
* feat(openrouter): add open router to model block * improvement(openrouter): streaming fix, temperature fix * pr comments --------- Co-authored-by: waleedlatif1 <walif6@gmail.com>
Summary
added openrouter models, dynamically fetch list of models and specify capabilities.
Type of Change
Testing
Tested many of the new models manually, added unit tests for model capabilities at the provider level.
Checklist