Token Overview
API Token (API Key) is your credential for calling Laozhang API. Like a password, it’s used to verify your identity and record usage. Security AlertAPI Token is like your account password. If leaked, others can use your quota. Please keep it safe!Create Token
Standard Token
1 Log in to Console Visit Laozhang API Console and log in 2 Enter Token Management
Click “API Keys” in the left menu
3
Create New Token
Click “Create New Token” button
4
Configure Token
Fill in token information:
- Token Name: For identifying token purpose (e.g., “Production Environment”, “Testing”)
- Billing Method: Choose billing method
- Usage-based billing (pay per token)
- Pay-per-use (pay per request)
- Permissions: Set API permissions (optional)
- Expiration Time: Set token validity period (optional)
Special Purpose Tokens
- Usage-based Billing Token
- Pay-per-use Token
- Read-only Token
- Temporary Token
- High-frequency API calls
- Chat applications
- Text processing
- Code generation
- Billed by tokens consumed
- More economical for high usage
- Support all text models
- Image generation
- Video generation
- Occasional use
- Predictable costs
- Fixed price per successful request
- No need to worry about token counts
- Clearer pricing
- Monitoring and statistics
- Audit logs
- Non-sensitive operations
- View usage data
- Query model list
- View account information
- Cannot call AI models
- Demonstration and testing
- Third-party integration
- Short-term projects
- Set expiration time
- Auto revoke after expiration
- Enhanced security
Manage Tokens
View Token List
View all your tokens in console:| Token Name | Created | Last Used | Status | Operations | |
|---|---|---|---|---|---|
| Production | 2024-01-01 | 2 minutes ago | 🟢 Active | Edit | Revoke |
| Testing | 2024-01-05 | Yesterday | 🟢 Active | Edit | Revoke |
| Demo | 2024-01-10 | Never | 🟡 Not Used | Edit | Revoke |
| Old Token | 2023-12-01 | Last month | 🔴 Revoked | Delete |
Edit Token
Can modify token configuration: 1 Click Edit Click “Edit” button next to token 2 Modify Configuration Modifiable items:- Token name
- Permissions
- Expiration time
- Usage limits
Revoke Token
When need to invalidate a Token: 1 Select Token Find token to revoke in token list 2 Click Revoke Click “Revoke” button 3 Confirm Operation Confirm revocation in popup dialog After revocation, all applications using this Token will fail. Ensure alternatives are prepared.Rotate Tokens
Regularly rotating Tokens enhances security: 1 Create New Token Create new token as replacement 2 Update Application Update all applications to use new Token 3 Test Verification Confirm new Token works properly 4 Revoke Old Token Revoke old Token Recommended Rotation Frequency- Production environment: Every 3 months
- Development environment: Every 6 months
- Temporary Token: Set expiration time
Security Best Practices
1. Token Storage
Python JavaScript Bash2. Version Control
Never Commit API KeyNever commit API Keys to version control systems (Git, SVN, etc.)3. Permission Control
Set minimum necessary permissions:| Scenario | Recommended Permissions |
|---|---|
| Production Environment | Full permissions, strict access control |
| Development Environment | Full permissions, local use only |
| Testing Environment | Limited permissions, low quotas |
| Demo Applications | Read-only or limited calls |
| Third-party Integration | Minimum necessary permissions |
4. IP Whitelist
Limit Token to specific IP addresses: 1 Enable IP Restrictions Edit Token settings and enable “IP Whitelist” 2 Add Allowed IPs Add IPs allowed to use this Token:- Single IP:
192.168.1.100 - IP Range:
192.168.1.0/24 - Multiple IPs: Add multiple rules
5. Usage Monitoring
Regularly check Token usage:Token Leakage Handling
If Token Leaked
1 Immediately Revoke Immediately revoke leaked Token in console 2 Check Usage Records Check recent usage records for unusual activities
3
Assess Impact
Evaluate potential losses:
- Unusual API calls?
- Abnormal cost increases?
- Sensitive data leaks?
- Email: support@laozhang.ai
- Request balance freeze or refund
- Report security incident
Prevent Leakage
Prevention Measures- ✅ Use environment variables
- ✅ Add keys to .gitignore
- ✅ Do not share keys in chat/email
- ✅ Use different keys for different environments
- ✅ Enable IP whitelist
- ✅ Regularly rotate keys
- ✅ Monitor usage logs
- ✅ Set usage limits
Programmatic Management
Create Token via API
List Tokens
Revoke Token
Common Issues
Error: “Invalid API Key” Possible Causes:- Token Incorrect
- Check for extra spaces or newlines when copying
- Ensure complete Token copied
- Check for character confusion (0/O, 1/l, etc.)
- Token Revoked
- Check Token status in console
- May have been manually revoked
- May have reached expiration time
- Token Expired
- Check Token expiration time
- Recreate if expired
- Different environments (development/testing/production)
- Different projects
- Different billing methods
- Different permission levels
- Standard users: Up to 10 Tokens
- Professional users: Up to 50 Tokens
- Enterprise users: Unlimited
- Create new Token with desired billing method
- Update applications to use new Token
- Revoke old Token
- Usage records remain independent
- Balance is shared (same account)
- Daily limit (calls or amount)
- Monthly limit
- Single request maximum tokens
- Allowed models
- Create new Token as replacement
- Update all applications to use new Token
- Revoke old Token (optional)
- Immediately save Token after creation
- Use password manager to store
- Save to secure configuration management system
Best Practices
1. Environment Isolation
Use different Tokens for different environments:2. Token Naming
Use clear naming conventions:3. Regular Audits
Establish regular audit mechanisms:Related Resources
- Insufficient Balance - Handle balance issues
- Usage Logs - View API usage records
- Data Security - Understand data protection
- API Reference - View API documentation