An async implementation of the Anthropic Claude integration for OpenWebUI, converted from the synchronous version to use aiohttp for better performance and scalability.
- ✅ Async/Await Support - Full async implementation using aiohttp
- ✅ Streaming Responses - Real-time text generation with async generators
- ✅ Image Processing - Support for both base64 and URL images with size validation
- ✅ Multiple Models - Support for Claude Sonnet 4 and Opus 4
- ✅ Error Handling - Comprehensive error handling and validation
- ✅ OpenWebUI Compatible - Drop-in replacement for the sync version
-
Install dependencies:
uv sync
-
Set your Anthropic API key:
export ANTHROPIC_API_KEY=your_api_key_here
The async pipe can be used as a drop-in replacement for the synchronous version in OpenWebUI. The pipe function signature is compatible with OpenWebUI's async function calling pattern.
from anthropic_async import Pipe
# Initialize the pipe
pipe = Pipe()
# Use in async context
async def example():
body = {
"model": "anthropic.claude-sonnet-4-20250514",
"messages": [{"role": "user", "content": "Hello!"}],
"stream": False
}
response = await pipe.pipe(body)
print(response)Comprehensive integration tests using pytest test all functionality against the real Anthropic API.
# Install dependencies including test dependencies
uv sync
# Set API key
export ANTHROPIC_API_KEY=your_api_key_here# Run all tests
just test
# Run specific test categories
just test-streaming # Only streaming tests
just test-images # Only image tests
just test-errors # Only error handling tests
just test-slow # Only slow tests
# Run tests by name pattern
just test-name "image_url"
# Or use pytest directly
uv run pytest tests/ -v- ✅ Non-streaming and streaming responses
- ✅ Image processing (base64 and URLs)
- ✅ System message handling
- ✅ Multiple Claude models
- ✅ Error handling and validation
- ✅ Concurrent request handling
- ✅ Parametrized test cases
- Async Methods: All HTTP operations use
aiohttpinstead ofrequests - Image Processing: URL image validation is now async
- Streaming: Uses async generators for streaming responses
- Error Handling: Updated for
aiohttp.ClientErrorexceptions - Performance: Better handling of concurrent requests
This project uses just for task automation:
# Show all available commands
just
# Run tests
just test
just test-streaming
just test-images
# Code quality
just format # Format with black
just lint-ruff # Lint with ruff
just lint-fix # Lint and auto-fix
# Development
just run # Run the main module
just install # Install dependencies
just update # Update dependenciesThis project uses opencode as a copilot for development assistance.