Anthropic Claude API Connection

function

A Secure Anthropic Claude API Pipeline

1337hero
@1337hero
Β·
a year ago
270
3
3.4K
Updated a year ago
Created Nov 13, 2025
anthropic_claude_api_connection.py
Python Β· 454 lines
"""
title: Anthropic Claude API
author: 1337Hero (Mike Key)
version: 2.1.0
license: MIT
required_open_webui_version: 0.5.0
requirements: requests>=2.31.0

A clean, simple Anthropic Claude integration that does exactly what's needed.
Security by default, not security theater.

Features:

Anthropic Claude API Pipeline

What's New in v2.1

πŸš€ Dynamic Model List - Now automatically fetches available models from Anthropic's API
πŸ”„ Auto-Refresh - Model list updates hourly (configurable)
πŸ›‘οΈ Graceful Fallback - Uses cached/fallback models if API is unavailable

No more waiting for pipeline updates when Anthropic releases new models!

Overview

A clean, secure Anthropic Claude integration for Open WebUI. Built with DHH-inspired principles: simple, expressive, and secure by defaultβ€”not security
theater.

This pipeline provides seamless access to all Claude models with essential security features and zero configuration overhead.

Supported Models

Models are automatically fetched from Anthropic's /v1/models API. New models are picked up automatically when Anthropic releases them.

Fallback Models (used if API unavailable)

  • claude-sonnet-4-5 - Best balance of intelligence, speed, and cost
  • claude-haiku-4-5 - Fastest responses with near-frontier intelligence
  • claude-opus-4-1 - Specialized reasoning for complex tasks
  • claude-3-7-sonnet - Enhanced capabilities with extended thinking
  • claude-3-5-sonnet - Strong general-purpose model
  • claude-3-5-haiku - Fast and cost-effective
  • claude-3-opus - Previous generation flagship
  • claude-3-sonnet - Balanced performance
  • claude-3-haiku - Speed-optimized

Features

Security (Real Protection, Not Theater)

βœ… SSRF Protection - Validates URLs, blocks private networks and metadata endpoints
βœ… Input Validation - Prevents crashes from malformed data
βœ… Secure Error Handling - User-friendly messages, no information disclosure
βœ… Image Size Validation - Enforces Anthropic's 5MB limit per image

Core Functionality

βœ… Dynamic Model List - Auto-fetches available models from Anthropic's API
βœ… Auto-Refresh - Configurable refresh interval (default: 1 hour)
βœ… Streaming Support - Real-time response streaming
βœ… Multimodal - Text and image processing
βœ… Retry Logic - Automatic retry with exponential backoff
βœ… Graceful Fallback - Uses cached/fallback models if API is unavailable

Configuration

Simple Configuration (Two Valves)

  • ANTHROPIC_API_KEY - Your Anthropic API key (required)
  • MODEL_REFRESH_INTERVAL - Seconds between model list refreshes, 0 to disable (default: 3600)

Minimal config, maximum functionality.

License

MIT License

Contributing

Github: https://github.com/1337hero/open-webui-anthropic-api-pipe

Contributions welcome! But remember:

Before adding features, ask:

  1. Is this solving an actual problem or a theoretical one?
  2. Can we solve this with less code?
  3. Are we duplicating Anthropic's existing protections?

Pull Request Guidelines:

  • Keep it simple
  • Remove code when possible
  • No security theater
  • Test with real use cases

Key changes:

  • Added "What's New in v2.1" section at top
  • Updated "Supported Models" to explain dynamic fetching
  • Added 3 new features to Core Functionality
  • Added MODEL_REFRESH_INTERVAL to Configuration

0