How to run MiroFish with OpenRouter instead of Alibaba Bailian.
- No Chinese cloud account needed
- Access to 200+ models (Qwen, GPT, Claude, Gemini, Llama)
- Pay-per-token, no subscription
- Same OpenAI-compatible API format
MiroFish needs 4 patches to work with OpenRouter because:
- Qwen3 models output
<think>reasoning tags — need stripping response_format: json_object— not supported on OpenRouter for all models- OpenRouter requires extra headers (HTTP-Referer, X-Title)
- Python integer conversion limit — Qwen3 can return very large numbers
All patches are in the patches/ subfolder:
| File | What Changed |
|---|---|
llm_client.py |
Strips think tags, skips response_format for OpenRouter, adds headers |
oasis_profile_generator.py |
Removes response_format, adds think-tag stripping |
simulation_config_generator.py |
Same as above |
run.py |
Sets sys.set_int_max_str_digits(100000) |
frontend/src/api/index.js |
Changes baseURL from localhost:5001 to empty (uses Vite proxy) |
# LLM — OpenRouter with Qwen
LLM_API_KEY=sk-or-v1-your-openrouter-key
LLM_BASE_URL=https://openrouter.ai/api/v1
LLM_MODEL_NAME=qwen/qwen3-30b-a3b
# Zep Cloud (same as original)
ZEP_API_KEY=z_your-zep-key
# Optional boost model (even faster)
LLM_BOOST_API_KEY=sk-or-v1-your-openrouter-key
LLM_BOOST_BASE_URL=https://openrouter.ai/api/v1
LLM_BOOST_MODEL_NAME=qwen/qwen3-30b-a3b| Model ID | Speed | Quality | Cost/1M tokens |
|---|---|---|---|
qwen/qwen3-30b-a3b |
Fast | Good | $0.30 |
qwen/qwen3-235b-a22b |
Slow | Best | $1.50 |
qwen/qwen2.5-72b-instruct |
Medium | Great | $0.50 |
google/gemini-2.5-flash |
Very fast | Great | $0.10 |
google/gemini-2.0-flash-001 |
Very fast | Good | $0.05 |
Recommendation: qwen/qwen3-30b-a3b for best speed/quality/cost ratio.
# docker-compose.yml
services:
mirofish:
image: ghcr.io/666ghj/mirofish:latest
container_name: mirofish
env_file:
- .env
ports:
- "3000:3000"
- "5001:5001"
restart: unless-stopped
volumes:
- ./backend/uploads:/app/backend/uploads
- ./backend/app/utils/llm_client.py:/app/backend/app/utils/llm_client.py
- ./backend/app/services/oasis_profile_generator.py:/app/backend/app/services/oasis_profile_generator.py
- ./backend/app/services/simulation_config_generator.py:/app/backend/app/services/simulation_config_generator.py
- ./backend/run.py:/app/backend/run.py
- ./frontend/src/api/index.js:/app/frontend/src/api/index.jsWhen accessing the UI remotely (not localhost), the frontend API calls fail because they go to localhost:5001 which is YOUR machine, not the server.
The index.js patch changes baseURL to empty string, making all API calls go through the Vite proxy on port 3000, which forwards /api/* to localhost:5001 inside the container.
# 1. Clone MiroFish
git clone https://github.com/666ghj/MiroFish.git
cd MiroFish
# 2. Create .env
cat > .env << 'EOF'
LLM_API_KEY=sk-or-v1-YOUR_KEY
LLM_BASE_URL=https://openrouter.ai/api/v1
LLM_MODEL_NAME=qwen/qwen3-30b-a3b
ZEP_API_KEY=z_YOUR_ZEP_KEY
EOF
# 3. Copy patches
cp setup-guide/patches/llm_client.py backend/app/utils/llm_client.py
cp setup-guide/patches/oasis_profile_generator.py backend/app/services/oasis_profile_generator.py
cp setup-guide/patches/simulation_config_generator.py backend/app/services/simulation_config_generator.py
cp setup-guide/patches/run.py backend/run.py
mkdir -p frontend/src/api/
cp setup-guide/patches/index.js frontend/src/api/index.js
cp setup-guide/patches/docker-compose.yml docker-compose.yml
# 4. Start
docker compose pull
docker compose up -d
# 5. Verify
curl http://localhost:3000 # Frontend
curl http://localhost:5001/healthz # Backend (should return ".")| Phase | Calls | Cost (30B) | Cost (235B) |
|---|---|---|---|
| Ontology Generation | 1 | $0.01 | $0.05 |
| Graph Building (Zep) | 0 | $0 | $0 |
| Profile Generation (93 agents) | ~93 | $0.10 | $0.80 |
| Config Generation (7 batches) | ~10 | $0.05 | $0.30 |
| Simulation (72 rounds x 93 agents) | ~6,600 | $0.50 | $3.00 |
| Report Generation | ~10 | $0.05 | $0.30 |
| Total | ~$0.70 | ~$4.45 |