Missing keys
Troubleshooting Guide: Missing or Incorrect API Keys in R2R
API keys are crucial for authenticating and accessing various services integrated with R2R. Missing or incorrect API keys can lead to connection failures and service disruptions. This guide will help you identify and resolve API key issues.
1. Identifying API Key Issues
Common symptoms of API key problems include:
- Error messages mentioning “unauthorized,” “authentication failed,” or “invalid API key”
- Specific services or integrations not working while others function correctly
- Unexpected 401 or 403 HTTP status codes in logs
2. Checking API Key Configuration
2.1 Environment Variables
R2R uses environment variables to store API keys. Check if the required environment variables are set:
Look for variables like:
OPENAI_API_KEY
ANTHROPIC_API_KEY
AZURE_API_KEY
UNSTRUCTURED_API_KEY
HATCHET_CLIENT_TOKEN
2.2 Configuration Files
If you’re using configuration files (e.g., r2r.toml
), verify that API keys are correctly set:
3. Common API Key Issues and Solutions
3.1 OpenAI API Key
Issue: OpenAI services not working or returning authentication errors.
Solution:
- Verify the
OPENAI_API_KEY
is set: - Ensure the key starts with “sk-”.
- Check the key’s validity in the OpenAI dashboard.
- Regenerate the key if necessary and update the environment variable.
3.2 Anthropic API Key
Issue: Claude or other Anthropic models not functioning.
Solution:
- Confirm the
ANTHROPIC_API_KEY
is set: - Verify the key format (typically starts with “sk-ant-”).
- Test the key using Anthropic’s API documentation.
3.3 Azure API Key
Issue: Azure-based services failing to authenticate.
Solution:
- Check the
AZURE_API_KEY
is set: - Verify additional Azure-related variables:
AZURE_API_BASE
AZURE_API_VERSION
- Ensure the key and endpoint match your Azure resource configuration.
3.4 Unstructured API Key
Issue: File ingestion or parsing failures.
Solution:
- Verify the
UNSTRUCTURED_API_KEY
is set: - Check if the Unstructured API URL is correctly configured:
- Test the key using Unstructured’s API documentation.
3.5 Hatchet Client Token
Issue: Workflow orchestration failures or Hatchet connectivity issues.
Solution:
- Confirm the
HATCHET_CLIENT_TOKEN
is set: - Verify the token was correctly generated during the R2R setup process.
- Check Hatchet logs for any token-related errors.
4. Updating API Keys
If you need to update an API key:
-
Stop the R2R service:
-
Update the key in your environment or configuration file:
Or update the
r2r.toml
file if you’re using configuration files. -
Restart the R2R service:
5. Security Best Practices
- Never commit API keys to version control.
- Use environment variables or secure secret management solutions.
- Regularly rotate API keys, especially if you suspect they’ve been compromised.
- Use the principle of least privilege when creating API keys.
6. Debugging API Key Issues
If you’re still having trouble:
-
Check R2R logs for detailed error messages:
-
Verify network connectivity to the API endpoints.
-
Ensure your account has the necessary permissions for the API keys you’re using.
-
Try using the API key in a simple curl command to isolate R2R-specific issues:
7. Getting Help
If you’ve tried these steps and are still experiencing issues:
- Check the R2R documentation for any recent changes or known issues with API integrations.
- Search the R2R GitHub issues for similar problems and solutions.
- Reach out to the R2R community on Discord or other support channels, providing:
- R2R version
- Relevant logs (with sensitive information redacted)
- Steps to reproduce the issue
- Any error messages you’re seeing
Remember, never share your actual API keys when seeking help. Use placeholders or redacted versions in any logs or code snippets you share publicly.