PromptLayer Run Agent icon

PromptLayer Run Agent

Run an Agent from the PromptLayer API

Overview

The "PromptLayer Run Agent" node allows you to execute an Agent workflow from the PromptLayer API within an n8n automation. It is designed to trigger a specific Agent by name or ID, optionally specifying a version number or label, and pass input variables to it. The node then waits for the Agent execution to complete and returns the results.

This node is useful when you want to integrate complex AI-driven workflows managed in PromptLayer into your n8n automation pipelines. For example, you could run an AI prompt workflow that processes text, generates responses, or performs data enrichment, and then use the output downstream in your automation.

Practical examples:

  • Running a specific version of an AI prompt workflow with custom inputs.
  • Triggering labeled versions of Agents for A/B testing or staged deployments.
  • Collecting all outputs from an Agent execution for detailed analysis.

Properties

Name Meaning
Agent Name or ID The name or ID of the Agent workflow to execute. You can select from a list loaded dynamically or specify via expression.
Use Agent Label Name Boolean flag to choose whether to specify the Agent version by label name instead of version number.
Agent Version Number (Shown if not using label) Specify the numeric version of the Agent to run a specific version.
Agent Label Name (Shown if using label) Specify the label name of the Agent version to run a specific labeled version.
Input Variables JSON dictionary of input variables required by the Agent workflow.
Additional Fields Collection of optional fields:
- Metadata JSON key-value pairs as metadata to attach to the execution.
- Return All Outputs Boolean to indicate whether to return all outputs from the Agent execution instead of just the main one.
- Timeout Maximum time in minutes to wait for the Agent execution before timing out (default 10 minutes).

Output

The node outputs a JSON array where each item corresponds to an execution of the Agent workflow. Each output item contains the full response from the PromptLayer API about the Agent execution results.

  • The main json field includes details such as the execution ID and the outputs returned by the Agent.
  • If "Return All Outputs" is enabled, the node returns all outputs generated by the Agent; otherwise, it returns the default output.
  • The node does not output binary data.

Dependencies

  • Requires an API key credential for authenticating with the PromptLayer API.
  • The node makes HTTP requests to https://api.promptlayer.com.
  • The user must configure the API key credential in n8n prior to using this node.

Troubleshooting

  • Invalid JSON in Input Variables or Metadata: If the JSON provided in these fields is malformed, the node will throw an error indicating invalid JSON. Ensure the JSON syntax is correct.
  • Missing Execution ID in Response: If the API response does not include a workflow execution ID, the node throws an error. This may indicate an issue with the Agent name/ID or API permissions.
  • Execution Timeout: If the Agent execution takes longer than the specified timeout (default 10 minutes), the node errors out with a timeout message. Increase the timeout if needed.
  • Unexpected Status Code: If the API returns a status code other than 200 (OK) or 202 (Accepted), the node throws an error with the status code. Check API key validity and network connectivity.
  • Continue on Fail: If enabled, the node will continue processing subsequent items even if one fails, returning error messages in the output.

Links and References

Discussion