OpenRouter Setup for AgentBox
This skill guides users through configuring OpenRouter as their LLM provider on this AgentBox instance. OpenRouter gives access to models from Anthropic, OpenAI, Google, Meta, and others through a single API key.
When to use this skill
Invoke this when the user:
- - Wants to use a model through OpenRouter (e.g., "I want to use Claude Sonnet 4.5")
- Asks about configuring a different LLM provider
- Mentions OpenRouter
- Wants access to models not available through the default blockrun provider
Setup flow
Step 1: Check for OpenRouter account
Ask the user if they have an OpenRouter account. If not, guide them:
To use OpenRouter, you'll need an account and API key:
- 1. Go to https://openrouter.ai and sign up (Google/GitHub login works)
- Go to https://openrouter.ai/keys
- Click "Create Key"
- Copy the key (starts with
sk-or-)
Let me know when you have your API key.
Step 2: Get the API key
Ask the user to provide their API key. It should start with sk-or-.
Step 3: Ask which model they want
If the user already specified a model, use that. Otherwise, recommend:
Recommended: Claude Sonnet 4.5 (openrouter/anthropic/claude-sonnet-4-5) - best balance of capability and cost for most tasks.
Other popular options:
- -
openrouter/anthropic/claude-opus-4-6 - most capable, higher cost - INLINECODE4 - OpenAI's flagship
- INLINECODE5 - Google's best
Which model would you like as your default?
Step 4: Configure OpenClaw
Read the current config, modify it, and write it back:
CODEBLOCK0
Use jq to update the config. The two fields to set:
- 1.
env.OPENROUTER_API_KEY - the API key agents.defaults.model.primary - the default model
CODEBLOCK1
IMPORTANT: Always read the full config first, then modify. Never write a partial config file.
Step 5: Restart the gateway
CODEBLOCK2
Wait a few seconds, then verify:
CODEBLOCK3
Step 6: Confirm
Tell the user the setup is complete and their default model is now set to the chosen OpenRouter model. Suggest they send a test message to verify everything works.
Model reference format
OpenRouter models use the format openrouter/<provider>/<model>:
- - INLINECODE10
- INLINECODE11
- INLINECODE12
- INLINECODE13
- INLINECODE14
- INLINECODE15
- INLINECODE16
Full model list at https://openrouter.ai/models
Switching models later
To change the default model without re-entering the API key:
CODEBLOCK4
Troubleshooting
- - "Invalid API key": Verify the key starts with
sk-or- and has credit on https://openrouter.ai/credits - Model not responding: Check if the model is available on https://openrouter.ai/models - some models have downtime
- Config broken after edit: The issue is usually malformed JSON. Read the file with
cat ~/.openclaw/openclaw.json | jq . to check syntax - Changes not taking effect: Must run
openclaw gateway restart after any config change
为AgentBox配置OpenRouter
本技能指导用户在此AgentBox实例上配置OpenRouter作为其LLM提供商。OpenRouter通过单一API密钥即可访问Anthropic、OpenAI、Google、Meta等公司的模型。
何时使用此技能
在以下情况下调用此技能:
- - 用户希望通过OpenRouter使用某个模型(例如:我想使用Claude Sonnet 4.5)
- 用户询问配置不同的LLM提供商
- 用户提到OpenRouter
- 用户希望访问默认blockrun提供商未提供的模型
配置流程
步骤1:检查OpenRouter账户
询问用户是否拥有OpenRouter账户。如果没有,引导他们:
要使用OpenRouter,您需要一个账户和API密钥:
- 1. 前往 https://openrouter.ai 注册(支持Google/GitHub登录)
- 前往 https://openrouter.ai/keys
- 点击创建密钥
- 复制密钥(以sk-or-开头)
准备好API密钥后请告知我。
步骤2:获取API密钥
请用户提供他们的API密钥。密钥应以sk-or-开头。
步骤3:询问用户想要哪个模型
如果用户已指定模型,则使用该模型。否则,推荐:
推荐:Claude Sonnet 4.5(openrouter/anthropic/claude-sonnet-4-5)——对于大多数任务而言,能力和成本的最佳平衡。
其他热门选项:
- - openrouter/anthropic/claude-opus-4-6 —— 能力最强,成本较高
- openrouter/openai/gpt-4o —— OpenAI的旗舰模型
- openrouter/google/gemini-2.5-pro —— Google的最佳模型
您希望将哪个模型设为默认模型?
步骤4:配置OpenClaw
读取当前配置,修改后写回:
bash
读取当前配置
cat ~/.openclaw/openclaw.json
使用jq更新配置。需要设置的两个字段:
- 1. env.OPENROUTERAPIKEY —— API密钥
- agents.defaults.model.primary —— 默认模型
bash
jq --arg key sk-or-用户密钥 \
--arg model openrouter/anthropic/claude-sonnet-4-5 \
.env.OPENROUTERAPIKEY = $key | .agents.defaults.model.primary = $model \
~/.openclaw/openclaw.json > /tmp/openclaw-update.json \
&& mv /tmp/openclaw-update.json ~/.openclaw/openclaw.json
重要提示:务必先读取完整配置,再进行修改。切勿写入不完整的配置文件。
步骤5:重启网关
bash
openclaw gateway restart
等待几秒钟,然后验证:
bash
openclaw status
步骤6:确认
告知用户设置已完成,其默认模型现已设置为所选的OpenRouter模型。建议用户发送一条测试消息以验证一切正常。
模型引用格式
OpenRouter模型使用openrouter/<提供商>/<模型>格式:
- - openrouter/anthropic/claude-sonnet-4-5
- openrouter/anthropic/claude-opus-4-6
- openrouter/anthropic/claude-haiku-3-5
- openrouter/openai/gpt-4o
- openrouter/openai/o1
- openrouter/google/gemini-2.5-pro
- openrouter/meta-llama/llama-3.3-70b-instruct
完整模型列表请访问 https://openrouter.ai/models
后续切换模型
如需更改默认模型而无需重新输入API密钥:
bash
jq --arg model openrouter/anthropic/claude-opus-4-6 \
.agents.defaults.model.primary = $model \
~/.openclaw/openclaw.json > /tmp/openclaw-update.json \
&& mv /tmp/openclaw-update.json ~/.openclaw/openclaw.json
openclaw gateway restart
故障排除
- - 无效的API密钥:验证密钥是否以sk-or-开头,并在 https://openrouter.ai/credits 查看是否有余额
- 模型无响应:检查该模型是否在 https://openrouter.ai/models 上可用——某些模型可能有停机时间
- 编辑后配置损坏:问题通常是JSON格式错误。使用cat ~/.openclaw/openclaw.json | jq .读取文件以检查语法
- 更改未生效:任何配置更改后必须运行openclaw gateway restart