PromptLayer Run Agent icon

PromptLayer Run Agent

Run an Agent from the PromptLayer API

Overview

This node allows you to run an Agent from the PromptLayer API. It is designed to execute a specified Agent workflow by name or ID, optionally targeting a specific version number or label. The node sends input variables to the Agent and waits for its execution results, handling asynchronous polling until the Agent completes or a timeout occurs.

Common scenarios include automating AI-driven workflows, integrating custom prompt-based agents into larger automation pipelines, or running specific versions of Agents with tailored inputs. For example, you might use this node to trigger a natural language processing Agent that generates summaries based on provided text inputs or to run a labeled version of an Agent that performs data enrichment tasks.

Properties

Name Meaning
Agent Name or ID The name or ID of the Agent to execute. You can select from a dynamically loaded list or specify an ID using an expression.
Use Agent Label Name Boolean flag indicating whether to use an Agent label name instead of a version number to specify which Agent version to run.
Agent Version Number (Shown if not using Agent label) Specify the numeric version of the Agent to run.
Agent Label Name (Shown if using Agent label) Specify the label name of the Agent version to run.
Input Variables A JSON dictionary of input variables required by the Agent. These are passed as inputs when executing the Agent.
Additional Fields A collection of optional fields:
- Metadata: JSON key-value pairs to attach as metadata.
- Return All Outputs: Boolean to return all outputs from the Agent execution.
- Timeout: Maximum wait time in minutes.

Output

The node outputs a JSON array where each item corresponds to one execution of the Agent. Each output item contains the full response body from the PromptLayer API representing the Agent's execution results.

If the "Return All Outputs" option is enabled, the output includes all outputs generated by the Agent; otherwise, it may contain only the primary output.

The node does not output binary data.

Dependencies

  • Requires an API key credential for authenticating with the PromptLayer API.
  • Makes HTTP requests to https://api.promptlayer.com endpoints.
  • Uses n8n's built-in request helpers with authentication support.
  • The node expects the user to have configured the necessary API key credential in n8n.

Troubleshooting

  • Invalid JSON in Input Variables or Metadata: If the JSON provided in these fields is malformed, the node will throw an error specifying the issue. Ensure valid JSON syntax.
  • Missing workflow_version_execution_id in response: Indicates the API did not return an expected execution ID. This could be due to incorrect Agent name/ID or API issues.
  • Execution Timeout: If the Agent does not complete within the specified timeout (default 10 minutes), the node throws a timeout error. Increase the timeout if needed.
  • Unexpected status code during polling: If the API returns a status other than 200 (OK) or 202 (Accepted) while waiting for results, the node throws an error. Check API availability and credentials.
  • Credential errors: Ensure the API key credential is correctly set up and has sufficient permissions.

Links and References

Discussion