Authentication
Lunar SDK uses API Key authentication. You can provide your API key via environment variable or pass it directly to the client.Using Environment Variable
Set theLUNAR_API_KEY environment variable:
Passing Directly
Pass the API key to the client constructor:Authentication Header
The SDK automatically sets the authentication header:| Header | Format |
|---|---|
x-api-key | {your-api-key} |
Error Handling
Getting Your API Key
- Log in to the PureAI Console
- Navigate to API Keys section
- Click Create New Key
- Copy and securely store your key
Keep your API key secure. Never commit it to version control or expose it in client-side code.
Best Practices
Use Environment Variables in Production
Rotate Keys Regularly
- Create new keys periodically
- Revoke old keys after rotation
- Use separate keys for development and production
Limit Key Permissions
- Use the minimum required permissions
- Create separate keys for different applications