Skip to main content
The n8n API integration enables n8n workflows to invoke PraisonAI agents via HTTP endpoints, allowing bidirectional automation between the platforms. The user triggers an n8n workflow; HTTP nodes call PraisonAI agents and return structured responses.

How It Works

Quick Start

1

Start PraisonAI API Server

For a containerised n8n, the API must be reachable from another container — bind to 0.0.0.0 and set an API key:
--auth (with CALL_SERVER_TOKEN) is the legacy praisonai/jobs/server.py call-server flag — not the serve agents auth. For praisonai serve agents, use --api-key / PRAISONAI_SERVE_API_KEY instead — see Agents Server → Security.
2

Configure n8n HTTP Request Node

3

Test the Integration


API Endpoints

POST /api/v1/agents//invoke

Invoke a specific PraisonAI agent with input data. URL Parameters: Request Body:
Required Fields: Optional Fields:

Supported agent_config keys

agent_config overrides only the whitelisted attributes below on the request’s isolated clone. Any other key returns a 400.
Behavior changed in v4.6.162. Before then, unknown keys were logged and silently ignored.
temperature is not on the whitelist — it is not a settable attribute on the resolved Agent in the wrapper, so passing it returns a 400. Set model parameters like temperature through agents.yaml instead.
Rejected requests return a FastAPI error with a 400 status:
The non-FastAPI standalone path (invoke_agent_standalone) returns the same rejection as {"error": "...", "status": "error", "agent_id": "..."} instead of raising an HTTP 400.

Session semantics

session_id isolates conversations per id, resumes history within an id, and runs ephemerally when omitted.
Do NOT pass a hard-coded fallback like session_id || "default" — that single bucket becomes one continuous conversation shared by every caller who lacks a real id, silently defeating the isolation this endpoint provides. Either pass a per-user / per-conversation id, or omit the field entirely to get the ephemeral (isolated, non-persistent) mode.
Response:
Error Response:

GET /api/v1/agents

List all available agents. Response:

GET /api/v1/health

Check API server health status. Response:

n8n HTTP Request Configuration

Basic Configuration

Advanced Configuration

Use this pattern when you want to dynamically select which agent to call based on input data.
Configure timeouts and retry logic for resilient workflows.
Control how n8n handles the API response data.

Authentication

Token-Based Authentication

Set up authentication for secure API access:

API Key Management

Implement token rotation for enhanced security:
Use different tokens for different environments:

Workflow Examples

Sequential Agent Workflow

Create a research → write → publish workflow:
  1. Webhook Trigger: Receives initial request
  2. Researcher HTTP Node: Calls /agents/researcher/invoke
  3. Writer HTTP Node: Calls /agents/writer/invoke with research data
  4. Publisher HTTP Node: Calls /agents/publisher/invoke with content
  5. Response Node: Returns final result

Conditional Routing Workflow

Route content to different agents based on type:
Implement fallback logic for failed agent calls:

Best Practices

Implement robust error handling in n8n workflows:
Validate data before sending to agents:When your workflow already knows who is talking (a user id, a customer id, a chat id), pass that stable value as session_id. When it doesn’t, omit the field — the endpoint’s ephemeral mode is the correct default. Do not synthesise ids per-run.
Optimize API calls for better performance:
  • Batch Requests: Group multiple agent calls when possible
  • Parallel Execution: Use fan-out patterns for independent calls
  • Caching: Store frequently used results in Set nodes
  • Connection Pooling: Configure HTTP node connection limits
  • Timeouts: Set appropriate timeouts based on agent complexity
Secure your API integration:
  • Authentication: Always use CALL_SERVER_TOKEN in production
  • HTTPS: Use encrypted connections for remote APIs
  • Input Sanitization: Validate and sanitize user inputs
  • Rate Limiting: Implement rate limiting on the PraisonAI server
  • Logging: Enable request logging for audit trails

Troubleshooting

Common Issues

Debugging Steps

  1. Check Server Status: Verify PraisonAI API is running
  2. Test Endpoints: Use curl to test API endpoints directly
  3. Validate Credentials: Confirm authentication tokens are correct
  4. Review Logs: Check both n8n and PraisonAI logs for errors
  5. Network Connectivity: Ensure n8n can reach PraisonAI server

n8n Integration Overview

Complete guide to n8n integration architecture and setup

n8n Tools Reference

PraisonAI tools for executing n8n workflows from agents

Visual Workflow Editor

Export and edit PraisonAI workflows in n8n’s visual interface

CLI n8n Commands

Command-line tools for n8n workflow management