LiteLLM ကို Docker နဲ့ Setup လုပ်နည်း — Step by Step Guide
LiteLLM ဟာ LLM providers အများကြီးကို တစ်ခုတည်းသော OpenAI-compatible API နဲ့ ချိတ်ဆက်ပေးနိုင်တဲ့ proxy layer တစ်ခုပါ။ OpenAI, Azure OpenAI, Anthropic, Bedrock, Gemini, Ollama စတဲ့ providers တွေကို တစ်နေရာထဲကနေ manage လုပ်ချင်တဲ့အခါ LiteLLM က အတော်အသုံးဝင်ပါတယ်။
ဒီ post မှာတော့:
- LiteLLM ဆိုတာဘာလဲ
- Docker နဲ့ LiteLLM ကို ဘယ်လို run မလဲ
config.yamlကို ဘယ်လိုရေးမလဲ- Virtual key, master key, database နဲ့ production setup ကို ဘယ်လိုတည်ဆောက်မလဲ
- လက်တွေ့ test လုပ်တဲ့ curl examples တွေ
ကို အဆင့်လိုက်ပြပေးထားပါတယ်။
LiteLLM ဆိုတာဘာလဲ?
LiteLLM က model provider မျိုးစုံကို တစ်ခုတည်းသော API အဖြစ် unify လုပ်ပေးတဲ့ proxy ဖြစ်ပါတယ်။
အဓိကအသုံးဝင်တာတွေကတော့:
- Provider မျိုးစုံကို တစ်ထိုင်တည်း တစ်နေရာထဲက manage လုပ်နိုင်ခြင်း
- OpenAI SDK နဲ့ compatible ဖြစ်လို့ app code ကို မပြောင်းဘဲ အသုံးပြုနိုင်ခြင်း
- Model aliasing လုပ်နိုင်ခြင်း
- Rate limit, key management, spend tracking တို့ကို စီမံနိုင်ခြင်း
- Docker / Kubernetes / Helm နဲ့ deploy လုပ်နိုင်ခြင်း
အထူးသဖြင့် team project တွေမှာ provider key တွေကို app ထဲမှာ တိုက်ရိုက်မထည့်ချင်တဲ့အခါ LiteLLM proxy က အဆင်ပြေပါတယ်။
ဘယ်အချိန်မှာ LiteLLM ကိုသုံးသင့်လဲ?
ဒီလိုအခြေအနေတွေမှာ LiteLLM က အထူးသင့်တော်ပါတယ်:
- OpenAI, Azure OpenAI, Anthropic စတာတွေကို တစ်ခုတည်းသော endpoint ကနေ ခေါ်ချင်တဲ့အခါ
- မတူညီတဲ့ model တွေကို alias နာမည်နဲ့ manage လုပ်ချင်တဲ့အခါ
- Internal app တွေမှာ usage tracking / virtual keys ထည့်ချင်တဲ့အခါ
- Production မှာ proxy layer တစ်ခုထားပြီး security တိုးချင်တဲ့အခါ
Docker နဲ့ LiteLLM Setup လုပ်ရန် လိုအပ်ချက်များ
အနည်းဆုံးလိုအပ်တာတွေက:
- Docker
- Docker Compose (အကြံပြု)
- Provider API key များ
config.yaml
Production deployment အတွက် LiteLLM docs မှာ CPU 4 cores နဲ့ RAM 8GB လောက်ကို အနည်းဆုံးအကြံပြုထားပါတယ်။
1) config.yaml ဖိုင်ရေးပါ
LiteLLM ကို config.yaml နဲ့ control လုပ်ပါတယ်။ အောက်က example က Azure OpenAI ကို alias နာမည်နဲ့ expose လုပ်ထားတာပါ။
model_list:
- model_name: gpt-4o
litellm_params:
model: azure/my_azure_deployment
api_base: os.environ/AZURE_API_BASE
api_key: os.environ/AZURE_API_KEY
api_version: "2025-01-01-preview"
general_settings:
master_key: sk-your-master-keyဒီ config ထဲက field တွေဘာလုပ်သလဲ?
model_list: client တွေက call လုပ်မယ့် model alias တွေmodel_name: external client က ပို့မယ့် model namelitellm_params.model: backend provider model stringapi_base: Azure endpoint URLapi_key: secret keyapi_version: Azure API versionmaster_key: LiteLLM proxy admin key
Environment variable နဲ့ secret ထားနည်း
os.environ/VAR_NAME ဆိုတာက config ထဲမှာ secret တိုက်ရိုက်မရေးဘဲ environment variable ကနေ load လုပ်တာပါ။
ဥပမာ:
export AZURE_API_KEY="your-azure-key"
export AZURE_API_BASE="https://your-resource.openai.azure.com/"
ဒီနည်းက config ဖိုင်ကို git ထဲတင်တဲ့အခါ secret မပေါက်ကြားအောင် ကူညီပေးပါတယ်။
2) Docker image နဲ့ run ပါ
Quick start အတွက် Docker run command နဲ့တင် စနိုင်ပါတယ်။
docker run \
-v $(pwd)/litellm_config.yaml:/app/config.yaml \
-e AZURE_API_KEY=your-azure-key \
-e AZURE_API_BASE=https://your-resource.openai.azure.com/ \
-p 4000:4000 \
docker.litellm.ai/berriai/litellm:main-stable \
--config /app/config.yaml --detailed_debug
ဒီ command ရဲ့ အဓိပ္ပါယ်
-v $(pwd)/litellm_config.yaml:/app/config.yaml→ local config ကို container ထဲ mount လုပ်တယ်-e AZURE_API_KEY=...→ provider secret ထည့်တယ်-e AZURE_API_BASE=...→ Azure endpoint ထည့်တယ်-p 4000:4000→ localhost မှာ port 4000 နဲ့ expose လုပ်တယ်--config /app/config.yaml→ LiteLLM ကို config file နဲ့ run တယ်--detailed_debug→ debug logs ပိုမြင်ရတယ်
သတိ: Production မှာ
--detailed_debugကို မထားတာ ပိုကောင်းပါတယ်။ logs အများကြီးထွက်ပြီး performance ကို ထိခိုက်နိုင်ပါတယ်။
3) Proxy တက်မတက် စစ်ပါ
Container တက်လာပြီးရင် endpoint ကို test လုပ်ပါ။
curl -X POST 'http://0.0.0.0:4000/chat/completions' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer sk-your-master-key' \
-d '{
"model": "gpt-4o",
"messages": [
{"role": "user", "content": "Hello!"}
]
}'
LiteLLM က OpenAI-compatible ဖြစ်တာကြောင့် /chat/completions endpoint ကို အလွယ်တကူ သုံးနိုင်ပါတယ်။
4) Production-friendly Docker Compose setup
Single docker run ထက် Docker Compose နဲ့ရေးရင် ပို maintainable ဖြစ်ပါတယ်။ အထူးသဖြင့် Postgres database နဲ့ virtual key management ထည့်မယ်ဆိုရင် Compose က ပိုသင့်တော်ပါတယ်။
အောက်က example က LiteLLM proxy + Postgres ကို တစ်ခါတည်း run နိုင်အောင်ရေးထားတာပါ။
docker-compose.yml
version: "3.9"
services:
postgres:
image: postgres:16-alpine
container_name: litellm-postgres
restart: unless-stopped
environment:
POSTGRES_DB: litellm
POSTGRES_USER: litellm
POSTGRES_PASSWORD: litellm_password
volumes:
- pgdata:/var/lib/postgresql/data
ports:
- "5432:5432"
litellm:
image: docker.litellm.ai/berriai/litellm-database:main-stable
container_name: litellm-proxy
restart: unless-stopped
depends_on:
- postgres
ports:
- "4000:4000"
environment:
LITELLM_MASTER_KEY: sk-your-master-key
DATABASE_URL: postgresql://litellm:litellm_password@postgres:5432/litellm
AZURE_API_KEY: your-azure-key
AZURE_API_BASE: https://your-resource.openai.azure.com/
volumes:
- ./litellm_config.yaml:/app/config.yaml:ro
command: ["--config", "/app/config.yaml", "--detailed_debug"]
volumes:
pgdata:ဒီ setup ကို ဘာကြောင့်သုံးသင့်လဲ?
- Virtual keys create လုပ်ချင်ရင် database လိုတတ်တယ်
- Spend tracking / users / teams / budgets ကို manage လုပ်နိုင်တယ်
- Production မှာ config နဲ့ data ကို clean ခွဲထားနိုင်တယ်
- Restart ဖြစ်ရင် data မပျောက်စေဖို့ Postgres volume သုံးနိုင်တယ်
5) Database ပါတဲ့ LiteLLM config ဥပမာ
Database သုံးမယ်ဆိုရင် general_settings ထဲမှာ database_url ထည့်ပေးရပါတယ်။
model_list:
- model_name: gpt-4o
litellm_params:
model: azure/my_azure_deployment
api_base: os.environ/AZURE_API_BASE
api_key: os.environ/AZURE_API_KEY
api_version: "2025-01-01-preview"
general_settings:
master_key: sk-your-master-key
database_url: postgresql://litellm:litellm_password@postgres:5432/litellmMaster key နဲ့ database_url
master_key→ admin keydatabase_url→ Postgres connection string
ဒီ setup နဲ့ဆို virtual keys, budgets, users, teams စတာတွေကို manage လုပ်လို့ရလာပါတယ်။
6) Virtual key ဖန်တီးပုံ
Master key နဲ့ API call လုပ်ပြီး virtual key generate လုပ်လို့ရပါတယ်။
curl -L -X POST 'http://0.0.0.0:4000/key/generate' \
-H 'Authorization: Bearer sk-your-master-key' \
-H 'Content-Type: application/json' \
-d '{
"rpm_limit": 1
}'
Response က ဒီလိုမျိုးဖြစ်နိုင်ပါတယ်:
{
"key": "sk-generated-virtual-key"
}ပြီးရင် အဲဒီ virtual key နဲ့ request လုပ်နိုင်ပါတယ်။
7) Virtual key နဲ့ test လုပ်ပါ
curl -X POST 'http://0.0.0.0:4000/chat/completions' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer sk-generated-virtual-key' \
-d '{
"model": "gpt-4o",
"messages": [
{
"role": "user",
"content": "8x + 7 = -23 ကို ဘယ်လိုဖြေမလဲ?"
}
]
}'
အကယ်၍ rpm_limit: 1 ထားခဲ့ရင် တစ်မိနစ်အတွင်း request ၂ ကြိမ်လုပ်တဲ့အခါ 2nd request က rate limit error ပြနိုင်ပါတယ်။
8) Logs ထဲမှာ ဘာတွေစစ်ရမလဲ?
Proxy စတင်တဲ့အခါ config load ဖြစ်မဖြစ် စစ်ပါ။
အောက်လို log မျိုးကိုမြင်ရရင် config read လုပ်ပြီးသားလို့ ယူဆနိုင်ပါတယ်:
LiteLLM: Proxy initialized with ConfigLoaded config YAML- running on
http://0.0.0.0:4000
9) Common mistakes
1. Secret ကို config.yaml ထဲ တိုက်ရိုက်ရေးမိခြင်း
ဖြေရှင်းချက်: os.environ/VAR_NAME သုံးပါ။
2. master key မထည့်ထားခြင်း
ဖြေရှင်းချက်: general_settings.master_key သို့ LITELLM_MASTER_KEY ထည့်ပါ။
3. Virtual key features မဖြစ်ခြင်း
ဖြေရှင်းချက်: Postgres DATABASE_URL လိုပါတယ်။ Database မပါတဲ့အခါ key management features အချို့ မသုံးနိုင်ပါဘူး။
4. Debug mode ကို production မှာထားခြင်း
ဖြေရှင်းချက်: --detailed_debug ကို development မှာသာသုံးပါ။
10) Recommended production architecture
Production အတွက် recommended flow က ဒီလိုပါ:
- LiteLLM proxy container
- Postgres database
- Optional Redis for high-traffic or multi-instance routing
- Secrets via environment variables
- Config file in volume mount or config map
High traffic environment မှာ Redis buffer/cache ကိုအသုံးပြုရင် database pressure လျော့နိုင်ပါတယ်။
Conclusion
LiteLLM က provider မျိုးစုံကို တစ်ခုတည်းသော OpenAI-compatible endpoint အဖြစ် unify လုပ်ပေးနိုင်လို့ modern AI application တွေအတွက် အတော်အသုံးဝင်ပါတယ်။ Docker နဲ့ setup လုပ်ရတာလည်း straightforward ဖြစ်ပြီး config.yaml, env vars, Docker Compose သုံးလိုက်ရုံနဲ့ local development ကနေ production ထိ တဖြည်းဖြည်းတက်နိုင်ပါတယ်။
အကယ်၍ သင်က:
- LLM providers များစွာကို manage လုပ်ချင်တယ်
- app ထဲမှာ provider-specific logic လျှော့ချင်တယ်
- API keys ကို secure way နဲ့ handle လုပ်ချင်တယ်
- virtual keys / budgets / usage tracking လိုချင်တယ်
ဆိုရင် LiteLLM က စဉ်းစားသင့်တဲ့ tool တစ်ခုပါ။
Quick Summary
config.yamlဖန်တီးပါ- Secrets ကို environment variables နဲ့ထားပါ
- Docker image နဲ့ proxy run ပါ
/chat/completionsနဲ့ test လုပ်ပါ- Database ထည့်ပြီး virtual keys သုံးပါ
- Production မှာ Compose / Redis / monitoring ထည့်ပါ“

