Difficulty: ⭐⭐⭐☆☆ (Medium) | Duration: 15-20 minutes | Outcome: Learn how to call mainstream AI models like DeepSeek/Claude/ChatGPT at zero cost
Target Audience
This article is aimed at developers with 1-3 years of experience. You do not need to be a large model expert, but you should:
- Be familiar with basic command line operations
- Have a basic understanding of Node.js
- Want to know how to call AI models without spending a dime
Core Dependencies and Environment
Before starting, let's prepare the development environment. You need to install the following software:
| Dependency | Version Requirement | Description |
|---|---|---|
| Node.js | >= 22.12.0 | Basis for project operation |
| pnpm | >= 9.0.0 | Package management tool |
| Chrome | Latest version | Browser automation |
TIP
It is recommended to use nvm (Node Version Manager) to manage Node.js versions. You can switch with one command:
nvm install 22 && nvm use 22
Operating System Support: macOS, Linux, Windows (WSL2). If you are using Windows, installing WSL2 is the easiest option; a single command wsl --install will do the trick.
Project Structure
Once cloned, you'll find the project structure to be very clear:
openclaw-zero-token/
├── src/
│ ├── providers/ # Authentication modules and API clients for various platforms
│ │ ├── deepseek-web-auth.ts
│ │ ├── deepseek-web-client.ts
│ │ ├── claude-web-auth.ts
│ │ └── doubao-web-client.ts
│ ├── agents/ # Streaming response handling
│ ├── commands/ # Authentication process commands
│ └── browser/ # Core for Chrome automation
├── ui/ # Web UI (Lit 3.x)
├── .openclaw-state/ # Local state (where credentials are stored)
│ ├── openclaw.json # Configuration file
│ └── agents/main/agent/
│ └── auth.json # Sensitive credentials
├── scripts/ # Utility scripts
├── onboard.sh # Configuration wizard
├── server.sh # Service management script
└── start-chrome-debug.sh # Chrome debug startup
Step-by-Step Tutorial
Next, we will complete the entire configuration process step by step.
Step 1: Clone the Project and Install Dependencies
First, pull the project to your local machine, then install the dependencies:
# Clone the repository
git clone https://github.com/linuxhsj/openclaw-zero-token.git
cd openclaw-zero-token
# Install dependencies (pnpm will automatically handle all sub-dependencies)
pnpm install
WARNING
If you are using an M-series Mac, ensure that Node.js is the ARM version, or you may encounter compilation issues. Use nvm ls to confirm the architecture currently in use.
Step 2: Compile the Project
The project is written in TypeScript, so you need to compile it to JavaScript before it can run:
# Compile TypeScript
pnpm build
Once compilation is complete, you will see a dist directory created. This is where the compiled code resides.
Next, build the Web UI (optional but recommended, as you will need it when accessing http://127.0.0.1:3001):
pnpm ui:build
Step 3: Start Chrome Debug Mode
This is the crucial step—we need a Chrome browser that can be remotely debugged. The project's script will help you with this automatically:
./start-chrome-debug.sh
After running, you will see a Chrome window pop up. This window is used specifically for logging into various AI platforms, and its debug port 9222 is open.
TIP
If this is your first time running it, the script may prompt you to create a user data directory. Just confirm; all login information will be stored in this directory.
Step 4: Log into AI Platforms
In the Chrome browser that just appeared, open the websites of the AI platforms you want to use:
- DeepSeek: https://chat.deepseek.com
- Claude Web: https://claude.ai
- ChatGPT: https://chat.openai.com
- Kimi: https://kimi.moonshot.cn
- Qwen: https://chat.qwen.ai
- Doubao: https://www.doubao.com
Log in using your username and password or via QR code. You need to log in separately for each platform.
WARNING
The order of logging in matters: log into all platforms except DeepSeek first, and log into DeepSeek last. This small design trick makes credential capture more stable.
Step 5: Run the Configuration Wizard (Onboard)
Now return to the terminal and run the configuration wizard to capture the login credentials from the browser:
./onboard.sh
Or if you prefer to run the compiled version manually:
node openclaw.mjs onboard
The configuration wizard will prompt you to select an authentication provider. Here we will use DeepSeek as an example:
? Auth provider: DeepSeek (Browser Login)
? DeepSeek Auth Mode:
> Automated Login (Recommended) # Automatically capture credentials
Manual Paste # Manually paste credentials
Select “Automated Login” and wait a few seconds. The wizard will automatically:
- Connect to Chrome’s debug port
- Visit the DeepSeek page
- Capture your login credentials (Cookie, Bearer Token, etc.)
- Save them to the
auth.jsonfile
If you want to configure multiple platforms, you can run ./onboard.sh multiple times and choose a different provider each time.
Step 6: Start the Gateway Service
After authentication is configured, start the core Gateway service:
./server.sh start
Or run directly:
node openclaw.mjs gateway
Once started, the Gateway will listen on port 3001. You can open your browser and visit http://127.0.0.1:3001 to see the Web UI interface.
TIP
For daily use, managing the Gateway service is simple:
./server.sh start # Start
./server.sh stop # Stop
./server.sh restart # Restart
./server.sh status # Check status
Step 7: API Call in Practice
Now comes the exciting part—calling free AI models via API!
# Call the DeepSeek model
curl http://127.0.0.1:3001/v1/chat/completions \
-H "Authorization: Bearer YOUR_GATEWAY_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-web/deepseek-chat",
"messages": [{"role": "user", "content": "Hello, please introduce yourself in one sentence"}]
}'
WARNING
Replace YOUR_GATEWAY_TOKEN with your actual token. You can find it in .openclaw-state/openclaw.json.
Step 8: Switch Between Models
In the Web UI, you can use the /model command to switch between different AI models:
# Switch to Claude Web
/model claude-web
# Switch to Doubao
/model doubao-web
# Or specify a particular model version
/model claude-web/claude-3-5-sonnet-20241022
/model doubao-web/doubao-seed-2.0
View all available models:
/models
Example output:
Model Input Ctx Local Auth Tags
doubao-web/doubao-seed-2.0 text 63k no no default,configured,alias:Doubao Browser
claude-web/claude-3-5-sonnet-20241022 text+image 195k no no configured,alias:Claude Web
deepseek-web/deepseek-chat text 64k no no configured
Supported Models Overview
The project has been tested with a wide range of platforms and models:
| Platform | Model | Status |
|---|---|---|
| DeepSeek | deepseek-chat, deepseek-reasoner | ✅ Tested |
| Claude Web | claude-3-5-sonnet, claude-3-opus, claude-3-haiku | ✅ Tested |
| ChatGPT Web | GPT-4, GPT-4 Turbo | ✅ Tested |
| Gemini Web | Gemini Pro, Gemini Ultra | ✅ Tested |
| Kimi | Moonshot v1 8K/32K/128K | ✅ Tested |
| Qwen (International) | Qwen 3.5 Plus, Qwen 3.5 Turbo | ✅ Tested |
| Qwen (China) | Qwen 3.5 Plus, Qwen 3.5 Turbo | ✅ Tested |
| Doubao | doubao-seed-2.0, doubao-pro | ✅ Tested |
| GLM Web | glm-4-Plus, glm-4-Think | ✅ Tested |
| Grok Web | Grok 1, Grok 2 | ✅ Tested |
| Manus API | Manus 1.6, Manus 1.6 Lite | ✅ Tested |
Common Troubleshooting
Issue 1: Cannot Connect to Chrome Debug Mode
Symptom: After running ./start-chrome-debug.sh, onboard reports it cannot connect to the browser.
Solution:
- Check whether the Chrome process is running:
ps aux | grep Chrome - Confirm that port 9222 is listening:
lsof -i :9222 - If the port is occupied, kill the process:
kill -9 <PID>
Issue 2: Credential Capture Fails
Symptom: The onboard process waits for a long time and eventually times out.
Solution:
- Ensure you have completed login in Chrome
- Refresh the target AI platform page
- Re-run
./onboard.shand choose “Manual Paste” mode to copy cookies manually
Issue 3: API Call Returns 401
Symptom: The curl request returns unauthorized.
Solution:
- Check whether the token is correct: find
gateway.auth.tokenin.openclaw-state/openclaw.json - Confirm that the Gateway service is running:
./server.sh status - Try restarting the service:
./server.sh restart
Issue 4: Session Expired
Symptom: API calls suddenly fail with login-related errors.
Solution:
- Open the previously started Chrome debug window
- Log in again to the corresponding AI platform
- Run
./onboard.shagain to recapture credentials
Issue 5: Model Switch Not Taking Effect
Symptom: After switching models, the API still returns results from the previous model.
Solution:
- Restart the Gateway service:
./server.sh restart - Check that the model name is correct (case-sensitive, including slashes)
- Use
/modelsto confirm the model appears in the list
Issue 6: Port 3001 Already in Use
Symptom: Starting the Gateway shows “Port 3001 already in use.”
Solution:
- Find the process occupying the port:
lsof -i :3001 - Kill it:
kill -9 <PID> - Or modify the configuration file to use a different port
Advanced Directions
Once you’ve mastered the basics, you can explore more advanced features:
1. Tool Calling
All supported tool-calling models can execute local commands, read/write files, and automate browsers. This means AI can not only answer questions, but also actually help you perform tasks—such as writing code, manipulating files, or even controlling a browser.
2. Configure Multiple Platforms Simultaneously
You can configure multiple platforms in separate onboard runs, then switch anytime using /model. For example, use Claude for coding in the morning, DeepSeek for reasoning in the afternoon, and Kimi for reading long documents at night.
3. Custom Providers
The project is open source. You can add support for new platforms in the src/providers/ directory. As long as you follow the existing template to implement authentication and an API client, you can integrate any AI model with a web version.
4. Security Hardening
WARNING
Granting AI access to your local terminal and files carries risks. It is recommended to:
- Use a dedicated workspace directory to limit file access scope
- Enable manual confirmation for dangerous operations (such as deleting files or executing destructive commands)
- Regularly check logs in the
.openclaw-statedirectory
How It Works (Brief Overview)
You might wonder: how does this achieve “token-free” API calls? The core principle is actually straightforward:
- Browser Automation: Use Playwright to control Chrome and connect via the CDP (Chrome DevTools Protocol)
- Credential Capture: Listen to network requests, extract Authorization headers, and obtain session IDs from cookies
- API Forwarding: Use captured credentials to send requests to the platform’s Web API, then convert responses into an OpenAI-compatible format
That’s why you must keep the Chrome debug window running—all requests are sent from that browser context.