Overview
The anthropic node provides access to Anthropic's Claude models.
Known for exceptional reasoning, long-context understanding, and nuanced analysis. Ideal for complex
data interpretation and decision support in edge computing scenarios.
Claude 3
Latest Family
200K
Context Window
Vision
Image Analysis
Safe
By Design
Properties
| Property | Type | Default | Description |
|---|---|---|---|
| apiKey | string | env | Anthropic API key |
| model | string | "claude-3-5-sonnet" | Model to use |
| systemPrompt | string | "" | System message to set context |
| temperature | number | 0.7 | Creativity (0-1) |
| maxTokens | number | 4096 | Maximum response length |
| stream | boolean | false | Stream response tokens |
Available Models
Claude 3.5 Sonnet
Best balance of speed and intelligence
200K context Vision Recommended
Claude 3 Opus
Most powerful for complex tasks
200K context Vision
Claude 3 Haiku
Fastest, most cost-effective
200K context Fastest
Inputs & Outputs
Input
// Simple message
{
"payload": "Analyze this data..."
}
// With conversation
{
"payload": "Continue analysis",
"messages": [
{ "role": "user", "content": "Initial..." },
{ "role": "assistant", "content": "Response..." }
]
} Output
{
"payload": "Claude's response...",
"usage": {
"input_tokens": 150,
"output_tokens": 300
},
"model": "claude-3-5-sonnet-20241022",
"stopReason": "end_turn"
} Example: Intelligent Anomaly Detection
Use Claude's reasoning to detect and explain anomalies in sensor data.
// Function node: Prepare anomaly analysis request
var historicalData = flow.get("sensorHistory") || [];
var currentReading = msg.payload;
// Add current reading to history
historicalData.push({
timestamp: new Date().toISOString(),
...currentReading
});
// Keep last 100 readings
if (historicalData.length > 100) {
historicalData = historicalData.slice(-100);
}
flow.set("sensorHistory", historicalData);
msg.payload = `Analyze this time-series sensor data for anomalies:
Current reading:
${JSON.stringify(currentReading, null, 2)}
Historical context (last ${historicalData.length} readings):
${JSON.stringify(historicalData.slice(-10), null, 2)}
Statistical summary:
- Average temperature: ${calculateAverage(historicalData, 'temperature').toFixed(2)}°C
- Std deviation: ${calculateStdDev(historicalData, 'temperature').toFixed(2)}
Identify if the current reading is anomalous and explain why.`;
msg.systemPrompt = `You are an IoT anomaly detection expert. Analyze sensor data
and identify anomalies with clear reasoning. Consider seasonal patterns,
sudden spikes, gradual drifts, and correlation between sensors.`;
return msg; Example: Natural Language Device Control
Convert natural language to device commands using Claude.
// Function node: Parse natural language command
msg.systemPrompt = `You are an IoT command parser. Convert natural language to JSON commands.
Available devices: living_room_light, bedroom_thermostat, kitchen_fan
Available actions: on, off, set_temperature, set_speed, dim
Output JSON only, no explanation. Format:
{"device": "device_name", "action": "action", "value": optional_value}`;
msg.payload = msg.payload.text; // "Turn on the living room light and set bedroom to 72 degrees"
msg.temperature = 0; // Deterministic output
return msg;
// After Claude response, parse the JSON:
// Function node: Execute commands
var commands = JSON.parse(msg.payload);
commands.forEach(function(cmd) {
node.send({ topic: cmd.device, payload: cmd });
}); Tool Use (Function Calling)
Enable Claude to call functions/tools for enhanced capabilities.
// Configure tools in the node
msg.tools = [
{
name: "get_sensor_reading",
description: "Get the current reading from a specific sensor",
input_schema: {
type: "object",
properties: {
sensor_id: {
type: "string",
description: "The sensor identifier"
}
},
required: ["sensor_id"]
}
},
{
name: "set_device_state",
description: "Control a smart device",
input_schema: {
type: "object",
properties: {
device_id: { type: "string" },
state: { type: "boolean" }
},
required: ["device_id", "state"]
}
}
];
msg.payload = "What's the temperature in the living room?";
return msg;