AnthropicAiQuery@1
Node AnthropicAiQuery@1
is used to query Claude (Anthropic AI) to extract or analyze information from data in the pipeline. This node sends data to Claude's API and can extract structured information, answer questions, or transform content based on AI analysis.
Adapter Prerequisites
Node Configuration
For fields path
, targetPath
, targetValueWriteMode
, and targetValueKind
, see Overview.
transformations:
- type: AnthropicAiQuery@1
path: $.ExtractedText # The path to the main content to analyze
targetPath: $.AiExtractedData # The path where the AI response will be stored
targetValueWriteMode: Overwrite # The target value write mode
targetValueKind: Simple # The target value kind
apiKey: "sk-ant-api03-..." # The Anthropic API key for authentication
model: "claude-3-5-sonnet-20241022" # The Claude model to use (e.g., "claude-3-5-sonnet-20241022", "claude-3-haiku-20240307")
question: "Extract invoice details from this document" # The question/prompt to ask the AI about the data
dataPaths: # Optional additional context data paths to include in the query
- $.DocumentMetadata
- $.AdditionalContext
systemPrompt: "You are a helpful AI assistant that extracts specific information from documents. Always provide accurate, structured responses based only on the information provided." # System prompt to set the context for the AI
maxTokens: 1000 # Maximum tokens for the response (default: 1000)
temperature: 0.1 # Temperature for response generation (0.0 to 1.0, default: 0.1)
responseFormat: "json" # Expected response format ("json" or "text", default: "json")
includeRawResponse: false # Whether to include the raw AI response in the output (default: false)
rawResponseOutputPath: $.RawAiResponse # Output path for the raw AI response if includeRawResponse is true
continueOnError: false # Whether to continue processing if the AI query fails (default: false)
jsonFormatSample: | # Sample JSON format for structured responses
{
"transactionDate": "2024-01-15",
"companyAddress": "Main St, City, Country",
"grossTotal": 1200.00,
"netTotal": 1000.00,
"taxAmount": 200.00
}
Configuration Parameters
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
apiKey | string | Yes | - | The Anthropic API key for authentication |
model | string | No | claude-sonnet-4-20250514 | The Claude model to use |
question | string | Yes | - | The question/prompt to ask the AI about the data |
dataPaths | string[] | No | - | Additional context data paths to include in the query |
systemPrompt | string | No | Default system prompt | System prompt to set the context for the AI |
maxTokens | int | No | 1000 | Maximum tokens for the response |
temperature | double | No | 0.1 | Temperature for response generation (0.0 to 1.0) |
responseFormat | string | No | json | Expected response format (json or text ) |
includeRawResponse | bool | No | false | Whether to include the raw AI response |
rawResponseOutputPath | string | No | $.RawAiResponse | Output path for the raw AI response |
continueOnError | bool | No | false | Whether to continue processing if the query fails |
jsonFormatSample | string | No | Sample JSON | Sample JSON format for structured responses |
Response Processing
The node processes Claude's response based on the responseFormat
parameter:
- JSON format: The node attempts to parse the response as JSON. If the response contains mixed content (explanatory text with embedded JSON), it will extract and parse the JSON portion.
- Text format: The response is returned as plain text.
Context Limitations
The total context (main content plus additional data paths) is limited to 3000 characters. If the combined context exceeds this limit, the node will throw an error.
Error Handling
- If
continueOnError
is set tofalse
(default), the pipeline will stop if the AI query fails - If
continueOnError
is set totrue
, errors will be logged but the pipeline will continue - Common errors include: missing required fields, API authentication failures, context size exceeded, and invalid JSON parsing
Example: Extract Invoice Data
triggers:
- type: FromHttpRequest@1
path: /extract/invoice
method: POST
transformations:
- type: AnthropicAiQuery@1
path: $.documentText
targetPath: $.extractedInvoiceData
apiKey: "sk-ant-api03-..."
question: "Extract the following from this invoice: invoice number, date, total amount, vendor name, and all line items"
responseFormat: "json"
jsonFormatSample: |
{
"invoiceNumber": "INV-001",
"date": "2024-01-15",
"totalAmount": 1500.00,
"vendorName": "ABC Company",
"lineItems": [
{
"description": "Product A",
"quantity": 2,
"unitPrice": 500.00,
"total": 1000.00
}
]
}
Example: Analyze Document with Additional Context
transformations:
- type: AnthropicAiQuery@1
path: $.mainDocument
targetPath: $.analysis
apiKey: "sk-ant-api03-..."
question: "Analyze this document and identify any compliance issues based on the provided regulations"
dataPaths:
- $.regulatoryContext
- $.previousAnalysis
systemPrompt: "You are a compliance expert. Analyze documents for regulatory compliance issues."
maxTokens: 2000
responseFormat: "json"
includeRawResponse: true
rawResponseOutputPath: $.rawAnalysis
Available Models
Common Claude models include:
claude-3-5-sonnet-20241022
- Most capable, balanced performanceclaude-3-haiku-20240307
- Fastest, most cost-effectiveclaude-opus-4-1-20250805
- Most powerful for complex tasksclaude-sonnet-4-20250514
- Latest Sonnet model (default)
Refer to Anthropic's documentation for the latest model information and capabilities.