Skip to main content

Get Current API Key

Retrieves information about the currently authenticated API key including usage limits and remaining quota.

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.

Inputs

  • Connection Id - The connection identifier from Connect node (optional if API Key is provided directly).

Options

  • API Key - OpenRouter API key credential (optional if using Connection Id).
warning

This node does NOT support "Use Robomotion AI Credits" mode. You must use your own OpenRouter API key.

Output

  • API Key Info - API key information object containing:
    • label - Display label for the key
    • limit - Credit limit for this key (in USD, 0 = unlimited)
    • usage - Current usage amount (in USD)
    • is_free_tier - Whether this is a free tier key
    • limit_remaining - Remaining credit limit
    • is_provisioning_key - Whether this is a provisioning key (for API key management)

How It Works

When executed, the node:

  1. Validates the connection or credentials
  2. Blocks execution if using Robomotion AI Credits (not supported)
  3. Makes GET request to /key endpoint
  4. Parses the response and extracts API key information
  5. Returns the key metadata object

Requirements

  • Valid OpenRouter API Key (Robomotion AI Credits NOT supported)
  • Active OpenRouter account

Error Handling

The node will return specific errors in the following cases:

  • Using Robomotion AI Credits mode (unsupported)
  • API authentication errors (401)
  • API service errors (500, 502, 503, 504)

Examples

Example 1: Check Key Status

Input:

  • Connection Id: msg.connection

Output:

{
label: "Production Key",
limit: 100.00,
usage: 45.30,
is_free_tier: false,
limit_remaining: 54.70,
is_provisioning_key: false
}

Example 2: Key Limit Alert

// Get Current API Key Node
// Output: msg.api_key

if (msg.api_key.limit > 0) {
const usage_percent = (msg.api_key.usage / msg.api_key.limit) * 100;

if (usage_percent > 90) {
sendAlert(`API key "${msg.api_key.label}" at ${usage_percent.toFixed(1)}% usage`);
}

console.log(`Remaining: $${msg.api_key.limit_remaining.toFixed(2)}`);
}

Example 3: Free Tier Check

// Get Current API Key Node
// Output: msg.api_key

if (msg.api_key.is_free_tier) {
console.log("Using free tier - limited features may apply");
} else {
console.log(`Paid tier with $${msg.api_key.limit} limit`);
}

Example 4: Provisioning Key Validation

// Get Current API Key Node
// Output: msg.api_key

if (!msg.api_key.is_provisioning_key) {
throw new Error("Provisioning API key required for this operation");
}

console.log("Provisioning key confirmed - proceeding with key management");

Best Practices

  1. Monitor Usage:

    • Check key usage regularly
    • Set up alerts for high usage
    • Track remaining limits
  2. Key Types:

    • Use regular keys for AI operations
    • Use provisioning keys for key management
    • Don't confuse the two types
  3. Limit Management:

    • Set appropriate limits for production keys
    • Monitor free tier restrictions
    • Plan for limit increases

Use Cases

  1. Pre-Operation Checks: Validate key has sufficient remaining limit
  2. Usage Monitoring: Track key-specific usage
  3. Key Type Validation: Ensure correct key type for operations
  4. Limit Alerts: Notify when approaching key limits
  5. Free Tier Detection: Handle free tier limitations
  6. Multi-Key Management: Monitor different keys for different purposes