OpenClaw Native Windows Installation and Deployment
OpenClaw Windows Native Installation and Deployment
Section titled “OpenClaw Windows Native Installation and Deployment”Page Overview
Tutorial: OpenClaw Windows Native Installation and Deployment, plus Connecting Claude API Access via 4All API Aggregation Relay
Section titled “Tutorial: OpenClaw Windows Native Installation and Deployment, plus Connecting Claude API Access via 4All API Aggregation Relay”OpenClaw (formerly Clawdbot / MoltBot) is an open-source, local-first AI Agent gateway that connects large language models to your local system and messaging platforms (Telegram, WhatsApp, Discord, Feishu, WeCom, etc.), enabling a 24/7 personal AI assistant.
This tutorial will walk you through the full process, from setting up the underlying environment and connecting to LLM APIs, to deploying it as an automated bot in the Feishu workspace, and obtaining a Claude apikey through a custom Base URL + API Key integration to access Claude models.
1. Preparation Before Installation
Section titled “1. Preparation Before Installation”1.1 System Requirements
Section titled “1.1 System Requirements”- Windows 10 / Windows 11
- Node.js 22+ LTS
- Git
- At least 2GB of free disk space
- 4All API APIKey
1.2 Install Node.js
Section titled “1.2 Install Node.js”- Visit the [Node.js official website] https://nodejs.org and download the Windows installer for Node.js 22 LTS (.msi).
- Run the installer and check “Automatically install the necessary tools”.
- After installation, close and reopen PowerShell, then verify the installation:
node --version # Should display v22.x.xnpm --version # Should display the version numberTip: If you get a message saying node is not recognized as a command, manually add C:\Program Files\nodejs\ to the system PATH environment variable, or restart your computer.
1.3 Install Git
Section titled “1.3 Install Git”Run the following command in PowerShell:
winget install Git.Git(or download and install it from the [Git official website] https://git-scm.com . On the website, choose the installer based on your computer architecture (for example, Windows x64). Regular users do not need to worry about advanced settings; keep the default options and complete the installation. During installation, choose “Use Git from the command line and also from 3rd-party software”.)
After installation, close and reopen PowerShell, then verify:
git --version2. Install OpenClaw Natively on Windows via PowerShell
Section titled “2. Install OpenClaw Natively on Windows via PowerShell”2.1 Configure the PowerShell Environment
Section titled “2.1 Configure the PowerShell Environment”Open PowerShell as administrator (right-click the Start menu → Windows PowerShell (Administrator)), then run the following commands one by one:
# Allow script executionSet-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
# Change the npm global install directory (to avoid permission conflicts)npm config set prefix "C:\npm"npm config set cache "C:\npm-cache"
# Add the new directory to the user PATH[Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\npm", "User")After the commands finish, close PowerShell and open a new window (so PATH takes effect).
2.2 Install OpenClaw
Section titled “2.2 Install OpenClaw”There are two ways to do this; it is recommended to try Method 1 first:
Method 1: One-click installation script
iwr -useb https://openclaw.ai/install.ps1 | iexMethod 2: Manual npm installation (if the one-click script fails)
npm install -g openclawCommon error fixes:
node.exeapplication error: Temporarily turn off Windows Defender real-time protection and try again.spawn git ENOENT: Git is not installed, or PowerShell has not been restarted. Install Git first, then reopen the window.- Permission errors: Run PowerShell as administrator.
2.3 Run the Setup Wizard
Section titled “2.3 Run the Setup Wizard”The setup wizard will ask you the following questions in sequence:
-
Security confirmation: Use the arrow keys to select “Yes” (confirming that you understand OpenClaw has system access permissions).
-
Installation mode: Choose “QuickStart” to complete the basic configuration quickly.
-
Choose an LLM provider: You can pick any option for now or skip it. You can also choose No to skip this step. We’ll manually configure the 4All API apikey service later.
-
Messaging platform configuration (optional): Telegram / WhatsApp / Discord / DingTalk / Feishu / WeCom / QQ, etc. can be configured later.
-
Shell completion (optional): It is recommended to choose Yes to speed up command entry.
-
Package manager: Choose npm.
-
For the remaining options, choose “No/Default”.
Tip: If you want to configure the API during the setup process, you can skip LLM selection for now and manually edit the configuration file after installation (see the next chapter). This is more flexible.
2.4 Verify the Installation
Section titled “2.4 Verify the Installation”Open http://127.0.0.1:18789/ in your browser. If it shows “unauthorized”, run the openclaw dashboard command in the terminal, which will print a link containing ?token=...; open that link instead.
Note: If the Gateway fails to install as a background service (administrator privileges required), you can start it manually in foreground mode: openclaw gateway --port 18789
3. Configure 4All API Proxy Access to Obtain Claude APIkey for LLM Services
Section titled “3. Configure 4All API Proxy Access to Obtain Claude APIkey for LLM Services”To connect Claude through the 4All API proxy (API Proxy / Relay), you need two things:
- Base URL: the API address provided by the 4All API service
- API Key: the secret key issued to you by the 4All API service
3.1 Confirm Your Relay Service Information
Section titled “3.1 Confirm Your Relay Service Information”| Item | Example | Description |
|---|---|---|
| Base URL | https://sg.4All API.com | Proxy service API address |
| API Key | sk-xxxxxxxxxxxxxxxx | The secret key from the relay service |
| Supported models | claude-sonnet-4-5-20250929, GPT-5, Gemini-3-Pro, etc. | Check the 4All API model marketplace for supported models |
Key point: The 4All API aggregation service is compatible with both Anthropic native format (anthropic-messages) and OpenAI-compatible format (openai-completions).
3.2 Edit the OpenClaw Configuration File
Section titled “3.2 Edit the OpenClaw Configuration File”By default, OpenClaw’s configuration file is located at: C:\Users\your-username\.openclaw\openclaw.json. Open it with Notepad, VS Code, or any text editor.
3.3 Configuration Option A: 4All API Compatible with Anthropic Native Format (Recommended)
Section titled “3.3 Configuration Option A: 4All API Compatible with Anthropic Native Format (Recommended)”If the service supports Anthropic native API (/v1/messages endpoint), use the anthropic-messages format. This is the recommended option and allows you to use all of Claude’s advanced features. Add or modify the following in openclaw.json:
Clear openclaw.json and paste the following complete version, including "name": "Claude Sonnet 4.5":
{ "models": { "providers": { "4All API": { "api": "anthropic-messages", "baseUrl": "https://sg.4All API.com", "apiKey": "sk-在这里填入你在4All API生成的真实密钥", "headers": { "anthropic-version": "2023-06-01", "anthropic-beta": "" }, "models": [ { "id": "claude-sonnet-4-5-20250929", "name": "Claude Sonnet 4.5", "contextWindow": 200000, "maxTokens": 8192, "reasoning": true } ] } } }, "agents": { "defaults": { "model": { "primary": "4All API/claude-sonnet-4-5-20250929" } } }}(Reminder: Don’t forget to replace your sk-... key.)
Save and exit, then go back to PowerShell and run the following again:
Step 1: Reset local mode. Run this command in PowerShell:
openclaw config set gateway.mode localStep 2: Start the gateway again. Immediately run the startup command:
openclaw gateway --port 18789Keep this window open, switch to your browser, refresh the Dashboard page (http://127.0.0.1:18789), and send Claude your first message to test it!
Notes:
- Do not add
/v1to the end ofbaseUrl. When OpenClaw uses this format, it will automatically append/v1/messages. If the URL already includes/v1, it will become/v1/v1/messages, causing a 404 error. "api": "anthropic-messages"must be set, otherwise it will default to OpenAI-compatible mode.anthropic-versioninheadersis generally set to"2023-06-01".- The model
idmust match the actual model supported by the relay service. - If the relay service is not compatible with the
thinking/reasoningfeature, you can setanthropic-betato an empty string inheadersto disable it.
3.4 Configuration Option B: 4All API Compatible with OpenAI Format
Section titled “3.4 Configuration Option B: 4All API Compatible with OpenAI Format”In the latest OpenClaw 2026 version, we must strictly follow the required nested structure, while also adding the new mandatory name field and routing configuration.
Below is the fully refactored and optimized final OpenAI-compatible version. You can copy and use it directly:
{ "gateway": { "mode": "local" }, "models": { "providers": { "4All API": { "api": "openai-completions", "baseUrl": "https://sg.4All API.com/v1", "apiKey": "sk-xxxxxxxxxxxxxxxx", "models": [ { "id": "gpt-4.1", "name": "GPT-4.1", "contextWindow": 128000, "maxTokens": 4096 } ] } } }, "agents": { "defaults": { "model": { "primary": "4All API/gpt-4.1" } } }}💡 Core Optimization Points of the New JSON Version:
Section titled “💡 Core Optimization Points of the New JSON Version:”- Fully adapted to the latest architecture:
api,baseUrl, andapiKeyare all placed undermodels.providers.4All API, completely eliminatingUnrecognized keyserrors. - Keep the
/v1suffix: unlike the Anthropic native format, the standard path for OpenAI-compatible interfaces ends with/v1, so"baseUrl": "https://sg.4All API.com/v1"is the correct standard format. - Add required fields:
"name": "GPT-4.1"is included. Without this field, the Dashboard will fail because it cannot read the display name and will reportreceived undefined. - Add context parameters:
contextWindowandmaxTokensare included so the gateway can manage memory length more precisely. - Connect the primary model routing:
agents.defaultsexplicitly sets the default model to4All API/gpt-4.1, ensuring there is a model ready to handle messages.
3.5 Quick Comparison of the Two Formats
Section titled “3.5 Quick Comparison of the Two Formats”| Comparison Item | anthropic-messages (Recommended) | openai-completions |
|---|---|---|
api field | "anthropic-messages" | "openai-completions" |
baseUrl ending | Do not add /v1 | Must include /v1 |
| Prompt Caching | Supported | Not supported |
| Extended Thinking | Supported | Not supported |
| Tool Calling stability | Better (native format) | May have compatibility issues |
| Use case | Relay supports Anthropic native API | Relay supports OpenAI native interface |
Recommendation: If both formats are supported, prefer anthropic-messages.
4. Example Configuration File for Automatic Primary/Backup Model Switching with Anthropic
Section titled “4. Example Configuration File for Automatic Primary/Backup Model Switching with Anthropic”This is the fully compatible openclaw.json for the latest 2026 OpenClaw version. It supports automatic switching between primary and backup models and fixes all format validation requirements.
You can copy it directly and completely overwrite the existing file content:
{ "gateway": { "mode": "local" }, "models": { "providers": { "4All API": { "api": "anthropic-messages", "baseUrl": "https://sg.4All API.com", "apiKey": "sk-请替换为你的4All API真实密钥", "headers": { "anthropic-version": "2023-06-01", "anthropic-beta": "" }, "models": [ { "id": "claude-sonnet-4-5-20250929", "name": "Claude Sonnet 4.5", "contextWindow": 200000, "maxTokens": 8192, "reasoning": true }, { "id": "claude-opus-4-6", "name": "Claude Opus 4.6", "contextWindow": 200000, "maxTokens": 4096 } ] } } }, "agents": { "defaults": { "model": { "primary": "4All API/claude-sonnet-4-5-20250929", "fallbacks": [ "4All API/claude-opus-4-6" ] } } }}⚠️ Important reminder: After pasting, make sure to replace the sk-请替换为你的4All API真实密钥 on line 10 with the actual key you generated.
5. Example Configuration File for a “Dual-Engine” Setup Combining Claude and GPT
Section titled “5. Example Configuration File for a “Dual-Engine” Setup Combining Claude and GPT”Combining Claude and GPT is one of the most powerful ways to use a platform like 4All API as an aggregation relay. It gives your AI assistant a “dual-engine” setup that can handle complex tasks while maintaining excellent stability.
One core logic point is especially important: Claude (Anthropic protocol, without /v1) and GPT (OpenAI protocol, with /v1) use completely different underlying communication formats. In the latest OpenClaw 2026 version, we cannot mix them in the same bucket; we must split them into two separate “providers”.
Below is the carefully tuned “Claude + GPT dual-engine final version” openclaw.json configuration. You can directly add it to your Zhihu tutorial as an advanced feature example:
{ "gateway": { "mode": "local" }, "models": { "providers": { "4All API-claude": { "api": "anthropic-messages", "baseUrl": "https://sg.4All API.com", "apiKey": "sk-请替换为你的4All API真实密钥", "headers": { "anthropic-version": "2023-06-01", "anthropic-beta": "" }, "models": [ { "id": "claude-sonnet-4-5-20250929", "name": "Claude Sonnet 4.5", "contextWindow": 200000, "maxTokens": 8192, "reasoning": true } ] }, "4All API-gpt": { "api": "openai-completions", "baseUrl": "https://sg.4All API.com/v1", "apiKey": "sk-请替换为你的4All API真实密钥", "models": [ { "id": "gpt-4.1", "name": "GPT-4.1", "contextWindow": 128000, "maxTokens": 4096 } ] } } }, "agents": { "defaults": { "model": { "primary": "4All API-claude/claude-sonnet-4-5-20250929", "fallbacks": [ "4All API-gpt/gpt-4.1" ] } } }}(Reminder: Don’t forget to replace your sk-... key.)
Save and exit, then go back to PowerShell and run the following again:
Step 1: Reset local mode. Run this command in PowerShell:
openclaw config set gateway.mode localStep 2: Start the gateway again. Immediately run the startup command:
openclaw gateway --port 18789Keep this window open, switch to your browser, refresh the Dashboard page (http://127.0.0.1:18789), and send Claude your first message to test it!
💡 Key Highlights of the Dual-Engine Setup
Section titled “💡 Key Highlights of the Dual-Engine Setup”When explaining this code to readers, you can distill the following highly attractive “hardcore selling points”:
- Protocol isolation, no interference: We cleverly define two independent channels under
providers:4All API-claudeand4All API-gpt. One uses the native Anthropic protocol for peak performance, while the other uses the standard OpenAI-compatible protocol. - Shared balance, seamless integration: Although split into two channels, they both point to
sg.4All API.comand use the sameapiKey, consuming the same account balance, which makes management extremely convenient. - Enterprise-grade disaster recovery: In
agents.defaults, we set the widely recognized strongest model for coding and logic, Claude Sonnet 4.5, as the absolute primary (primary). At the same time, GPT-4.1 is placed in the backup pool (fallbacks). If Claude’s interface experiences a major network fluctuation one day, the system will switch to GPT-4.1 within milliseconds and continue answering for you, ensuring your Feishu bot never goes down 24/7!
⚙️ Core Configuration Field Reference
Section titled “⚙️ Core Configuration Field Reference”1. Gateway Basic Settings (gateway)
Section titled “1. Gateway Basic Settings (gateway)”"mode": "local": Explicitly tells OpenClaw to run in “local mode.” This is the key switch for resolving frequentGateway start blockederrors right after installation.
2. Service Provider and Network Channel (providers.4All API)
Section titled “2. Service Provider and Network Channel (providers.4All API)”This is the bridge connecting the local gateway and the 4All API relay service:
"4All API": The custom provider name prefix defined in the configuration, which will be used when calling models later."api": "anthropic-messages": Specifies the communication protocol format. Using Anthropic native protocol ensures full access to Claude’s advanced features, such as Prompt Caching."baseUrl": The server endpoint address of 4All API. Note that/v1should not be added at the end; the system will append it automatically."apiKey": The dedicated secret key used for authentication (obtained from the platform)."headers": Request header parameters."anthropic-beta": ""is intentionally set to an empty string; this is an advanced troubleshooting technique used to suppress beta features not supported by some relay services and prevent400compatibility errors.
3. Detailed Model Definition (models array)
Section titled “3. Detailed Model Definition (models array)”In this array, we register two specific models (Sonnet and Opus):
"id": The actual request ID of the LLM on the backend (for example,claude-sonnet-4-5-20250929), which must exactly match the model library supported by the platform."name": (Required in the new version) The display name shown to users in the Dashboard. If you don’t fill this in, it will cause anundefinederror."contextWindow": The size of the model’s context window (Claude models usually support 200,000 tokens). This lets the gateway know when to truncate conversation history."maxTokens": The maximum number of tokens allowed in a single response."reasoning": true: A capability flag telling the Agent that this model supports advanced logical reasoning and thinking.
4. Automated Scheduling Strategy (agents.defaults)
Section titled “4. Automated Scheduling Strategy (agents.defaults)”The core strategy area that keeps your AI assistant online:
"primary": Sets the default main working model (format: provider name/model ID). Here it is set to the more cost-effective Sonnet."fallbacks": Backup model pool. When the primary model experiences network fluctuations, API rate limiting, or becomes unavailable, the system will automatically and seamlessly switch to a backup model in the array (such as Opus) to continue responding, ensuring 24/7 service stability.
6. Advanced Configuration
Section titled “6. Advanced Configuration”5.1 Use Different Models for Multiple Agents
Section titled “5.1 Use Different Models for Multiple Agents”Assign different models to different tasks to balance cost and performance. For example: use Opus for complex tasks and Sonnet for everyday chat. This is usually configured separately for each Agent in the Dashboard.
5.2 Switch the Default Model
Section titled “5.2 Switch the Default Model”If you want to quickly switch the primary model from the command line, use:
openclaw models set <model_id>5.3 Configure Messaging Platforms (Optional)
Section titled “5.3 Configure Messaging Platforms (Optional)”After installation, you can add messaging platforms at any time. Enter the following command in the terminal and follow the prompts:
openclaw configure1. Example: Deep Integration with the Feishu Workspace
Section titled “1. Example: Deep Integration with the Feishu Workspace”-
- Create a Feishu app: Log in to the Feishu Open Platform, enter the developer console, click to create an enterprise self-built app, and fill in the bot’s name and description.
-
- Enable basic permissions: In the app settings, add bot capabilities. Go to Permission Management, search for
IM:, and enable all message-related permissions. Then click Create Version and confirm publishing (the version number can be1.0.0).
- Enable basic permissions: In the app settings, add bot capabilities. Go to Permission Management, search for
-
- Open the configuration terminal: Return to the PowerShell terminal and enter the
openclawconfiguration command to re-enter the settings interface. Choose to configure the communication channel and add Feishu; the system will automatically install the Feishu plugin via npm.
- Open the configuration terminal: Return to the PowerShell terminal and enter the
-
- Bind Feishu credentials: Copy the
App SecretandApp IDprovided by the Feishu developer console and paste them into the PowerShell terminal in sequence.
- Bind Feishu credentials: Copy the
-
- Set the communication protocol: Choose the simplest WebSocket mode. Based on your actual needs, configure private chat and group chat access permissions (for example, choose Open to allow everyone on the team to use it).
-
- Configure event callbacks: Return to the Feishu developer console. In the Events and Callbacks module, switch the subscription method to long connection, and search for and add the
Receive Messageevent.
- Configure event callbacks: Return to the Feishu developer console. In the Events and Callbacks module, switch the subscription method to long connection, and search for and add the
-
- Add the remaining permissions and publish: Go back to Feishu Permission Management, and enable additional permissions such as
Get bot basic information. Finally, be sure to publish a new version again so all settings take effect.
- Add the remaining permissions and publish: Go back to Feishu Permission Management, and enable additional permissions such as
2. Testing and Capability Expansion
Section titled “2. Testing and Capability Expansion”-
- Final integration test: Open the Feishu app or desktop client, search for and open the bot app you just created in the message list. Try sending a direct message, or add it to a group chat and mention it to ask a question, then confirm that the response latency and logic are working properly.
-
- Expand automation skills: Once basic conversation is working, you can return to the OpenClaw configuration interface and install more automation skills for it (for example, AI image generation, automated information gathering, etc.). It is strongly recommended to install only official or trusted third-party skill plugins to protect your API quota and data security.
7. Common Commands Reference
Section titled “7. Common Commands Reference”| Command | Purpose |
|---|---|
| openclaw gateway status | Check gateway status |
| op |