Skip to main content

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.
info

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:

  1. Validates the authentication method (API key or Robomotion AI Credits)
  2. If using API key: Tests the connection by making a request to list models
  3. Creates an HTTP client with 30-second timeout
  4. Generates a unique connection ID (UUID)
  5. Stores the client session in memory for reuse by other nodes
  6. 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

FeatureAPI KeyRobomotion AI Credits
OpenRouter Account RequiredYesNo
Account ManagementFull accessNot available
Model AccessAll 480+ modelsAll 480+ models
Usage TrackingIn OpenRouter dashboardIn Robomotion workspace
Setup ComplexityRequires API key creationZero setup
Best ForProduction use, full controlQuick 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

  1. 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
  2. Error Handling:

    • Wrap Connect in try-catch blocks for production flows
    • Handle authentication errors appropriately
    • Consider retry logic for network issues
  3. Security:

    • Store API keys as credentials, never hardcode them
    • Use Disconnect to clean up sessions
    • Rotate API keys regularly for production use
  4. Performance:

    • Reuse the same connection for multiple operations
    • Avoid creating multiple connections in parallel
    • Connection validation adds a small latency on connect
  5. 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.