wallacelw

oh-my-litellm-opencode

Deploy LiteLLM proxy (litellm + postgres) routing through Huawei MaaS with multi-key load balancing, then bootstrap opencode + oh-my-opencode-slim with virtual key and 4 presets.

wallacelw 1 Updated 4w ago

Resources

7
GitHub

Install

npx skillscat add wallacelw/oh-my-litellm-opencode

Install via the SkillsCat registry.

SKILL.md

oh-my-litellm-opencode

Deploy LiteLLM proxy → bootstrap opencode → mint virtual key → configure. Idempotent.

Scripts

# Script Purpose
0 0_bootstrap.sh End-to-end orchestrator: prereqs → deploy → install → validate
1 1_init_env.sh Generate .env with secrets + MaaS keys
2 2_generate_config.sh Build litellm_config.yaml from .env
3 3_install.sh Install opencode + plugin + mint key + write config
4 4_mint-virtual-key.sh Mint a scoped virtual key (standalone)
5 5_validate.sh Validate all components (--litellm-only for proxy-only)

Core Rules

  • Never commit .env or real keys
  • Never change LITELLM_SALT_KEY after virtual keys exist
  • Model names are case-sensitive — must match MaaS console exactly
  • Config is generated by 2_generate_config.sh — never edit litellm_config.yaml directly
  • Master key is admin-only — opencode uses virtual keys
  • LiteLLM baseURL: http://127.0.0.1:4000 (no /v1)
  • MaaS region-locked to ap-southeast-1

AI Agent Installation Flow

For generic AI agents (Claude Code, Cursor, etc.) installing this stack for a user.

What the agent does interactively

1. Check prerequisites — for each missing tool, ask user "OK to install?" then install:

Tool Check Install command Version/source
bun command -v bun curl -fsSL https://bun.sh/install | bash Latest from bun.sh (restart shell after)
jq command -v jq sudo apt-get install -y jq or brew install jq OS package manager
git command -v git sudo apt-get install -y git or brew install git OS package manager (usually pre-installed)
python3 command -v python3 sudo apt-get install -y python3 or brew install python3 OS package manager (usually pre-installed)
curl command -v curl sudo apt-get install -y curl or brew install curl OS package manager (usually pre-installed)
docker command -v docker curl -fsSL https://get.docker.com | sudo sh Latest Docker Engine from get.docker.com
docker compose docker compose version Included with Docker Engine 20.10+ V2 plugin (not standalone docker-compose)

opencode is NOT a prerequisite — it's installed automatically by 3_install.sh via curl -fsSL https://opencode.ai/install | bash.

2. Check Docker runningdocker info >/dev/null 2>&1 — if not, run sudo systemctl start docker

3. Ask for MaaS key — "What is your Huawei ModelArts MaaS API key? (region: ap-southeast-1, get from https://console.huaweicloud.com/modelarts/)"

4. Ask for extra keys — "How many additional MaaS keys for load balancing? (0 for none)" — if >0, prompt one-by-one

5. Check existing install — if /home/oh-my-litellm-opencode exists, ask: "Existing installation found. Update in-place or fresh install?"

6. Check port 4000 — if in use, ask user to stop the conflicting service

What the agent delegates to the script

git clone https://github.com/wallacelw/oh-my-litellm-opencode /home/oh-my-litellm-opencode
cd /home/oh-my-litellm-opencode

export HUAWEI_MAAS_API_KEY="$MAAS_KEY"
export HUAWEI_MAAS_API_KEY_COUNT="$TOTAL_KEYS"    # 1 + extra
export HUAWEI_MAAS_API_KEY_1="$MAAS_KEY_1"        # if provided
export HUAWEI_MAAS_API_KEY_2="$MAAS_KEY_2"        # if provided

./scripts/0_bootstrap.sh --agent --maas-key="$MAAS_KEY"

--agent mode: non-interactive, fail-fast, reads extra keys from env vars, runs validate, prints summary with key rotation instructions.

Presets

Preset Models Route
LiteLLM-Huawei-MaaS-Full (default) All 6 Proxy → MaaS
LiteLLM-Huawei-MaaS-Core 4 (no v4-pro/v4-flash) Proxy → MaaS
Huawei-MaaS-Full All 6 Direct → MaaS
Huawei-MaaS-Core 4 (no v4-pro/v4-flash) Direct → MaaS

Switch at runtime: /preset LiteLLM-Huawei-MaaS-Core

Council

3 councillors run in parallel, each with a different model and focus:

Councillor Model Focus
alpha deepseek-v4-pro Deep reasoning, logical correctness, subtle bugs/edge cases
beta glm-5.2 Architecture, maintainability, trade-offs, long-term implications
gamma deepseek-v3.2 Practical implementation, cost-efficiency, verification steps

Models

Name Context RPM Cost (in/out per token)
glm-5.2 1M/128K 100 $1.400 / $4.400 × 10⁻⁶
glm-5.1 192K/128K 30 $1.078 / $3.774 × 10⁻⁶
glm-5 192K/64K 30 $0.809 / $2.965 × 10⁻⁶
deepseek-v4-pro 1M/128K 3 $1.617 / $3.235 × 10⁻⁶
deepseek-v4-flash 1M/128K 3 $0.135 / $0.270 × 10⁻⁶
deepseek-v3.2 128K/32K 700 $0.270 / $0.404 × 10⁻⁶

Repair

Symptom Fix
litellm keeps restarting Check docker compose logs db, verify DB_PASSWORD
401 Unauthorized Key must start with sk-
404 model not found Model name case-sensitive
MaaS 403 Verify key; region must be ap-southeast-1
unhealthy_count > 0 Check MaaS key/model/region — may be transient
Virtual key 403 Check with /key/info — may be expired
Port conflict ss -tlnp | grep ':4000'

Full reset: docker compose down -v; rm -f .env .master-key