- Node.js v18 or higher (for built-in fetch support)
- An AI API key (OpenAI, Anthropic, or custom service)
npm installFor OpenAI:
npm install openaiFor Anthropic Claude:
npm install @anthropic-ai/sdkFor Custom AI Service:
No additional package needed, but configure your API endpoint in .env
Create a .env file in the root directory with the following:
# AI Service Type: 'openai', 'anthropic', or 'custom'
AI_SERVICE_TYPE=openai
# Your AI API Key
AI_API_KEY=your_api_key_here
# For OpenAI (optional, defaults to gpt-3.5-turbo)
OPENAI_MODEL=gpt-3.5-turbo
# For Anthropic (optional, defaults to claude-3-sonnet-20240229)
ANTHROPIC_MODEL=claude-3-sonnet-20240229
# For Custom AI Service
# CUSTOM_AI_URL=https://api.example.com/v1/chat
# CUSTOM_AI_HEADERS={"X-Custom-Header": "value"}
# CUSTOM_AI_BODY={"model": "custom-model"}
# Backend Server Port (optional, defaults to 3001)
PORT=3001In one terminal:
npm run serverThe backend will run on http://localhost:3001
In another terminal:
npm run devThe frontend will run on http://localhost:5000
- Open
http://localhost:5000in your browser - Click the "Ask AI" button
- Enter your question in the modal
- Click "Generate Answers" to get 3 AI-generated answers
- Select your preferred answer
- Click "Add Selected Answer to Page"
- The question and answer will be formatted and added to the handwriting input area
- Generate your handwriting image as usual
- Make sure the backend server is running on port 3001
- Check that
AI_API_KEYis set in your.envfile - Verify the AI service package is installed
- Verify your API key is correct
- Check that you have sufficient API credits/quota
- For custom services, verify the endpoint URL and request format
- Check browser console for JavaScript errors
- Ensure
js/ai-modal.mjsis loaded correctly - Verify the "Ask AI" button has the correct ID