AI Module

Integrate Claude (Anthropic) and GPT (OpenAI) into your workflows for text generation, classification, extraction, and summarization — with budget controls and intelligent retry logic.

Module Anthropic Claude OpenAI GPT Token Budget

Supported Providers

ProviderModelsBest For
Anthropicclaude-sonnet-4-20250514 (default), claude-opus-4-20250514, claude-haikuComplex reasoning, safety, long context
OpenAIgpt-4o, gpt-4o-mini, gpt-4-turboGeneral purpose, vision, function calling

Default Model

If no model is specified in the node configuration, the module uses claude-sonnet-4-20250514 as the default. This provides an excellent balance of quality, speed, and cost.

Configuration

FieldTypeRequiredDescription
providerstringYes"anthropic" or "openai"
api_keystringYesProvider API key (stored encrypted)
default_modelstringNoDefault model if not specified per-node
temperaturefloatNoDefault temperature (0.0-1.0). Default: 0.7
monthly_token_budgetintegerNoMaximum tokens per month. Default: 1000000
max_ai_calls_per_executionintegerNoMax AI nodes per single execution. Default: 10
JSON — Module Configuration Example
{
  "provider": "anthropic",
  "api_key": "sk-ant-api03-xxxxxxxxxxxxxxxxxxxxxxxxx",
  "default_model": "claude-sonnet-4-20250514",
  "temperature": 0.7,
  "monthly_token_budget": 500000,
  "max_ai_calls_per_execution": 5
}

Budget Management

The AI Module includes built-in token budget management to prevent unexpected costs:

FieldDescription
monthly_token_budgetMaximum total tokens (input + output) allowed per calendar month
tokens_used_this_monthRunning counter of tokens consumed in the current month
budget_reset_dayDay of month when the counter resets (default: 1st)

Budget enforcement works as follows:

  1. Before each AI call, the module checks tokens_used_this_month against monthly_token_budget
  2. If the budget would be exceeded, the node fails with error code budget_exceeded
  3. After each successful call, tokens_used_this_month is incremented by (input_tokens + output_tokens)
  4. On the first day of each month (or configured reset day), a scheduled job resets the counter to 0

Budget Is Per-Organization

The token budget is tracked per organization. If multiple workflows in the same organization use AI nodes, they share the same budget pool. Monitor usage in Settings → Modules → AI → Usage.

Rate Limiting

The AI Module applies two layers of rate limiting:

LimitScopeDefaultPurpose
Calls per hourPer organization60Prevent runaway workflows from draining budget
Calls per executionPer workflow execution10Prevent infinite loops with AI nodes

When either limit is hit, the node fails with error code rate_limited and the execution step records which limit was exceeded.

Node Type: action.ai.prompt

Config FieldTypeRequiredDescription
promptstringYesUser prompt text (supports variable interpolation)
system_promptstringNoSystem/context prompt to set AI behavior
modelstringNoOverride default model for this node
temperaturefloatNoOverride default temperature (0.0-1.0)
max_tokensintegerNoMaximum output tokens. Default: 1024
JSON — AI Node Configuration Example
{
  "type": "action.ai.prompt",
  "config": {
    "system_prompt": "You are a customer support classifier. Categorize the message into: billing, technical, general, or urgent. Respond with only the category name.",
    "prompt": "Classify this customer message:\n\n{{trigger.message}}",
    "model": "claude-sonnet-4-20250514",
    "temperature": 0.1,
    "max_tokens": 50
  }
}

The node output contains:

JSON — Node Output
{
  "response": "technical",
  "model": "claude-sonnet-4-20250514",
  "input_tokens": 45,
  "output_tokens": 3,
  "total_tokens": 48
}

Retry Logic

The AI Module implements exponential backoff for transient errors:

AttemptDelayApplies To
1st retry1 secondrate_limited, timeout, server_error (5xx)
2nd retry2 secondsrate_limited, timeout, server_error (5xx)
3rd retry4 secondsrate_limited, timeout, server_error (5xx)

Never Retried

The error content_rejected (content policy violation) is never retried. The same prompt will produce the same rejection. The node fails immediately with a clear error message.

Error Codes

Error CodeDescriptionRetryableResolution
rate_limitedProvider API rate limit hitYesWait and retry (automatic with backoff)
context_exceededInput exceeds model's context windowNoReduce prompt length or use a model with larger context
content_rejectedContent policy violationNoModify prompt to comply with provider's usage policy
timeoutRequest took longer than 60 secondsYesReduce max_tokens or simplify prompt
budget_exceededMonthly token budget exhaustedNoIncrease budget or wait for monthly reset
invalid_api_keyAPI key rejected by providerNoCheck and update API key in module configuration

Common Issues

ProblemCauseSolution
API key invalid Key expired, revoked, or incorrectly entered Generate a new key from the provider dashboard. Ensure no leading/trailing whitespace.
Budget exceeded Monthly token budget consumed Increase monthly_token_budget in module config, or wait for the monthly reset.
Context too long Prompt + variable interpolation exceeds model context Truncate large inputs before passing to AI. Use a model with larger context (e.g., Claude with 200k).
Slow responses High max_tokens or complex prompt Reduce max_tokens. Use a faster model (e.g., claude-haiku or gpt-4o-mini).
Content rejected Prompt or output violates usage policy Rephrase prompt. Add guardrails in system_prompt. This error is never retried.