Skip to main content

List Models

Retrieves the list of available Claude models from the Anthropic API, including their details and capabilities.

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 Claude client session identifier from Connect node (optional if API Key is provided directly).

Options​

Authentication​

  • API Key - Claude API key (optional if using Connection ID). You can provide the API key directly instead of using a Connect node.
  • Use Robomotion AI Credits - Use Robomotion AI credits instead of your own API key.

Advanced​

  • Timeout (seconds) - Request timeout in seconds (default: 30). Leave empty for unlimited timeout.

Outputs​

  • Models - List of available Claude models with their details. This is an object containing model information including IDs, display names, creation dates, and types.

How It Works​

The List Models node queries the Anthropic API to retrieve available models. When executed, the node:

  1. Validates the connection or creates a temporary client using provided credentials
  2. Sets up the request timeout (30 seconds default, or unlimited if empty)
  3. Sends a request to the Claude Models API endpoint
  4. Receives the list of available models
  5. For direct API mode:
    • Converts each model to a simple structure with id, display_name, created_at, and type
    • Returns the models in a standardized format
  6. For Robomotion Credits mode:
    • Uses the gateway to fetch models
    • Returns the raw response from the gateway
  7. Returns the models list as output

Requirements​

  • Either a valid Connection Id from Connect node OR direct API Key credentials
  • Active network connection to Anthropic API

Error Handling​

The node will return specific errors in the following cases:

  • Invalid or missing Connection Id (when not using direct credentials)
  • API authentication errors (401) - invalid API key
  • API permission errors (403) - insufficient permissions
  • Network errors or connection failures
  • Timeout errors if the request takes longer than specified
  • API service errors (500, 503)

Usage Notes​

Model Information​

  • Each model entry contains:
    • id - Model identifier (e.g., "claude-sonnet-4-20250514")
    • display_name - Human-readable name (e.g., "Claude Sonnet 4")
    • created_at - When the model was created (ISO 8601 format)
    • type - Model type (e.g., "model")

Use Cases​

  • Dynamically discover available models
  • Check if a specific model is available
  • Display model options to users
  • Verify model IDs before use
  • Monitor when new models are released

Response Format​

The response is an object with:

  • data - Array of model objects
  • object - Type indicator ("list")
  • has_more - Boolean indicating if there are more results

Timeout Handling​

  • Default timeout is 30 seconds
  • Set to empty string for no timeout limit
  • Adjust based on network conditions
  • Longer timeouts for unstable connections

Examples​

Example 1: List All Available Models​

Inputs:

  • Connection Id: (from Connect node)

Configuration:

  • Timeout: 30 seconds

Output - Models:

{
"data": [
{
"id": "claude-opus-4-5-20251101",
"display_name": "Claude Opus 4.5",
"created_at": "2025-11-01T00:00:00Z",
"type": "model"
},
{
"id": "claude-sonnet-4-20250514",
"display_name": "Claude Sonnet 4",
"created_at": "2025-05-14T00:00:00Z",
"type": "model"
},
{
"id": "claude-3-5-haiku-latest",
"display_name": "Claude 3.5 Haiku",
"created_at": "2024-11-01T00:00:00Z",
"type": "model"
}
],
"object": "list",
"has_more": false
}

Example 2: Using Direct API Key​

Options:

  • API Key: (your credential)
  • Timeout: 30

Output: Same as Example 1, but without needing a Connect node first.


Example 3: Check if Specific Model Exists​

Flow:

  1. List Models node → msg.models
  2. JavaScript node:
    const models = msg.models.data;
    const targetModel = "claude-opus-4-5-20251101";
    const exists = models.some(m => m.id === targetModel);
    msg.modelExists = exists;
    return msg;
  3. Switch node: Check msg.modelExists
  4. Use the model if it exists

Example 4: Display Available Models to User​

Flow:

  1. List Models node → msg.models
  2. JavaScript node:
    const modelNames = msg.models.data.map(m => ({
    id: m.id,
    name: m.display_name
    }));
    msg.modelOptions = modelNames;
    return msg;
  3. Use modelOptions in a dropdown or selection UI

Example 5: Using Robomotion Credits​

Options:

  • Use Robomotion AI Credits: true
  • Timeout: 30

Output: Returns the list of models using Robomotion's gateway.


Example 6: Monitoring for New Models​

Flow:

  1. List Models node → msg.currentModels
  2. Data Table: Read previous model list → msg.previousModels
  3. JavaScript node: Compare lists
    const current = msg.currentModels.data.map(m => m.id);
    const previous = msg.previousModels.map(m => m.id);
    const newModels = current.filter(id => !previous.includes(id));

    if (newModels.length > 0) {
    msg.hasNewModels = true;
    msg.newModelIds = newModels;
    } else {
    msg.hasNewModels = false;
    }
    return msg;
  4. Switch node: Check msg.hasNewModels
  5. Send notification if new models detected
  6. Data Table: Update model list

Example 7: Model Selection Based on Capabilities​

Flow:

  1. List Models node → msg.models
  2. JavaScript node:
    const models = msg.models.data;

    // Select the newest Opus model for complex tasks
    const opusModels = models.filter(m =>
    m.id.includes('opus')
    ).sort((a, b) =>
    new Date(b.created_at) - new Date(a.created_at)
    );

    msg.selectedModel = opusModels[0].id;
    return msg;
  3. Generate Text node using msg.selectedModel

Best Practices​

  1. Caching:

    • Cache model list to avoid repeated API calls
    • Refresh periodically (e.g., daily) to catch new models
    • Store in Data Table or global variable for reuse
  2. Error Handling:

    • Handle cases where the API is unavailable
    • Provide fallback to known model IDs
    • Validate model existence before use
  3. Performance:

    • Use appropriate timeout values
    • Don't call on every flow execution
    • Cache results when possible
  4. Model Selection:

    • Don't hardcode model IDs if they might change
    • Use model listing to provide dynamic choices
    • Keep a list of preferred models as fallbacks
  5. User Experience:

    • Show display names to users, not model IDs
    • Provide descriptions of model capabilities
    • Sort models by relevance or capabilities
  6. Monitoring:

    • Track when new models are released
    • Test flows with new models
    • Update documentation when models change
  7. Validation:

    • Verify model IDs before making API calls
    • Handle deprecated models gracefully
    • Provide clear error messages for invalid models
  8. Security:

    • Protect API keys when listing models
    • Use credentials properly
    • Don't expose internal model information unnecessarily

Common Use Cases​

  1. Dynamic Model Selection:

    • Let users choose from available models
    • Select best model based on task requirements
    • Fallback to alternative models if preferred is unavailable
  2. Model Monitoring:

    • Track when new models are released
    • Monitor model availability
    • Alert when models are deprecated
  3. Feature Detection:

    • Check which models support specific features
    • Validate model compatibility
    • Ensure required models are available
  4. Cost Optimization:

    • Select cheaper models for simple tasks
    • Use premium models only when necessary
    • Build model selection logic based on requirements
  5. Testing:

    • Test flows with different models
    • Compare model outputs
    • Validate behavior across model versions

Integration Examples​

With Generate Text Node​

1. List Models → msg.models
2. JavaScript: Select best model → msg.selectedModel
3. Generate Text (Model: msg.selectedModel)

With Dynamic UI​

1. List Models → msg.models
2. Format models for dropdown → msg.modelOptions
3. Present to user for selection
4. Use selected model in subsequent nodes

With Monitoring System​

1. List Models (daily schedule)
2. Compare with previous list
3. If new models: Send notification
4. Update model registry
5. Trigger test flows for new models

Output Schema​

The models output follows this structure:

{
"data": [
{
"id": "string", // Model identifier
"display_name": "string", // Human-readable name
"created_at": "string", // ISO 8601 timestamp
"type": "string" // Model type
}
],
"object": "list",
"has_more": boolean
}

Use this schema when processing the output in JavaScript or other nodes.