Add OpenRouter AI integration with dynamic model fetching#281
Draft
Add OpenRouter AI integration with dynamic model fetching#281
Conversation
Contributor
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the Comment |
- Add OpenRouter provider config in wedocs_get_ai_provider_configs() - Implement call_openrouter_api() method following OpenAI-compatible format - Add REST endpoint for fetching OpenRouter models dynamically - Update frontend with model fetching UI and state management - Add "Fetch Models" button for OpenRouter in settings Co-authored-by: iftakharul-islam <[email protected]>
Co-authored-by: iftakharul-islam <[email protected]>
Copilot
AI
changed the title
[WIP] Add OpenRouter AI integration for model selection
Add OpenRouter AI integration with dynamic model fetching
Jan 13, 2026
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.
Implements OpenRouter AI provider integration allowing users to dynamically fetch and select from available models instead of being limited to predefined model lists.
Backend Changes
includes/functions.php: Added OpenRouter provider config withsupports_dynamic_modelsflag andmodel_list_endpointincludes/API/API.php:call_openrouter_api()using OpenAI-compatible formatGET /wp-json/wp/v2/docs/ai/models/{provider}for model fetchingfetch_openrouter_models()with proper authentication headers (HTTP-Referer,X-Title)Frontend Changes
src/components/Settings/AiSettings.js:fetchOpenRouterModels()to call REST endpoint and update provider model listUsage
User workflow: Select OpenRouter → Enter API key → Click "Fetch Available Models" → Select model → Generate AI content.
Original prompt
Copilot Chat Conversation Export: OpenRouter AI integration implementation guide
User: @iftakharul-islam
Thread URL: https://github.com/copilot/c/54288940-3663-44f1-91fd-3fe0ecc642f2
@iftakharul-islam
I want to add OpenRouter ai integration
Supporting Docs: https://openrouter.ai/docs/quickstart
user will select available models from it and don't bind it only with predefined models.
give me the implementation details proper guide on how we can achive it our plugin
Copilot
I'll help you create a comprehensive implementation guide for integrating OpenRouter AI into the weDevsOfficial/wedocs-plugin. Let me first examine the repository structure to understand the current architecture. Let me gather more information about the existing AI integration and plugin structure: Based on my analysis of the weDocs plugin repository, I can provide you with a comprehensive implementation guide for adding OpenRouter AI integration. The plugin already has a well-structured AI provider system in place, making it relatively straightforward to add OpenRouter.
📋 Implementation Guide: OpenRouter AI Integration
Current Architecture Overview
Your plugin uses a centralized AI provider system with:
includes/API/API.phpsrc/utils/aiService.jsfor UI interactionssrc/components/Settings/AiSettings.jsincludes/functions.phpviawedocs_get_ai_provider_configs()🎯 Step-by-Step Implementation
Step 1: Add OpenRouter Provider Configuration
File:
includes/functions.phpLocate the
wedocs_get_ai_provider_configs()function (around line 594) and add OpenRouter configuration:Step 2: Implement OpenRouter API Call Method
File:
includes/API/API.phpAdd a new method to handle OpenRouter API calls (add after the existing provider methods like
call_openai_api,call_anthropic_api, etc.):