Welcome to Raspberry Pi 5 repository
02. OpenClaw API-KEY Configuration
OpenClaw API-KEY Configuration
OpenClaw API-KEY Configuration1. Course Overview1.1 Course Content2. API-KEY Application2.1 Recommended Model Service Providers3. Configure OpenClaw API-KEY3.1 Configuration Method3.2 Quick Configuration3.2.1 Configure baseUrl3.2.2 Fill in apiKey and baseUrl4. View Connected Model Status4.1 View Configured Model List4.2 Verify Configuration Success5. Other Access Methods (Advanced)5.1 CLI Command Configuration API-KEY (Suitable for Beginners)5.2 Modify Configuration File (Recommended Method)Configuration File LocationEdit Configuration File6. Common Problems and Solutions6.1 API-KEY Invalid or Error6.2 Cannot Access Model Service7. Course Summary
1. Course Overview
This course will introduce in detail how to configure API-KEY for AI model services for OpenClaw, including the API-KEY application process, two configuration methods (CLI command configuration and configuration file modification), and how to verify if the configuration is successful. After completing this course, you will be able to successfully connect and use various AI major model service providers.
1.1 Course Content
- Understand the types of model service providers supported by OpenClaw
- Master the API-KEY application method
- Learn how to view and verify the status of connected models
2. API-KEY Application
2.1 Recommended Model Service Providers
OpenClaw supports many model service providers, including:
- OpenAI - GPT series (API + Codex)
- Anthropic - Claude series (API + Claude Code)
- Google - Gemini series
- Alibaba Cloud - Qwen Cloud, Tongyi Qianwen
- DeepSeek - DeepSeek models
- Zhipu AI - GLM models
- Moonshot - Kimi + Kimi Coding
- Ollama - Local models (cloud + local)
- And many other service providers
You can freely choose a model service provider based on your actual needs and network policies in your region, and register and apply for API-KEY on the corresponding official website
3. Configure OpenClaw API-KEY
3.1 Configuration Method
OpenClaw provides two methods to configure API-KEY:
CLI command configuration (suitable for beginners)
Directly modify configuration file (suitable for developers)
- Configuration file path:
$HOME/.openclaw/openclaw.json
- Configuration file path:
3.2 Quick Configuration
- The factory preset configuration file has already configured Bailian model parameters; Simply fill in your API-KEY and baseUrl to start using it directly.
- Open the OpenClaw configuration file:
xxxxxxxxxxnano $HOME/.openclaw/openclaw.json
3.2.1 Configure baseUrl
- Users need to configure the
tongyi_base_urlcorresponding to their account. Go to the Model Service Platform Bailian Console to apply for an API key. Copy the API key and OpenAI-compatible address (Base URL), then fill them into the corresponding fields.


3.2.2 Fill in apiKey and baseUrl

- After filling in, press
Ctrl+X, then pressYto confirm save, and press Enter to exit
4. View Connected Model Status
4.1 View Configured Model List
After configuration, you can use the following command to view the connected models:
xxxxxxxxxxopenclaw models list
4.2 Verify Configuration Success
Test conversation
xxxxxxxxxxopenclaw tuiStart the TUI interface, send a test message (such as "May I have your name?"), and confirm the model can respond normally.

5. Other Access Methods (Advanced)
- If you have your own model provider or need to access other model providers later, refer to the following tutorials
5.1 CLI Command Configuration API-KEY (Suitable for Beginners)
Start configuration wizard
xxxxxxxxxxopenclaw onboard
- Select 【Yes】 and press Enter

- Select QuickStart for configuration mode, press Enter

Select model service provider
- Use up and down arrows to select the service provider you have applied for API-KEY, press Enter to confirm. Here we take the Alibaba Cloud Bailian model provider as an example. The configuration method for other model providers is the same.
- Here select custom provider 【Custom Provider】

- Fill in the base_url of the model provider

- Input API-KEY
- After selecting the service provider, the system will prompt you to enter the corresponding API-KEY

- Paste or enter your applied API-KEY and press Enter to confirm

- Select OpenAI-compatible for the interface protocol

- Fill in the model name, here we take MiniMax as an example

- Endpoint ID is the model provider identifier, you can fill in freely

- Model alias (optional) can be left blank

- Other configurations
- For other configuration items, select skip as shown in the figure below, no configuration needed



- Press space to select Skip for now for Enable Hooks

- Select Restart to restart the gateway to take effect

5.2 Modify Configuration File (Recommended Method)
Configuration File Location
The configuration file is located at: $HOME/.openclaw/openclaw.json
Edit Configuration File
Open the configuration file
xxxxxxxxxxnano $HOME/.openclaw/openclaw.json# Or use your favorite editor, such as vim, code, etc.Add model provider configuration
Add or modify the
models.providerssection in the configuration file:xxxxxxxxxx{"models": {"providers": {"openai": {"apiKey": "OPENAI_API_KEY"},"anthropic": {"apiKey": "ANTHROPIC_API_KEY"},"google": {"apiKey": "GOOGLE_API_KEY"}}},"agents": {"defaults": {"model": {"primary": "openai/gpt-4"}}}}Configuration Description
models.providers: Configure API-KEY for each model service provideropenai.apiKey: OpenAI's API-KEYanthropic.apiKey: Anthropic's API-KEYgoogle.apiKey: Google's API-KEY
agents.defaults.model.primary: Set the default model to use- Format is
service provider/model name, such asopenai/gpt-4,anthropic/claude-3,google/gemini-pro
- Format is
Save and Exit
- Press
Ctrl+Oto save,Ctrl+Xto exit (nano editor)
- Factory Default Bailian Configuration (can be directly modified or referenced)
xxxxxxxxxx"models": { "mode": "merge", "providers": { "bailian": { "baseUrl": "https://dashscope.aliyuncs.com/compatible-mode/v1", "apiKey": "sk-a98b519b6bab4e35a7b82b4a95b8a4f6", "api": "openai-completions", "models": [ { "id": "qwen3.5-plus", "name": "qwen3.5-plus", "reasoning": false, "input": [ "text", "image" ], "contextWindow": 1000000, "maxTokens": 65536, "cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 } }, { "id": "MiniMax-M2.5", "name": "MiniMax-M2.5", "reasoning": false, "input": [ "text" ], "cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 }, "contextWindow": 196608, "maxTokens": 32768 }, { "id": "glm-4.7", "name": "glm-4.7", "reasoning": false, "input": [ "text" ], "cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 }, "contextWindow": 202752, "maxTokens": 16384, "compat": { "thinkingFormat": "qwen" } } ] }6. Common Problems and Solutions
6.1 API-KEY Invalid or Error
Problem: After configuration, it shows API-KEY invalid or authentication failed
Solution:
- Confirm whether the API-KEY is correct (note no extra spaces)
- Check if the API-KEY has expired or been disabled
- Confirm whether the account balance is sufficient (some service providers require pre-charging)
6.2 Cannot Access Model Service
Problem: Configuration is correct but cannot connect to model service
Solution:
- Check if the network connection is normal
- Confirm whether the network in your region can access the service provider (some services may require special network configuration)
- Try changing to another model service provider for testing
7. Course Summary
Through this course, you have mastered:
✅ Types of model service providers supported by OpenClaw ✅ API-KEY application method and precautions ✅ CLI command configuration method (suitable for beginners) ✅ Configuration file modification method (suitable for developers) ✅ How to view and verify model configuration status ✅ Troubleshooting and solutions for common problems