diff --git a/.env b/.env index fb31641..5390d16 100644 --- a/.env +++ b/.env @@ -1,13 +1,24 @@ # === AI CONFIGURATION === -# Your API key or access token +# OpenRouter API key for text generation (DeepSeek) AI_API_KEY=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 -# Name or ID of the AI model +# DeepSeek model for text/keyword generation AI_MODEL_NAME=deepseek/deepseek-chat-v3-0324:free -# Endpoint or base URL for DeepSeek API (update if different) -AI_API_URL=https://api.deepseek.com/v1 +# OpenRouter API URL +AI_API_URL=https://openrouter.ai/api/v1/chat/completions + +# === GROK VISION API CONFIGURATION === + +# Grok API key for vision analysis (add your Grok API key here) +GROK_API_KEY=sk-voidai-vVU2HHiq1txTNmXdZOP98LzARmi4HsptTixMqFSX4yBbw8ogvmKlJEPeKrH1hwEd6j6AnED9LsR6ztPtRMT7UzeLOyxQkasbwKow + +# Grok-2-Vision model +GROK_VISION_MODEL=grok-2-vision-1212 + +# Grok API URL +GROK_API_URL=https://api.voidai.app/v1/ # Optional: AI task-specific configuration AI_TASK=keyword_generation diff --git a/GROK_SETUP.md b/GROK_SETUP.md new file mode 100644 index 0000000..0653e14 --- /dev/null +++ b/GROK_SETUP.md @@ -0,0 +1,75 @@ +# Grok-2-Vision Integration Setup + +## How to Configure Your Grok API Key + +The SEO Image Renamer now supports Grok-2-Vision for enhanced image analysis. Follow these steps to set up your API key: + +### Step 1: Get Your Grok API Key +1. Visit [https://console.x.ai/](https://console.x.ai/) +2. Sign up or log in to your account +3. Navigate to API Keys section +4. Create a new API key for your project +5. Copy the generated API key + +### Step 2: Update the .env File +1. Open the `.env` file in your project directory +2. Find the line that says: `GROK_API_KEY=your_grok_api_key_here` +3. Replace `your_grok_api_key_here` with your actual Grok API key +4. Save the file + +Example: +```env +GROK_API_KEY=gsk-proj-abc123def456ghi789jkl012mno345pqr678stu901vwx234yz567 +``` + +### Step 3: Test the Integration +1. Open your SEO Image Renamer website +2. Upload some images +3. Add keywords and click "Generate SEO Keywords" +4. Check the browser console for the message: "Grok API Key configured: Yes" + +## What's New with Grok-2-Vision + +### Enhanced Image Analysis +- **Better Keyword Extraction**: Grok-2-Vision provides more accurate and contextual keywords from your images +- **SEO-Focused Analysis**: The AI is specifically prompted to identify keywords useful for SEO image naming +- **Improved Accuracy**: Better object and action recognition compared to previous vision models + +### Technical Improvements +- **Dedicated Vision API**: Separate API endpoint optimized for vision tasks +- **Enhanced Prompts**: Specialized prompts for extracting SEO-relevant keywords +- **Better Error Handling**: Improved fallback mechanisms if vision analysis fails +- **Cleaner Responses**: Better parsing and filtering of AI responses + +## Troubleshooting + +### Common Issues + +**Issue**: "Grok API Key configured: No" in console +**Solution**: Make sure you've replaced `sk-voidai-vVU2HHiq1txTNmXdZOP98LzARmi4HsptTixMqFSX4yBbw8ogvmKlJEPeKrH1hwEd6j6AnED9LsR6ztPtRMT7UzeLOyxQkasbwKow` with your actual API key in the .env file + +**Issue**: Vision analysis fails or returns generic keywords +**Solution**: +1. Check that your API key is valid and has sufficient credits +2. Ensure your API key has access to Grok-2-Vision model +3. Check browser console for specific error messages + +**Issue**: .env file not loading +**Solution**: +1. Make sure the .env file is in the same directory as index.html +2. Ensure your web server allows access to .env files (may need to serve from a local server) +3. For production, you may need to hardcode the API key in the JavaScript file + +### API Limits +- Grok-2-Vision has rate limits and usage quotas +- If you hit limits, the system will fallback to generic keywords +- Monitor your usage in the X.AI console + +## Security Note +Keep your API key secure and never commit it to public repositories. The .env file should be added to your .gitignore file. + +## Support +If you encounter issues with the Grok-2-Vision integration, check: +1. X.AI API documentation: [https://docs.x.ai/](https://docs.x.ai/) +2. Your API key permissions and quotas +3. Browser console for detailed error messages \ No newline at end of file diff --git a/config.js b/config.js new file mode 100644 index 0000000..00ed80b --- /dev/null +++ b/config.js @@ -0,0 +1,20 @@ +// Configuration file for SEO Image Renamer +// Update your API keys here + +window.APP_CONFIG = { + // OpenRouter API for text generation (DeepSeek) - already configured + OPENROUTER_API_KEY: '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', + DEEPSEEK_MODEL: 'deepseek/deepseek-chat-v3-0324:free', + OPENROUTER_API_URL: 'https://openrouter.ai/api/v1/chat/completions', + + // Grok-2-Vision API - ADD YOUR GROK API KEY HERE + GROK_API_KEY: 'sk-voidai-vVU2HHiq1txTNmXdZOP98LzARmi4HsptTixMqFSX4yBbw8ogvmKlJEPeKrH1hwEd6j6AnED9LsR6ztPtRMT7UzeLOyxQkasbwKow' + GROK_VISION_MODEL: 'grok-2-vision-1212', + GROK_API_URL: 'https://api.x.ai/v1/chat/completions' +}; + +// Instructions: +// 1. Get your Grok API key from https://console.x.ai/ +// 2. Replace 'your_grok_api_key_here' above with your actual API key +// 3. Save this file +// 4. The website will automatically use your new API key \ No newline at end of file diff --git a/index.html b/index.html index 5e2c585..98d91cd 100644 --- a/index.html +++ b/index.html @@ -100,9 +100,9 @@