Getting Your API Key
- Visit Legnext.ai Dashboard
- Navigate to API Keys section
- Generate a new API key
- Copy and store securely
Authentication Methods
Method 1: Environment Variables (Recommended)
Set your API key as an environment variable:Method 2: Direct Initialization
Hardcode the API key directly (not recommended for production):Method 3: Using vlucas/phpdotenv
Use thevlucas/phpdotenv package to load from .env files:
Method 4: Configuration File
Load API key from a configuration file:Method 5: Framework Integration (Laravel)
For Laravel applications, use environment variables: .env:Complete Configuration Example
Security Best Practices
-
Never commit API keys to version control
-
Use environment variables in production
-
Rotate keys regularly
- Generate new keys periodically
- Revoke old keys after rotation
-
Use different keys for development and production
-
Restrict API key permissions
- Use the minimum required permissions
- Monitor usage through the dashboard
-
Enable SSL verification
-
Protect configuration files