Chat
AI-generatedSummary
Send a chat message to the Anthropic Claude model using LangChain, optionally including a system message that can be cached to reduce API costs, and receive the model's response.
Inputs
- Model — Select which Claude model to use (e.g., Claude 3.5 Sonnet, Claude 3 Opus). Defaults to Claude 3.5 Sonnet.
- Message (required) — The user message to send to Claude for the conversation.
- System Message — An optional system message to provide context or instructions to Claude. If provided, it can be cached to optimize costs. Minimum 1024 tokens recommended.
- Enable System Prompt Caching — Toggle whether to cache the system message to reduce API usage and costs. Defaults to true.
- Options — Additional parameters controlling response generation, including maximum tokens to generate, temperature for randomness, and top P for diversity.
Output shape
A list where each item contains a JSON object with keys: 'success' (boolean), 'response' (string content returned by the Claude model), 'model' (the model used), and optionally 'systemMessage' (object with content and cached status).
Each input item produces a corresponding output item. On error, the JSON includes 'success': false and an 'error' message if 'Continue On Fail' is enabled in the node settings.
Examples
Example 1: Sending a basic chat message without system prompt caching.
Set 'Model' to 'Claude 3 Opus', provide a 'Message', disable 'Enable System Prompt Caching'. The node returns the assistant's reply in 'response'.