AI Agent icon

AI Agent

Agent capable of using tools, subagents, and structured output.

AI Agent

AI-generated

Overview

This node acts as a core agent for interacting with an AI model API, supporting different API modes such as chat completions and stateful/stateless responses. It allows users to configure the model, send messages with various roles, and specify the desired response format including plain text, JSON, or structured outputs. The node is useful for scenarios involving conversational AI, chatbots, or any application requiring dynamic interaction with language models.

Use Case Examples

  1. Using the node to send a user message and receive a chat completion response from an OpenAI or OpenRouter model.
  2. Configuring the node to use stateful responses to maintain conversation context across multiple interactions.
  3. Setting up structured output with a JSON schema to enforce specific response formats for downstream processing.

Properties

Name Meaning
API Mode Selects which API endpoint and format to use for the interaction, such as chat completions or responses with conversation state.
Model Specifies the AI model to use for generating responses, selectable from a list or by ID.
Messages Collection of messages to send to the model, each with a role (assistant, system, user, chat history, or chat memory) and content or JSON message array.
Response Format Defines the format of the model's output, such as plain text, JSON mode, or structured output via schema or visual editor.
Structured Output Mode Mode used to enforce structured output, including native JSON schema, tool mode, or validation modes.
Flag Extra Content Indicates if the model response contained extra text or invalid JSON alongside the extracted output.
JSON Schema Defines the JSON schema for structured output enforcement.
Structured Output Name Name of the structured output object.
Description Description for the structured output, guiding the model's response.
Array Indicates if the structured output is an array of objects.
Array Name Name of the array if structured output is an array.
Array Description Description of the array in structured output.
Properties Definitions of properties for structured output, including name, type, description, and enumeration.
Extra Outputs Additional fields to include in the output such as chat history, request, response, or usage information.
Include in Chat History Specifies what to include in the chat history such as system messages, tool calls, or reasoning.
Options Additional configuration options including retry behavior, custom headers and parameters, tool iteration limits, timeout settings, and skill tool handling.

Output

JSON

  • response - The main response generated by the AI model according to the selected response format.
  • chatHistory - The full chat history including all messages if included in extra outputs.
  • request - The HTTP request sent to the AI model API if included in extra outputs.
  • fullResponse - The complete HTTP response from the AI model API if included in extra outputs.
  • totalUsage - The total usage statistics from the AI model API if included in extra outputs.

Dependencies

  • An API key credential for OpenAI or OpenRouter to authenticate requests.

Troubleshooting

  • Ensure the API key credential is correctly configured and has necessary permissions to access the selected model.
  • If using stateful responses, verify that the previous response ID or chat memory is correctly managed to maintain conversation context.
  • Validation errors may occur if the JSON schema for structured output is invalid or does not match the model's response format; review and correct the schema accordingly.
  • Timeouts can happen if the API server is slow or unreachable; adjust the request timeout setting as needed.
  • Custom headers and parameters must be valid JSON; invalid JSON input can cause request failures.

Links

Discussion