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.
Supported Providers
| Provider | Models | Best For |
|---|---|---|
| Anthropic | claude-sonnet-4-20250514 (default), claude-opus-4-20250514, claude-haiku | Complex reasoning, safety, long context |
| OpenAI | gpt-4o, gpt-4o-mini, gpt-4-turbo | General 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
| Field | Type | Required | Description |
|---|---|---|---|
provider | string | Yes | "anthropic" or "openai" |
api_key | string | Yes | Provider API key (stored encrypted) |
default_model | string | No | Default model if not specified per-node |
temperature | float | No | Default temperature (0.0-1.0). Default: 0.7 |
monthly_token_budget | integer | No | Maximum tokens per month. Default: 1000000 |
max_ai_calls_per_execution | integer | No | Max AI nodes per single execution. Default: 10 |
{
"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:
| Field | Description |
|---|---|
monthly_token_budget | Maximum total tokens (input + output) allowed per calendar month |
tokens_used_this_month | Running counter of tokens consumed in the current month |
budget_reset_day | Day of month when the counter resets (default: 1st) |
Budget enforcement works as follows:
- Before each AI call, the module checks
tokens_used_this_monthagainstmonthly_token_budget - If the budget would be exceeded, the node fails with error code
budget_exceeded - After each successful call,
tokens_used_this_monthis incremented by (input_tokens + output_tokens) - 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:
| Limit | Scope | Default | Purpose |
|---|---|---|---|
| Calls per hour | Per organization | 60 | Prevent runaway workflows from draining budget |
| Calls per execution | Per workflow execution | 10 | Prevent 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 Field | Type | Required | Description |
|---|---|---|---|
prompt | string | Yes | User prompt text (supports variable interpolation) |
system_prompt | string | No | System/context prompt to set AI behavior |
model | string | No | Override default model for this node |
temperature | float | No | Override default temperature (0.0-1.0) |
max_tokens | integer | No | Maximum output tokens. Default: 1024 |
{
"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:
{
"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:
| Attempt | Delay | Applies To |
|---|---|---|
| 1st retry | 1 second | rate_limited, timeout, server_error (5xx) |
| 2nd retry | 2 seconds | rate_limited, timeout, server_error (5xx) |
| 3rd retry | 4 seconds | rate_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 Code | Description | Retryable | Resolution |
|---|---|---|---|
rate_limited | Provider API rate limit hit | Yes | Wait and retry (automatic with backoff) |
context_exceeded | Input exceeds model's context window | No | Reduce prompt length or use a model with larger context |
content_rejected | Content policy violation | No | Modify prompt to comply with provider's usage policy |
timeout | Request took longer than 60 seconds | Yes | Reduce max_tokens or simplify prompt |
budget_exceeded | Monthly token budget exhausted | No | Increase budget or wait for monthly reset |
invalid_api_key | API key rejected by provider | No | Check and update API key in module configuration |
Common Issues
| Problem | Cause | Solution |
|---|---|---|
| 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. |