# n8n-nodes-claude-vision

[![npm version](https://badge.fury.io/js/n8n-nodes-claude-vision.svg)](https://badge.fury.io/js/n8n-nodes-claude-vision)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

An n8n community node that brings **Claude's powerful vision capabilities** directly to your workflows. Analyze images using Claude AI models with ease.

![n8n Claude Vision Node](https://raw.githubusercontent.com/your-username/n8n-nodes-claude-vision/main/docs/banner.png)

## 🚀 Features

### 🤖 Claude Vision Node
- **Multiple Claude Models** - Support for Claude 3 Opus, Claude 3 Sonnet, Claude Sonnet 4, and Claude Haiku 4
- **Image Analysis** - Analyze multiple images from URLs
- **Custom System Prompts** - Tailor Claude's behavior with custom instructions
- **Secure API Integration** - Uses Claude's official API with encrypted token storage
- **Flexible Input** - Accept comma-separated image URLs
- **Built-in Comparison** - Automatically asks "How are these images different?" for multiple images

## 📦 Installation

### Option 1: n8n Community Nodes (Recommended)
1. Open your n8n instance
2. Go to **Settings** → **Community Nodes**
3. Click **Install** and enter: `n8n-nodes-claude-vision`
4. Click **Install**
5. Restart n8n

### Option 2: Manual Installation
```bash
# Navigate to your n8n installation directory
cd ~/.n8n

# Install the package
npm install n8n-nodes-claude-vision

# Restart n8n
```

### Option 3: Docker
Add to your `Dockerfile`:
```dockerfile
RUN cd /usr/local/lib/node_modules/n8n && npm install n8n-nodes-claude-vision
```

## 🔑 Setup

### 1. Get Claude API Token
1. Sign up at [Claude.ai](https://claude.ai)
2. Go to your account settings
3. Generate an API key
4. Copy the key for use in n8n

### 2. Create Claude API Credential
1. In n8n, go to **Settings** → **Credentials**
2. Click **Add Credential** → **Claude API**
3. Enter your API token
4. Save the credential

## 🏃‍♂️ Quick Start

### 1. Basic Image Analysis
Analyze a single image:

1. **Add Claude Vision** node to your workflow
2. **Configure the node:**
   - Model: `Claude Sonnet 4 20250514`
   - System Prompt: `Describe what you see in this image in detail.`
   - Image URLs: `https://example.com/image.jpg`
3. **Connect your credential**
4. **Execute** the workflow

### 2. Compare Multiple Images
Compare differences between images:

1. **Add Claude Vision** node
2. **Configure with multiple URLs:**
   - Image URLs: `https://example.com/image1.jpg, https://example.com/image2.jpg`
   - System Prompt: `Focus on the key differences between these images.`
3. Claude will automatically analyze differences

### 3. Process Workflow Images
Use with other nodes that generate image URLs:

```
HTTP Request → Extract URLs → Claude Vision → Process Results
```

## 🔧 Configuration

### Node Settings

| Setting | Description | Required |
|---------|-------------|----------|
| **Model** | Claude model to use for analysis | Yes |
| **System Prompt** | Custom instructions for Claude | No |
| **Image URLs** | Comma-separated list of image URLs | Yes |

### Supported Models

| Model | Code | Best For |
|-------|------|----------|
| **Claude 3 Opus** | `claude-3-opus-20240229` | Most capable, complex analysis |
| **Claude 3 Sonnet** | `claude-3-sonnet-20240229` | Balanced performance and speed |
| **Claude Sonnet 4** | `claude-sonnet-4-20250514` | Latest Sonnet with improved capabilities |
| **Claude Haiku 4** | `claude-haiku-4-20250514` | Fastest, simple analysis |

## 📖 Usage Examples

### Image Content Moderation
```
Webhook → Claude Vision → If Node → Send Alert
```
Automatically moderate uploaded images for inappropriate content.

### Product Catalog Analysis
```
Database → Claude Vision → Update Description → Save to Database
```
Automatically generate product descriptions from images.

### Document Processing
```
File Trigger → Claude Vision → Extract Text → Process Data
```
Extract and process text from document images.

### Quality Control
```
IoT Camera → Claude Vision → Check Quality → Notify Team
```
Automated quality control using image analysis.

## 💡 Example System Prompts

### Product Description
```
You are a product catalog expert. Describe this product image in a way that would appeal to online shoppers. Include details about color, style, materials, and key features. Keep it concise but compelling.
```

### Content Moderation
```
Analyze this image for any inappropriate content including violence, nudity, offensive symbols, or harmful activities. Respond with only "SAFE" or "FLAGGED" followed by a brief reason if flagged.
```

### Technical Documentation
```
You are a technical writer. Describe any diagrams, charts, or technical elements in this image. Focus on accuracy and include any visible text, numbers, or labels.
```

### Accessibility
```
Describe this image in detail for someone who cannot see it. Include all important visual elements, text, colors, and context that would help them understand the content.
```

## 🔒 Security

### API Token Storage
- Tokens are stored encrypted in n8n's credential system
- Never exposed in workflow logs or exports
- Access controlled by n8n's user permissions

### Image URL Requirements
- Must be publicly accessible URLs
- HTTPS recommended for security
- Supported formats: JPG, PNG, GIF, WebP

### Rate Limiting
- Respects Claude API rate limits
- Consider implementing delays for batch processing
- Monitor usage in your Claude dashboard

## 🚨 Troubleshooting

### Common Issues

**❌ "Invalid API token"**
- Verify token is correct and active
- Check if token has proper permissions
- Ensure credential is properly configured

**❌ "Image not accessible"**
- Verify URLs are publicly accessible
- Check image format is supported
- Ensure images are not too large (check Claude's limits)

**❌ "Rate limit exceeded"**
- Implement delays between requests
- Consider using lower-tier models for simple tasks
- Monitor your API usage

**❌ "Model not available"**
- Check if the model name is correct
- Verify your account has access to the model
- Try with a different model

### Debug Tips
- Enable n8n's debug mode for detailed logs
- Test with simple single-image requests first
- Verify image URLs in browser before using
- Check Claude API status page for service issues

## 📊 Node Output

### Successful Response
```json
{
  "id": "msg_123456",
  "type": "message",
  "role": "assistant",
  "content": [
    {
      "type": "text",
      "text": "I can see two images showing different seasonal views of the same landscape. The first image shows..."
    }
  ],
  "model": "claude-sonnet-4-20250514",
  "stop_reason": "end_turn",
  "usage": {
    "input_tokens": 1234,
    "output_tokens": 567
  }
}
```

### Error Response
```json
{
  "error": {
    "type": "invalid_request_error",
    "message": "Invalid image URL"
  }
}
```

## 🛠️ Development

### Building from Source
```bash
git clone https://github.com/your-username/n8n-nodes-claude-vision.git
cd n8n-nodes-claude-vision
npm install
npm run build
```

### Local Testing
```bash
# Build and link locally
npm run build
npm link

# In your n8n project
npm link n8n-nodes-claude-vision
```

## 📝 Workflow Templates

### Image Analysis Pipeline
```json
{
  "name": "Image Analysis Pipeline",
  "nodes": [
    {
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook"
    },
    {
      "name": "Claude Vision",
      "type": "n8n-nodes-claude-vision.claudeVision"
    },
    {
      "name": "Process Results",
      "type": "n8n-nodes-base.code"
    }
  ]
}
```

## 🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

1. Fork the repository
2. Create your feature branch: `git checkout -b feature/amazing-feature`
3. Commit your changes: `git commit -m 'Add amazing feature'`
4. Push to the branch: `git push origin feature/amazing-feature`
5. Open a Pull Request

## 📝 License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## 🆘 Support

- 📖 **Documentation**: [GitHub Wiki](https://github.com/your-username/n8n-nodes-claude-vision/wiki)
- 🐛 **Bug Reports**: [GitHub Issues](https://github.com/your-username/n8n-nodes-claude-vision/issues)
- 💬 **Discussions**: [GitHub Discussions](https://github.com/your-username/n8n-nodes-claude-vision/discussions)
- 📧 **Claude API**: [Official Documentation](https://docs.anthropic.com/)

## 🎯 Roadmap

- [ ] Support for local file uploads
- [ ] Batch processing capabilities
- [ ] Custom image preprocessing options
- [ ] Integration with other AI vision models
- [ ] Advanced prompt templates library
- [ ] Cost tracking and optimization features

## 📚 Related

- [Claude API Documentation](https://docs.anthropic.com/)
- [n8n Community Nodes](https://docs.n8n.io/integrations/community-nodes/)
- [n8n Node Development](https://docs.n8n.io/integrations/creating-nodes/)

---

**Made with ❤️ for the [n8n](https://n8n.io) community**

*⭐ If this package helped you, please give it a star on [GitHub](https://github.com/your-username/n8n-nodes-claude-vision)!*