Claude AI Studio icon

Claude AI Studio

Generate content using Anthropic Claude API

Overview

The Claude AI Studio node for n8n enables you to generate content using the Anthropic Claude API. Specifically, with the "Complete Message" operation, this node sends a prompt to a selected Claude model and returns the generated completion. This is useful for tasks such as text generation, summarization, creative writing, code suggestions, or any scenario where you want an AI to complete or expand upon a given message.

Practical examples:

  • Automatically drafting email responses based on a short prompt.
  • Generating product descriptions from bullet points.
  • Expanding user input into longer, more detailed text.
  • Creating summaries of provided content.

Properties

Name Type Meaning
Model options The Claude model to use for generating the completion (e.g., Opus, Sonnet, Haiku, 2.1).
Prompt string The message prompt sent to Claude; this is the main input that the model will complete.
Advanced Parameters collection Optional advanced settings to control the generation process (see below for details).

Advanced Parameters (within the collection):

Name Type Meaning
Temperature number Controls randomness in output (0 = deterministic, 1 = maximum randomness).
Top P number Nucleus sampling; considers tokens with top_p probability mass.
Maximum Output Tokens number Maximum number of tokens to generate in the response.
System Prompt string An optional system-level prompt to guide the assistant's behavior.
Response Format options Desired format of the response: Auto, JSON, or Text.
Stop Sequences string[] Comma-separated sequences that will cause the model to stop generating further output.
Stream boolean Whether to stream partial progress (not fully supported in n8n yet).

Output

The node outputs a single item per input, with the following structure in the json field:

{
  // ...original input fields,
  "claudeResponse": {
    // The full response object returned by the Claude API, including:
    // - id: Unique identifier for the completion
    // - type: Type of response
    // - role: Who generated the message (usually "assistant")
    // - content: The generated text/content
    // - model: The model used
    // - stop_reason: Why the generation stopped
    // - usage: Token usage statistics
    // ...other metadata as provided by the Claude API
  }
}
  • If binary data is ever returned (not typical for this operation), it would be included as a separate binary property, but this operation is designed for text completions.

Dependencies

  • External Service: Requires access to the Anthropic Claude API.
  • API Key: You must provide an Anthropic API key via n8n credentials (anthropicApi).
  • API Version: Optionally configurable; defaults to 2023-06-01.
  • API Endpoint: Optionally configurable; defaults to https://api.anthropic.com.

Troubleshooting

Common Issues:

  • Invalid API Key: If your API key is missing or incorrect, you'll receive an authentication error from the Claude API.
  • Model Not Supported: Using a deprecated or misspelled model name will result in an error.
  • Exceeded Quota/Rate Limit: If you exceed your API quota, the node will return an error from the Claude API.
  • Malformed Advanced Parameters: Supplying invalid values (e.g., negative numbers for token limits) may cause the API to reject the request.

Error Messages:

  • Claude API Error: <status> - <message>: Indicates an error returned by the Claude API. Check the status code and message for details (e.g., 401 Unauthorized, 400 Bad Request).
  • Error: <message>: General error, possibly due to network issues or misconfiguration.

How to resolve:

  • Double-check your API credentials and endpoint.
  • Ensure all required properties are filled and within valid ranges.
  • Review the error message for hints about what went wrong.

Links and References

Discussion