| name | configure-api |
| description | Configure OpenClaw model API providers with minimal user input. Use when user wants to add, switch, or connect LLM APIs (e.g., "接入百炼", "配置DashScope", "用DeepSeek", "换个模型"). Auto-detects provider settings from known providers database — user only needs to provide API key and optionally which plan/model they want. |
Configure API
One-step LLM API provider setup for OpenClaw. User provides minimal info, you handle the rest.
Workflow
- Identify provider — from user's request, match against known providers in
{baseDir}/references/providers.json
- Ask only what's missing — typically just the API key. If the provider has multiple plans (e.g., DashScope regular vs Coding Plan), ask which one.
- Test → Apply → Verify — all in one go, no back-and-forth.
Step 1: Identify Provider
Read {baseDir}/references/providers.json for the full provider database. Match the user's intent to a provider entry. Users may say things like:
- "接入百炼" / "用阿里百炼" → dashscope
- "用 DashScope Coding Plan" → dashscope-coding
- "配置 DeepSeek" → deepseek
- "接入 MiniMax" / "海螺" → minimax
- "用硅基流动" / "SiliconFlow" → siliconflow
- "用 OpenAI" → openai
- "用火山引擎" / "豆包" → volcengine
If the provider isn't in the database, fall back to manual: ask for baseUrl, model ID, and API key.
Step 2: Ask Only What's Missing
From the matched provider entry you already know: baseUrl, api type, default model, context window, etc.
Typically only ask:
- API key (always required)
- Plan variant (only if provider has multiple, e.g., DashScope regular vs coding)
- Model choice (only if provider offers multiple models AND user didn't specify)
Do NOT ask for baseUrl, api type, maxTokens, contextWindow, etc. — these come from the provider database.
Step 3: Test → Apply → Verify
Run all three in sequence. Stop and report if any step fails.
python3 {baseDir}/scripts/configure_api.py test \
--base-url "BASE_URL" \
--api-key "API_KEY" \
--model "MODEL_ID" \
--api-type "API_TYPE"
python3 {baseDir}/scripts/configure_api.py apply \
--base-url "BASE_URL" \
--api-key "API_KEY" \
--model "MODEL_ID" \
--api-type "API_TYPE" \
--provider "PROVIDER_NAME" \
--set-default \
--alias "ALIAS" \
--context-window CONTEXT_WINDOW \
--max-tokens MAX_TOKENS
grep "gateway/reload" /tmp/openclaw/openclaw-$(date +%Y-%m-%d).log | tail -3
Success: config hot reload applied in logs.
Failure: config reload skipped (invalid config) — read error, fix, retry.
If hot reload fails due to unrecognized config keys, run openclaw doctor --fix first.
Troubleshooting
- Valid
api values: openai-completions, openai-responses, anthropic-messages, google-generative-ai, ollama. Never use openai-chat.
- Different API keys per plan: Some providers (e.g., DashScope) use different keys for different plans. Coding Plan keys start with
sk-sp-.
- Model self-identifies wrong provider: This is normal model behavior, not a config issue. Check logs for
provider= to confirm routing.