当用户需要使用 OpenRouter 免费 LLM 模型时调用本技能,触发词包括“OpenRouter”“free models”“openrouter‑c”等。
OpenClaw helps you:
Look for OPENROUTER_API_KEY in this priority order:
.env — ./ relative to the user's current working directory~/.env — the user's home directoryUse the helper script to resolve this:
bash
python3 /home/claude/openrouter-connect/scripts/resolve_key.py
If no key is found, tell the user and show them the quick-start box:
No key found. Get a free key at https://openrouter.ai/keys then add it to
.env:text
OPENROUTER_API_KEY=sk-or-...
Run the discovery script to fetch and cache the free model list:
bash
python3 /home/claude/openrouter-connect/scripts/discover_models.py [--refresh]
This calls GET https://openrouter.ai/api/v1/models (no auth required) and filters
for models where both pricing.prompt == "0" and pricing.completion == "0".
The script outputs a JSON array ranked by the default preference list (see
references/model_preferences.md for how ranking works and how to customise it).
Pass --refresh to bypass the 1-hour local cache.
Read references/model_preferences.md for the full preference system.
Quick summary:
To ask the user for their preference list, show them the discovered models and say:
"Here are the free models I found. Would you like to rank your favourites, or should I pick the best one automatically?"
Once a model is selected, call it directly using the script:
bash
python3 /home/claude/openrouter-connect/scripts/proxy_query.py \
--model "mistralai/mistral-7b-instruct:free" \
--prompt "Your question here"
Stream the response back to the user and note which model was used.
If the model returns a 429 (rate limit) or 5xx, automatically retry with the next model in the ranked list. Log which model was tried and why it was skipped.
Read the appropriate template from references/:
references/python_template.mdreferences/typescript_template.mdFill in:
.env loading boilerplate (checks ./ then ~/)main() example with the user's actual prompt if they provided oneAlways include inline comments explaining the fallback logic.
SituationBehaviourModel mid-list becomes paidSkip it, log a warning, continue down the listAll ranked models unavailableFall back to auto-ranked free poolNo free models found at allTell the user — OpenRouter's free tier may be downKey found but invalid (401)Prompt user to check the key; show the OpenRouter keys URLUser provides a model not in the free listWarn them it may incur cost; ask to confirmStreaming not supported by modelFall back to non-streaming request silently
FileWhen to readreferences/model_preferences.mdRanking algorithm, customisation, default weightsreferences/python_template.mdGenerating Python codereferences/typescript_template.mdGenerating TS/JS code