PI OpenRouter Pro v4
AI-generatedOverview
This node integrates with the OpenRouter Chat Completions API to generate chat-based completions using multimodal prompts, structured outputs, and usage tracking. It supports various input message types including text, images (binary or URL), audio, and video, allowing users to create complex chat interactions. The node is useful for workflows requiring AI-driven chat responses, such as customer support automation, conversational agents, or content generation with advanced prompt customization and caching options.
Use Case Examples
- A customer support workflow where user queries are sent to the OpenRouter API and AI-generated responses are returned.
- A content creation pipeline that uses structured prompts and templates to generate text or multimedia chat completions.
- A chatbot that processes images or videos as part of the conversation and returns AI-generated insights or replies.
Properties
| Name | Meaning |
|---|---|
| Source for Prompt (User Message) | Determines the source of the user prompt, either from a connected Chat Trigger node, a connected Guardrails node, or a manually defined prompt. |
| Prompt (User Message) | The actual user message text to send as the prompt. Its default value depends on the selected prompt source. |
| Model Name or ID | Selects the AI model to use for generating the chat completion. Models can be chosen from a dropdown or specified by expression. |
| Temperature | Controls the randomness of the AI output. Higher values produce more random results. |
| Max Output Tokens | Maximum number of tokens to generate in the response. |
| Advanced Parameters | Additional parameters to customize the chat completion request, including caching options, penalties, seed, stop sequences, and sampling controls. |
| Enable Usage Tracking | Whether to include usage and cost metadata in the API response. |
| Prompt Templates | Optional system and user prompt templates that can be used to predefine messages before the main prompt. |
| Messages | Additional system, user, or assistant messages to include in the chat completion request, supporting text, images (binary or URL), audio, and video. |
| Enable Structured Output | Defines if the response should be formatted in a structured way, such as plain text, JSON object, or JSON schema. |
| Response Format Type | Specifies the type of structured output when enabled. |
| Usage & Cost Tracking | Options to customize which usage metrics to include and whether to return cost breakdowns or token counts. |
| Output Mode | Determines the format of the node's output, such as full API response, first completion text, structured JSON message, or usage summary. |
| Advanced Options | Additional advanced settings including logit bias, metadata, parallel tool calls, reasoning effort, response modifiers, streaming, and tool choice. |
Output
JSON
text- Text of the first completion choice when output mode is 'First Completion Text'.structuredJson- Structured JSON content of the first completion message when output mode is 'Structured JSON Message'.usage- Usage and cost metadata when output mode is 'Usage Summary'.raw- Full API response JSON when output mode is 'Full Response'.
Dependencies
- OpenRouter API
Troubleshooting
- Ensure a valid model is selected from the dropdown; an empty or invalid model ID will cause errors.
- If using JSON schema for structured output, provide a valid JSON schema object; invalid JSON will cause parsing errors.
- Binary properties referenced in messages must exist in the input data; missing binary data will cause errors.
- Streaming responses can only be used with 'Full Response' output mode; using streaming with other modes will throw an error.
- Check API credentials and network connectivity if model loading or API requests fail.
Links
- n8n Expressions Documentation - Guide on using expressions in n8n for dynamic parameter values.
- OpenRouter API Documentation - Official documentation for the OpenRouter API used by this node.