AI Agent Node Guide

Complete guide to using AI-powered nodes with OpenAI, Claude, Gemini, and Ollama

Using the AI Agent Node

The AI Agent Node is your gateway to powerful AI models. Think of it as having access to multiple AI assistants (OpenAI's GPT models, Anthropic's Claude, Google's Gemini, or local Ollama models) all in one node. You can send prompts, get responses, and even let the AI call functions to get information it needs.

Status: Production-Ready ✅ Version: 2.0 Last Updated: November 2025

What You Can Do

  • Chat with AI — Send questions, get intelligent responses
  • Use Different Models — Switch between GPT-4, Claude, Gemini, or local Ollama models
  • Let AI Call Tools — Enable tool calling so AI can request functions (weather data, database lookups, etc.)
  • Keep Conversation History — Enable memory so the AI remembers previous messages
  • Cache Responses — Avoid paying twice for the same prompt
  • Track Costs — See exactly how much each AI request costs
  • Fallback Providers — If one provider fails, automatically try another

Let's dive in!

Quick Start: Send Your First Prompt

Here's the simplest setup to get started:

  1. Add the AI Agent Node to your workflow
  2. Choose a provider (OpenAI, Anthropic, Google, or Ollama)
  3. Pick a model (GPT-4o, Claude Sonnet, Gemini 1.5, etc.)
  4. Add your API key (not needed for Ollama if running locally)
  5. Connect your prompt from a previous node or trigger
  6. Run it!

That's it. You'll get back the AI's response.

Tip: Start with a simple model like GPT-3.5-turbo or Claude Haiku to test. They're cheaper and usually fast enough.

Choosing the Right Provider

Different AI providers have different strengths, costs, and speeds. Here's how to pick:

Provider Best For Cost Speed Examples
OpenAI General purpose, most capable $ - $$$$ Medium GPT-4o, GPT-4, GPT-3.5-turbo
Anthropic Long documents, reasoning, safety $$ - $$$ Medium Claude Opus, Claude Sonnet, Claude Haiku
Google Fast, budget-friendly, multimodal $ - $$ Fast Gemini 1.5 Pro, Gemini 1.5 Flash
Ollama Local, free, no API calls FREE Depends on hardware Llama 2, Mistral, CodeLlama

Cost Breakdown

OpenAI Pricing (per 1 million tokens):

GPT-4o:          $2.50 input / $10.00 output
GPT-4 Turbo:    $10.00 input / $30.00 output
GPT-3.5-turbo:   $0.50 input / $1.50 output

Anthropic (Claude) Pricing (per 1 million tokens):

Claude Opus:      $15.00 input / $75.00 output
Claude Sonnet:     $3.00 input / $15.00 output
Claude Haiku:      $0.25 input / $1.25 output

Google (Gemini) Pricing (per 1 million tokens):

Gemini 1.5 Pro:    $1.25 input / $5.00 output
Gemini 1.5 Flash:  $0.075 input / $0.30 output

Ollama: FREE (runs on your machine)

Cost Tip: For development and testing, use cheaper models (GPT-3.5-turbo, Claude Haiku, Gemini Flash). Save expensive models (GPT-4, Claude Opus) for production.

Configuration Options

Here's everything you can configure on the AI Agent Node:

Basic Settings

provider: "openai"                    # Which AI service (openai, anthropic, google, ollama)
model: "gpt-4o"                       # Which model/version
credentialId: "cred-abc123"           # Your API key (not needed for Ollama)

Prompt Control

systemInstructions: "You are a helpful assistant"  # The AI's personality
maxTokens: 2048                                    # Max output length
temperature: 0.7                                  # Randomness (0=deterministic, 2=creative)
topP: 1.0                                         # Nucleus sampling
presencePenalty: 0.0                             # Avoid repeating topics
frequencyPenalty: 0.0                            # Avoid repeating words

Advanced Features

enableMemory: true                    # Remember previous messages
maxMemoryMessages: 20                 # Keep last 20 messages
enableCaching: true                   # Cache responses
cacheTTL: 3600                        # Cache for 1 hour
enableTools: true                     # Allow AI to call functions
maxIterations: 5                       # Max tool-calling loops
maxCost: 0.10                        # Stop if cost exceeds $0.10
fallbackProviders:                    # Backup providers if primary fails
  - provider: "anthropic"
    model: "claude-3-5-sonnet-20241022"

Using Tool Calling (Advanced)

Want the AI to get information by calling functions? That's tool calling. Here's how it works:

The Tool Calling Flow

  1. You enable tools on the AI Agent Node
  2. You provide tool definitions (what functions the AI can call)
  3. AI sees a prompt and decides if it needs to call a tool
  4. AI requests the tool (e.g., "call get_weather with location=NYC")
  5. Your workflow executes the tool and gets the result
  6. AI gets the result and can call more tools or respond
  7. Loop repeats up to 5 times (configurable)
  8. AI gives final answer using all the tool results

Example: Weather Workflow

Let's say you want the AI to answer "What's the weather in NYC?"

AI Agent Node (Enabled Tools):
  Input Prompt: "What's the weather in New York City?"
  Tools Available: [get_weather]

AI's Thought Process:
  "I need weather data. I'll call get_weather with location='New York City'"

Tool Execution:
  get_weather("New York City")  { temp: 72, condition: "Sunny" }

AI's Response:
  "It's 72 degrees and sunny in New York City."

Defining Tools

Each tool needs a name, description, and parameters:

tool:
  name: "get_weather"
  description: "Get current weather for a location"
  parameters:
    type: "object"
    properties:
      location:
        type: "string"
        description: "City name or coordinates"
      units:
        type: "string"
        enum: ["celsius", "fahrenheit"]
        description: "Temperature units"

Tip: Clear descriptions help the AI understand when to use each tool. Be specific!

Real-World Examples

Example 1: Customer Support Bot

  • Tools: lookup_customer, check_order_status, process_refund
  • User asks: "Where's my order?"
  • AI: Calls lookup_customercheck_order_status → responds with tracking info

Example 2: Data Analysis

  • Tools: query_database, calculate_statistics, format_report
  • User asks: "What were last month's sales?"
  • AI: Calls query_databasecalculate_statistics → gives summary

Example 3: Code Assistant

  • Tools: read_file, execute_code, list_directory
  • User asks: "What's in src/main.py?"
  • AI: Calls read_file → explains the code

Provider Support Details

Each provider works similarly but with slight format differences. The good news: DeepChain handles all the format conversion for you!

OpenAI (GPT Models)

Available Models:

  • gpt-4o — Latest, fastest, most capable
  • gpt-4-turbo — Good balance of power and cost
  • gpt-3.5-turbo — Budget-friendly

Example Configuration:

provider: "openai"
model: "gpt-4o"
credentialId: "your-openai-key"
systemInstructions: "You are a helpful assistant"

Anthropic (Claude Models)

Available Models:

  • claude-3-5-sonnet-20241022 — Best all-rounder
  • claude-3-opus — Most powerful for complex tasks
  • claude-3-haiku — Fastest and cheapest

Example Configuration:

provider: "anthropic"
model: "claude-3-5-sonnet-20241022"
credentialId: "your-anthropic-key"
maxTokens: 4096

Google (Gemini Models)

Available Models:

  • gemini-1.5-pro — Most capable
  • gemini-1.5-flash — Fastest and cheapest
  • gemini-1.0-pro — Older but still good

Example Configuration:

provider: "google"
model: "gemini-1.5-pro"
credentialId: "your-google-key"

Ollama (Local Models)

Run AI models locally without any API calls or costs!

Available Models:

  • llama2 — General purpose
  • mistral — Fast and accurate
  • neural-chat — Optimized for conversation
  • codellama — Great for programming

Example Configuration:

provider: "ollama"
model: "llama2"
# No credentialId needed - runs on your machine!

Local = Free: Ollama lets you run models on your own computer. No API costs, no data sent to external servers. Perfect for private/sensitive data.

Cost Tracking & Budget Control

Every time you run an AI Agent Node, it tracks:

  • Tokens used (how much "text" was processed)
  • Cost (calculated based on provider pricing)
  • Number of requests (useful for tool calling loops)

The node outputs all this data so you can monitor costs in real-time.

Example Cost Output

{
  "totalPromptTokens": 1250,
  "totalCompletionTokens": 380,
  "totalTokens": 1630,
  "totalCost": 0.00725,
  "requestCount": 3
}

Setting a Cost Budget

Don't want runaway AI bills? Set a maximum cost:

maxCost: 0.10  # Stop if this execution costs more than $0.10

Tip: Set maxCost for production workflows. If the AI makes too many tool calls, it'll stop before breaking your budget.

Conversation Memory

Remember previous messages in a conversation? Enable memory:

enableMemory: true
memoryKey: "user_123"  # Unique identifier for this conversation
maxMemoryMessages: 20  # Keep last 20 messages to save tokens

The AI will remember previous messages and use that context. Perfect for chatbots where the AI needs conversation history.

How It Works

  1. First message: User asks "My name is Alice"
  2. AI responds and message is saved
  3. Second message: User asks "What's my name?"
  4. AI remembers from step 1 and answers "Alice"

Response Caching

Avoid paying for the same question twice:

enableCaching: true
cacheTTL: 3600  # Cache results for 1 hour

If someone asks the same thing twice within the cache period, you get instant results without paying again.

Fallback Providers

What if your primary AI provider goes down? Have a backup:

provider: "openai"
model: "gpt-4o"
fallbackProviders:
  - provider: "anthropic"
    model: "claude-3-5-sonnet-20241022"
  - provider: "ollama"
    model: "llama2"

DeepChain tries OpenAI first. If that fails, it automatically tries Claude. If Claude fails, it tries Ollama. Your workflow keeps running!

Best Practices

Choose the Right Model for Your Task

# Cheap & fast (for simple tasks)
model: "gpt-3.5-turbo"    # or gemini-1.5-flash

# Balanced (default choice)
model: "gpt-4o"           # or claude-3-sonnet

# Most powerful (for complex reasoning)
model: "gpt-4"            # or claude-3-opus

Set Cost Budgets in Production

maxCost: 0.50  # Maximum per execution

Use Memory for Conversations

enableMemory: true
memoryKey: "{{ $trigger.userId }}"  # Unique per user
maxMemoryMessages: 10  # Balance context with cost

Cache Repeated Requests

enableCaching: true
cacheTTL: 3600  # 1 hour

Have Fallback Providers

Always have a backup, especially for critical workflows:

fallbackProviders:
  - provider: "anthropic"
    model: "claude-3-5-sonnet-20241022"

Troubleshooting

"API key invalid"

  • Double-check your credential is correct
  • Make sure credential is for the right provider
  • Verify the key hasn't expired

"Cost budget exceeded"

  • Check your recent AI requests
  • Increase maxCost if needed
  • Reduce maxIterations for tool calling

"Slow responses"

  • Use a faster model: gpt-3.5-turbo or gemini-1.5-flash
  • Check provider status (is OpenAI/Google/etc down?)
  • Reduce maxTokens if you're getting long outputs

"Tool calling not working"

  • Enable enableTools: true
  • Connect tool definitions to the tools input port
  • Verify tool descriptions are clear
  • Check tool parameter definitions are correct

Next Steps

  • Try tool calling: Create a workflow that uses get_weather or similar
  • Add memory: Build a chatbot with conversation history
  • Set budgets: Use maxCost to control spending
  • Test providers: Compare responses from different models
  • Optimize costs: Use cheaper models for simple tasks

Resources: