Connect
Establishes a connection to OpenRouter API and creates a client session for accessing 480+ AI models from multiple providers.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.
Options
- API Key - OpenRouter API key credential for authentication. Get your API key from https://openrouter.ai/keys
- Use Robomotion AI Credits - When enabled, uses Robomotion's managed AI credits instead of your own API key. No OpenRouter account required.
Output
- Connection Id - A unique identifier for this connection session that must be used in subsequent OpenRouter operations.
How It Works
The Connect node is the first step in OpenRouter automation flows that require persistent sessions. When executed, the node:
- Validates the authentication method (API key or Robomotion AI Credits)
- If using API key: Tests the connection by making a request to list models
- Creates an HTTP client with 30-second timeout
- Generates a unique connection ID (UUID)
- Stores the client session in memory for reuse by other nodes
- Returns the connection ID for use in subsequent operations
Requirements
Option 1: Using Your Own API Key
- An OpenRouter account (sign up at https://openrouter.ai)
- An OpenRouter API key stored as a credential in Robomotion
- Active credits in your OpenRouter account
Option 2: Using Robomotion AI Credits
- No OpenRouter account needed
- Robomotion AI credits available in your workspace
Error Handling
The node will return specific errors in the following cases:
- Missing or invalid API key when not using Robomotion AI Credits
- Empty API key value in the credential
- Failed connection test (status code other than 200)
- Network errors or timeout issues
Usage Notes
- The Connect node should be executed before other OpenRouter operations when using persistent sessions
- The returned Connection Id must be passed to subsequent OpenRouter nodes
- Each Connect node creates a new session entry that should be cleaned up with a Disconnect node
- For security, always use the Disconnect node to remove the stored session when no longer needed
- Sessions are stored in memory only and automatically removed when the flow stops
Authentication Methods Comparison
| Feature | API Key | Robomotion AI Credits |
|---|---|---|
| OpenRouter Account Required | Yes | No |
| Account Management | Full access | Not available |
| Model Access | All 480+ models | All 480+ models |
| Usage Tracking | In OpenRouter dashboard | In Robomotion workspace |
| Setup Complexity | Requires API key creation | Zero setup |
| Best For | Production use, full control | Quick prototyping, team sharing |
Examples
Example 1: Connect with API Key
Configuration:
- API Key: (your OpenRouter API key credential)
- Use Robomotion AI Credits: false
Output:
- Connection Id: "550e8400-e29b-41d4-a716-446655440000"
Usage: This connection ID is then used in Generate Text, Chat Completion, and other nodes.
Example 2: Connect with Robomotion AI Credits
Configuration:
- Use Robomotion AI Credits: true
Output:
- Connection Id: "660f9511-f30c-52e5-b827-557766551111"
Usage: No API key needed. The session will automatically use Robomotion AI credits for all operations.
Example 3: Full Workflow Pattern
[Connect Node]
|
| Connection Id: msg.openrouter_connection
|
v
[Generate Text Node] --> Uses msg.openrouter_connection
|
v
[Chat Completion Node] --> Uses msg.openrouter_connection
|
v
[Disconnect Node] --> Uses msg.openrouter_connection
This pattern ensures proper resource management and connection cleanup.
Best Practices
-
Resource Management:
- Always pair Connect with Disconnect nodes
- Use a single Connect node at the beginning of your flow
- Store the Connection Id in message scope for reuse
-
Error Handling:
- Wrap Connect in try-catch blocks for production flows
- Handle authentication errors appropriately
- Consider retry logic for network issues
-
Security:
- Store API keys as credentials, never hardcode them
- Use Disconnect to clean up sessions
- Rotate API keys regularly for production use
-
Performance:
- Reuse the same connection for multiple operations
- Avoid creating multiple connections in parallel
- Connection validation adds a small latency on connect
-
Choosing Authentication Method:
- Use API Key for production deployments requiring full control
- Use Robomotion AI Credits for rapid prototyping and team collaboration
- Consider Robomotion AI Credits for shared workspace projects
Alternative: Direct API Key Usage
Many OpenRouter nodes support direct API key input without using Connect/Disconnect. This is useful for:
- Single-operation workflows
- Simplified flow design
- Quick testing and prototyping
In this case, provide the API Key directly in the node options instead of using a Connection Id.