Required API keys
PAS2 uses a dual-model architecture:- Mistral AI: For paraphrase generation and response generation (
mistral-large-latest) - OpenAI: For hallucination detection judging (
o3-mini)
Getting your Mistral AI API key
Create a Mistral AI account
Visit Mistral AI and sign up for an account.
Getting your OpenAI API key
Create an OpenAI account
Visit OpenAI Platform and sign up for an account.
Generate a new API key
Click “Create new secret key”, give it a name, and copy the key. This is your only chance to see the full key.
OpenAI API keys are only shown once during creation. Store them securely in a password manager.
Setting up environment variables
Local development
Create a.env file in your project root:
.env
python-dotenv.
Hugging Face Spaces deployment
Create secret variables
Add two new secrets:
- Name:
HF_MISTRAL_API_KEY, Value: your Mistral API key - Name:
HF_OPENAI_API_KEY, Value: your OpenAI API key
Passing API keys programmatically
You can also pass API keys directly when initializing PAS2:This method takes priority over environment variables but is less secure for production use.
Verifying API key configuration
Test your API key setup:Troubleshooting
Missing API key errors
If you see:- Your
.envfile exists and is in the correct location - The variable names are spelled correctly (
HF_MISTRAL_API_KEY,HF_OPENAI_API_KEY) - There are no extra spaces or quotes around the keys
API authentication errors
If you see authentication errors when making API calls:- Verify your API keys are valid and active
- Check that you have available credits/quota on both platforms
- Ensure the keys haven’t expired or been revoked
API costs and rate limits
Be aware of API costs. Each query generates multiple API calls:
- 1 call for paraphrase generation (Mistral)
- N+1 calls for responses (Mistral, where N = number of paraphrases)
- 1 call for hallucination judging (OpenAI)
- Check your Mistral AI dashboard for usage statistics
- Review OpenAI usage at platform.openai.com/usage
Next steps
- Web interface - Start using PAS2 through the web interface
- Python library - Use PAS2 as a Python library in your code
- Configuration - Fine-tune PAS2 settings for your use case