openrouter-connector
Reactive icon

OpenRouter Connector

Stable version 1.0.0 (Compatible with OutSystems 11)
Uploaded
 on 29 Jul (13 hours ago)
 by 
0.0
 (0 ratings)
openrouter-connector

OpenRouter Connector

Documentation
1.0.0

Connect OutSystems ODC and O11 applications to 100+ AI models (Claude 3.5 Sonnet, GPT-4o, DeepSeek, Gemini, Llama 3) with a single API key, low-code server actions, and a drag-and-drop Chatbot UI widget.


🌟 Key Features

  • ⚡ Access 100+ AI Models with 1 API Key: Connect to Anthropic Claude, OpenAI, Meta Llama, Google Gemini, DeepSeek, and Mistral through OpenRouter.
  • 🔄 Instant Model Swapping: Switch models dynamically by changing a single parameter string (e.g. anthropic/claude-3.5-sonnet to openai/gpt-4o or deepseek/deepseek-r1) — zero code changes required.
  • 💬 Drag-and-Drop Chatbot UI Block (AIAgent_ChatWidget): A pre-styled, responsive Chatbot interface with user/AI speech bubbles, typing indicators, auto-scroll, and error handling.
  • 🧠 Conversational Memory (OpenRouter_ChatAgent): Full multi-turn chat support that maintains conversation history across user and assistant messages.
  • ⚡ Quick Q&A Action (OpenRouter_PromptAgent): High-level Server Action for single-prompt requests (summaries, translations, data extractions).
  • 📱 Cross-Platform: 100% compatible with ODCO11 Reactive WebPWA, and Native Mobile Shells.

💻 Framework Compatibility

FrameworkSupported
OutSystems Developer Cloud (ODC)✅ Yes
OutSystems 11 (O11) Reactive Web✅ Yes
OutSystems 11 (O11) Mobile / PWA✅ Yes
Traditional Web❌ No (Use Reactive/ODC version)

🌍 Real-Life Business Use Cases🏢 1. Automated Customer Support & FAQ Assistant

Problem: Customer support teams are overwhelmed by repetitive queries regarding order status, return policies, and business hours.
Solution: Drag the AIAgent_ChatWidget onto your portal or mobile app with a system prompt like "You are a friendly customer service bot for Acme Store". The bot handles routine FAQs 24/7 using cost-effective models like google/gemini-flash-1.5 or openai/gpt-4o-mini.

📄 2. Document & Invoice Summarizer

Problem: Employees waste hours manually reading lengthy PDF contracts, invoices, or customer emails.
Solution: Use OpenRouter_PromptAgent in a background process. Pass the document text with a system prompt asking to "Extract key dates, total amounts, and contract parties as bullet points".

💡 3. Multi-Model A/B Testing & Cost Optimization

Problem: Locking an enterprise app into a single cloud AI provider (like Azure OpenAI) makes it difficult to take advantage of cheaper or faster new models.
Solution: Use OpenRouter to route simple tasks (e.g., categorizing a ticket) to budget open-source models like meta-llama/llama-3.3-70b, while routing complex legal or financial analysis to anthropic/claude-3.5-sonnet or deepseek/deepseek-r1.

🌐 4. Multilingual Translation & Localized Responses

Problem: A global enterprise needs to support users in 30+ languages without hiring multilingual staff.
Solution: Pass user input into OpenRouter_PromptAgent specifying the target output language. The AI translates text, detects sentiment, and generates culturally context-aware replies.

💻 5. Smart Developer & SQL Assistant for Internal Tools

Problem: Internal operations teams need help writing complex database search filters or analytical reports.
Solution: Embed a chat widget inside your internal back-office portal powered by deepseek/deepseek-r1 or anthropic/claude-3.5-sonnet to assist staff with logic and data analysis.


📖 User Manual & Technical Reference1. Block Specification (AIAgent_ChatWidget)📥 Input Parameters

Parameter NameData TypeMandatoryDefault ValueDescription
ApiKeyTextTrue""OpenRouter API Key (sk-or-v1-...).
ModelTextFalse"anthropic/claude-3.5-sonnet"Target AI Model ID string.
SystemPromptTextFalse"You are a helpful assistant."Instructions defining the AI persona and boundaries.
WidgetTitleTextFalse"AI Assistant"Title displayed in the chat header bar.
PlaceholderTextTextFalse"Ask anything..."Input field placeholder text.
ExtendedClassTextFalse""Custom CSS class applied to outer container.

📤 Block Events

Event NameParameter(s)Description
OnResponseReceivedLatestResponse (Text)Triggered when the AI model successfully sends a response back.
OnErrorErrorMessage (Text)Triggered if the OpenRouter API key fails or network drops.

2. Server Actions Reference⚙️ OpenRouter_PromptAgent (Single Question Q&A)

Use this action when you need a single answer without keeping chat memory (e.g. text translation, data extraction).

  • Inputs: ApiKeyModelSystemPromptUserPromptTemperatureMaxTokens
  • Outputs: IsSuccessAIResponseTextErrorMessageTotalTokensUsed

⚙️ OpenRouter_ChatAgent (Conversational Memory)

Use this action for multi-turn conversations where the AI needs to remember previous context.

  • Inputs: ApiKeyModelSystemPromptConversationHistory (List of OpenRouterMessage), NewUserMessage
  • Outputs: IsSuccessLatestAIResponseUpdatedHistory (List of OpenRouterMessage), ErrorMessageTotalTokensUsed

🔍 Troubleshooting & FAQQ: Where do I get an OpenRouter API Key?

A: Create a free account at openrouter.ai, go to Keys, and generate a key starting with sk-or-v1-.

Q: What happens if an invalid model string is passed?

A: OpenRouter will return an API error message (e.g. Model not found), which is caught by the Server Action and returned in the ErrorMessage output parameter.

Q: How do I control how long/short the AI response is?

A: You can pass MaxTokens (e.g. 100 for short replies, 2000 for detailed articles) or specify formatting rules inside the SystemPrompt (e.g. "Keep answers under 50 words").


📄 License & Contribution

  • Distributed under the MIT License. Free for commercial and personal use in all OutSystems ODC and O11 applications.