A flexible AI-powered API that acts as a hub between various input sources (Twitch, Discord, direct API) and AI services (Replicate, Bedrock, local models). Built with FastAPI and designed for easy deployment and scaling.
- Image Analysis: CLIP interrogation and BLIP captioning
- Image Generation: SDXL text-to-image generation
- Image Editing: PhotoMaker for image transformation
- Flexible Model Configuration: Override models at API, environment, or app level
- Twitch Bot: Chat commands for image processing
- Discord Bot: (Coming soon) Discord integration
- Direct API: RESTful endpoints for programmatic access
- Python 3.11+
- Docker (optional)
- Replicate API token
-
Clone and setup:
git clone <repository> cd NeuroQuack just run
-
Configure API:
curl -X POST "http://localhost:8000/configure" \ -H "Content-Type: application/json" \ -d '{ "api": { "replicate_token": "your_token_here", "replicate_org": "your_org_here" } }'
-
Test image analysis:
curl -X POST "http://localhost:8000/image/analyze/clip" \ -H "Content-Type: application/json" \ -d '{ "image_url": "https://example.com/image.jpg" }'
-
Generate image:
curl -X POST "http://localhost:8000/image/generate" \ -H "Content-Type: application/json" \ -d '{ "prompt": "a beautiful landscape" }'
-
Build and run:
just rebuild
-
Configure with environment variables:
export REPLICATE_API_TOKEN="your_token" export REPLICATE_ORG="your_org" just docker-run
POST /configure- Configure API tokens and optional bot integrations
POST /image/analyze/clip- Analyze image with CLIP interrogatorPOST /image/analyze/blip- Generate image caption with BLIPPOST /image/generate- Generate image from text promptPOST /image/photomaker- Transform image using PhotoMaker
POST /start_bot- Start Twitch bot (if configured)POST /stop_bot- Stop Twitch bot
The system supports hierarchical model configuration:
- API Level (highest priority): Specify model in API request
- Environment Level: Set
MODEL_*environment variables - App Level (lowest priority): Default models in
config/models.py
# Required
REPLICATE_API_TOKEN=your_token
REPLICATE_ORG=your_org
# Optional model overrides
MODEL_PHOTOMAKER=jd7h/photomaker:latest
MODEL_CLIP_INTERROGATOR=pharmapsychotic/clip-interrogator:8151e1c9f47e696fa316146a2e35812ccf79cfc9eba05b11c7f450155102af70
MODEL_SDXL=stability-ai/sdxl:7762fd07cf82c948538e41f63f77d685e02b063e37e496e96eefd46c929f9bdc
MODEL_BLIP=ducktapedevops/blipNeuroQuack follows a hub-and-spoke architecture pattern:
Input Sources flow into the NeuroQuack API which then routes to AI Services:
- Input Sources: Twitch Chat, Discord, Direct API calls
- NeuroQuack API: FastAPI application with Pydantic models, Docker containerization
- AI Services: Replicate models, AWS Bedrock, Local models
The API acts as a central hub that can accept requests from multiple sources and route them to appropriate AI services based on the request type and configuration.
TODO: Create a visual architecture diagram showing the hub-and-spoke pattern with input sources, the NeuroQuack API hub, and AI service destinations.
The application is organized into the following directories:
- app/config/ - Model configuration and settings
- app/inputs/ - Bot integrations (Twitch, Discord)
- app/models/ - Pydantic data models for API requests/responses
- app/routers/ - FastAPI route handlers for different endpoints
- app/tasks/ - AI service integrations and business logic
- app/flavor/ - Style configurations and templates
- app/main.py - FastAPI application entry point
- Add model to
config/models.py - Create task function in
tasks/ - Add router endpoint in
routers/ - Update environment variables if needed
- Create integration in
inputs/ - Add configuration model in
models/bot.py - Update
/configureendpoint inmain.py
The application is designed to run on AWS ECS with:
- Environment variable configuration
- Health checks via
/configureendpoint - Optional Twitch/Discord bot integration
docker build -t neuroquack .
docker run -e REPLICATE_API_TOKEN -e REPLICATE_ORG -p 8080:8080 neuroquack- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
[Your License Here]