API Key Authentication
The YouRouter API uses API keys for authentication. You can generate and manage your API keys from the YouRouter Dashboard.Keep your API key secure and never expose it in client-side code or public repositories.
Getting Your API Key
- Sign up for an account at YouRouter Platform
- Navigate to the Dashboard and go to API Keys
- Generate a new API key
- Copy and store your API key securely
Making Authenticated Requests
Include your API key in theAuthorization
header of your requests:
Using Environment Variables
For security, set your API key as an environment variable:- macOS/Linux
- Windows
- Python (.env)
SDK Configuration
Configure the OpenAI SDKs with your API key and the YouRouter base URL:Security Best Practices
Store API keys securely
Store API keys securely
- Use environment variables or secure credential management systems
- Never commit API keys to version control
- Rotate your API keys regularly
- Use different API keys for different environments (development, staging, production)
Implement rate limiting
Implement rate limiting
- Monitor your API usage to avoid hitting rate limits
- Implement exponential backoff for retries
- Cache responses when possible to reduce API calls
Monitor API usage
Monitor API usage
- Set up monitoring and alerting for unusual API usage patterns
- Track costs and set spending limits in the YouRouter Dashboard
- Monitor for potential security breaches or unauthorized access
Error Handling
Handle authentication errors gracefully in your applications:Rate Limits and Usage
API rate limits and pricing information can be found in your YouRouter Dashboard. Monitor your usage to avoid hitting limits.
Status Code | Description |
---|---|
200 | Success |
401 | Invalid API key |
429 | Rate limit exceeded |
500 | Server error |