Overview
The XAUUSD Trading Bot uses Groq’s LLM API to generate intelligent trading signals based on technical analysis. This guide shows you how to obtain and configure your Groq API key.Groq provides fast inference for large language models, enabling real-time AI analysis of market conditions.
Getting Your Groq API Key
Create a Groq Account
Navigate to Groq Cloud and sign up for an account:
- Click Sign Up or Get Started
- Complete registration with your email
- Verify your email address
- Log in to the Groq Console
Generate API Key
Once logged in to the Groq Console:
- Navigate to API Keys section
- Click Create API Key
- Give your key a descriptive name (e.g., “XAUUSD Trading Bot”)
- Click Generate
- Copy the API key immediately - you won’t be able to see it again
Create Secrets Configuration
Create the Streamlit secrets directory and file:The
.streamlit folder should be in your project root directory.Add API Key to Secrets
Open Replace
.streamlit/secrets.toml and add your API key:gsk_your_actual_api_key_here with the API key you copied from Groq Console.Groq API keys typically start with
gsk_. Make sure to include the entire key string.Secure Your Secrets File
Add the secrets file to your This ensures your API key stays private.
.gitignore to prevent accidental commits:How the Bot Uses Groq
The trading bot leverages Groq’s LLM API through LangChain:- Technical indicators (RSI, EMA, ATR)
- Multi-timeframe confluence
- Order blocks and Fair Value Gaps
- Supply and demand zones
- Market structure
API Key Management
Environment Variables (Alternative)
For non-Streamlit deployments, you can use environment variables:- Linux/macOS
- Windows
- Python .env
~/.bashrc or ~/.zshrc for persistence.Rotating API Keys
For enhanced security, rotate your API keys regularly:- Generate a new key in Groq Console
- Update
.streamlit/secrets.tomlwith the new key - Restart the Streamlit application
- Delete the old key from Groq Console
Troubleshooting
'GROQ_API_KEY' not found in secrets
'GROQ_API_KEY' not found in secrets
This error occurs when Streamlit can’t find your secrets file:
- Verify
.streamlit/secrets.tomlexists in your project root - Check the file name is exactly
secrets.toml(notsecrets.txt) - Ensure the key name is exactly
GROQ_API_KEY(case-sensitive) - Restart the Streamlit server
Authentication Error / Invalid API Key
Authentication Error / Invalid API Key
If you see authentication errors:
- Verify you copied the complete API key from Groq Console
- Check for extra spaces or newlines in
secrets.toml - Ensure the key is still active in Groq Console
- Generate a new key if the old one was deleted or expired
Rate Limit Exceeded
Rate Limit Exceeded
Groq API has rate limits:
- Check your current usage in Groq Console
- Consider upgrading your plan for higher limits
- Implement caching to reduce API calls
- Use the auto-refresh feature wisely (30-minute intervals)
Cost Considerations
Groq offers generous free tier limits. Monitor your usage in the Groq Console dashboard.
- Once per manual analysis (“Run New Analysis” button)
- Every 30 minutes if auto-refresh is enabled
- Typical cost per analysis: minimal (depends on your Groq plan)