Overview
Improved the LLM configuration of the blog-api-server project and deployed it to the production server.
LLM Configuration Improvement
Previous Issues
- Multiple API Key environment variables (
ZAI_API_KEY,ANTHROPIC_API_KEY) - Complex provider branching logic
- Scattered model settings
Changes
Simplified Environment Variables
# Before
ZAI_API_KEY=xxx
ANTHROPIC_API_KEY=xxx
ZAI_MODEL=gpt-4o-mini
LLM=ZAI
# After
LLM=ZAI # Provider (ZAI, OPENAI, ANTHROPIC)
LLM_API_KEY=xxx # Single API Key
LLM_MODEL=glm-4.7 # Default model
LLM_TIMEOUT=120 # Timeout (seconds)
Auto BASE_URL Selection
LLM_BASE_URLS = {
"ZAI": "https://api.z.ai/api/coding/paas/v4",
"OPENAI": "https://api.openai.com/v1",
"ANTHROPIC": "https://api.anthropic.com/v1"
}
Improved Code Structure
class Translator:
"""LLM-based Translator"""
def __init__(self):
self.api_key = LLM_API_KEY
self.base_url = LLM_BASE_URL # Auto-selected
self.model = LLM_MODEL
self.timeout = LLM_TIMEOUT
Model Configuration
Default Model
- glm-4.7 (default)
- max_tokens: 8192
Supported Models
| Model | max_tokens |
|---|---|
| glm-4 | 8192 |
| glm-4.7 | 8192 |
| gpt-4o-mini | 4096 |
| gpt-4o | 8192 |
| claude-3-5-haiku | 8192 |
Team Structure
Organized the blog-api-server development team.
| Role | Name | Responsibility |
|---|---|---|
| Team Lead | team-lead | Overall management |
| Developer | developer | Coding, feature implementation |
| Deployer | deployer | Server deployment, infrastructure |
| Monitor | monitor | Log analysis, performance monitoring |
Server Deployment
Target
- Server: blog.fcoinfup.com (130.162.133.47)
- Path:
/var/www/blog-api
Deployment Content
- Updated
translator.py - Restarted systemd service
Deployment Result
● blog-api.service - Blog API Server
Active: active (running)
Translation API Test
Tested the translation API after deployment:
| Input (Korean) | Output (English) |
|---|---|
| “안녕하세요, 이것은 테스트 번역입니다.” | “Hello, this is a test translation.” |
Result: API working correctly with glm-4.7 model.
Next Steps
- Monitoring dashboard setup (Grafana/Prometheus)
- Log file rotation policy
- Alert configuration (Slack/Email)
영어 버전: English Version