Somrat Sorkar commited on
Commit
8d60ff8
Β·
unverified Β·
1 Parent(s): b77e302

Add MIT license and enhance README structure

Browse files

Added license information and improved README formatting.

Files changed (1) hide show
  1. README.md +170 -322
README.md CHANGED
@@ -6,6 +6,7 @@ colorTo: purple
6
  sdk: docker
7
  app_port: 7860
8
  pinned: true
 
9
  ---
10
 
11
  <!-- Badges -->
@@ -14,324 +15,175 @@ pinned: true
14
  [![HF Space](https://img.shields.io/badge/πŸ€—%20HuggingFace-Space-blue?style=flat-square)](https://huggingface.co/spaces)
15
  [![OpenClaw](https://img.shields.io/badge/OpenClaw-Gateway-red?style=flat-square)](https://github.com/openclaw/openclaw)
16
 
17
- # 🦞 HuggingClaw
18
-
19
- Run your own **always-on AI assistant** on HuggingFace Spaces β€” for free.
20
-
21
- Works with **any LLM** (Anthropic, OpenAI, Google), connects via **Telegram**, and persists your workspace to **HF Datasets** automatically.
22
-
23
- ### ✨ Features
24
-
25
- - **Zero-config** β€” just add 3 secrets and deploy
26
- - **Any LLM provider** β€” Claude, GPT-4, Gemini, DeepSeek, Qwen, Grok, and [40+ more](#-llm-provider-setup)
27
- - **Fast builds** β€” uses pre-built OpenClaw Docker image (minutes, not 30+)
28
- - **Smart workspace sync** β€” uses `huggingface_hub` Python library (more reliable than git for HF)
29
- - **Built-in keep-alive** β€” self-pings to prevent HF sleep (no external cron needed)
30
- - **Auto-create backup** β€” creates the HF Dataset for you if it doesn't exist
31
- - **Graceful shutdown** β€” saves workspace before container dies
32
- - **Multi-user Telegram** β€” supports comma-separated user IDs for teams
33
- - **Health endpoint** β€” `/health` for monitoring
34
- - **Password or token auth** β€” choose what works for you
35
- - **100% HF-native** β€” runs entirely on HuggingFace infrastructure
36
-
37
- ---
 
 
 
 
 
 
 
 
 
38
 
39
  ## πŸŽ₯ Video Tutorial
40
- https://www.youtube.com/watch?v=S6pl7NmjX7g&t=73s
41
 
42
- ---
43
 
44
  ## πŸš€ Quick Start
45
 
46
- ### 1. Duplicate this Space
 
47
  [![Duplicate this Space](https://huggingface.co/datasets/huggingface/badges/resolve/main/duplicate-this-space-xl.svg)](https://huggingface.co/spaces/somratpro/HuggingClaw?duplicate=true)
48
 
49
- Click the button above β†’ name it β†’ set to **Private**
50
 
51
- ### 2. Add Required Secrets
52
- Go to **Settings β†’ Secrets**:
53
 
54
- | Secret | Value |
55
- |--------|-------|
56
- | `LLM_API_KEY` | Your API key ([Anthropic](https://console.anthropic.com/) / [OpenAI](https://platform.openai.com/) / [Google](https://ai.google.dev/)) |
57
- | `LLM_MODEL` | Model to use (e.g. `google/gemini-2.5-flash`, `anthropic/claude-sonnet-4-5`, `openai/gpt-4`) |
58
- | `GATEWAY_TOKEN` | Run `openssl rand -hex 32` to generate |
59
 
60
- ### 3. Deploy
61
- That's it! The Space builds and starts automatically.
 
62
 
63
- ### 4. (Optional) Add Telegram
64
- | Secret | Value |
65
- |--------|-------|
66
- | `TELEGRAM_BOT_TOKEN` | From [@BotFather](https://t.me/BotFather) |
67
- | `TELEGRAM_USER_ID` | Your user ID ([how to find](https://t.me/userinfobot)) |
68
 
69
- ### 5. (Optional) Enable Workspace Backup
70
- | Secret | Value |
71
- |--------|-------|
72
- | `HF_USERNAME` | Your HuggingFace username |
73
- | `HF_TOKEN` | [HF token](https://huggingface.co/settings/tokens) with write access |
74
 
75
- The backup dataset (`huggingclaw-backup`) is **created automatically** β€” no manual setup needed.
76
 
77
- ---
78
 
79
- ## πŸ“‹ All Configuration Options
80
 
81
- See **`.env.example`** for the complete reference with examples.
 
 
 
 
 
82
 
83
- #### Required
84
 
85
- | Variable | Purpose |
86
- |----------|---------|
87
- | `LLM_API_KEY` | LLM provider API key |
88
- | `LLM_MODEL` | Model to use (e.g. `google/gemini-2.5-flash`, `anthropic/claude-sonnet-4-5`, `openai/gpt-4`) β€” auto-detects provider from prefix |
89
- | `GATEWAY_TOKEN` | Gateway auth token |
90
 
91
- #### Telegram
92
 
93
- | Variable | Purpose |
94
- |----------|---------|
95
- | `TELEGRAM_BOT_TOKEN` | Bot token from @BotFather |
96
- | `TELEGRAM_USER_ID` | Single user allowlist |
97
- | `TELEGRAM_USER_IDS` | Multiple users (comma-separated): `123,456,789` |
98
 
99
- #### Workspace Backup
100
 
101
- | Variable | Default | Purpose |
102
- |----------|---------|---------|
103
- | `HF_USERNAME` | β€” | Your HF username |
104
- | `HF_TOKEN` | β€” | HF token (write access) |
105
- | `BACKUP_DATASET_NAME` | `huggingclaw-backup` | Dataset name (auto-created!) |
106
- | `WORKSPACE_GIT_USER` | `openclaw@example.com` | Git commit email |
107
- | `WORKSPACE_GIT_NAME` | `OpenClaw Bot` | Git commit name |
108
 
109
- #### Background Services
110
 
111
- | Variable | Default | Purpose |
112
- |----------|---------|---------|
113
- | `KEEP_ALIVE_INTERVAL` | `300` (5 min) | Self-ping interval. `0` = disable |
114
- | `SYNC_INTERVAL` | `600` (10 min) | Auto-sync interval |
115
 
116
- #### Security (Optional)
 
 
 
 
117
 
118
- | Variable | Default | Purpose |
119
- |----------|---------|---------|
120
- | `OPENCLAW_PASSWORD` | β€” | Password auth (simpler alternative to token) |
121
- | `TRUSTED_PROXIES` | β€” | Comma-separated proxy IPs (fixes auth issues behind reverse proxies) |
122
- | `ALLOWED_ORIGINS` | β€” | Comma-separated URLs to lock down Control UI |
123
 
124
- #### Advanced
 
 
 
125
 
126
- | Variable | Default | Purpose |
127
- |----------|---------|---------|
128
- | `OPENCLAW_VERSION` | `latest` | Pin OpenClaw version |
129
- | `HEALTH_PORT` | `7861` | Health endpoint port |
130
 
131
- ---
 
 
 
 
132
 
133
- ## πŸ€– LLM Provider Setup
134
 
135
- Just set `LLM_MODEL` with the correct provider prefix β€” **any provider is supported**! The provider is auto-detected from the model name. All provider IDs from [OpenClaw docs](https://docs.openclaw.ai/concepts/model-providers).
 
 
 
 
 
 
136
 
137
- ### Anthropic (Claude)
138
- ```
139
- LLM_API_KEY=sk-ant-v0-...
140
- LLM_MODEL=anthropic/claude-sonnet-4-5
141
- ```
142
- Models: `anthropic/claude-opus-4-6` Β· `anthropic/claude-sonnet-4-6` Β· `anthropic/claude-sonnet-4-5` Β· `anthropic/claude-haiku-4-5`
143
 
144
- ### OpenAI
145
- ```
146
- LLM_API_KEY=sk-...
147
- LLM_MODEL=openai/gpt-5.4
148
- ```
149
- Models: `openai/gpt-5.4-pro` Β· `openai/gpt-5.4` Β· `openai/gpt-5.4-mini` Β· `openai/gpt-5.4-nano` Β· `openai/gpt-4.1` Β· `openai/gpt-4.1-mini`
150
 
151
- ### Google (Gemini)
152
- ```
153
- LLM_API_KEY=AIzaSy...
154
- LLM_MODEL=google/gemini-2.5-flash
155
- ```
156
- Models: `google/gemini-3.1-pro-preview` Β· `google/gemini-3-flash-preview` Β· `google/gemini-2.5-pro` Β· `google/gemini-2.5-flash`
157
 
158
- ### DeepSeek
159
- ```
160
- LLM_API_KEY=sk-...
161
- LLM_MODEL=deepseek/deepseek-v3.2
162
- ```
163
- Models: `deepseek/deepseek-v3.2` Β· `deepseek/deepseek-r1-0528` Β· `deepseek/deepseek-r1`
164
- Get key from: [DeepSeek Platform](https://platform.deepseek.com)
165
 
166
- ### OpenCode Zen (tested & verified models)
167
- ```
168
- LLM_API_KEY=your_opencode_api_key
169
- LLM_MODEL=opencode/claude-opus-4-6
170
- ```
171
- Models: `opencode/claude-opus-4-6` Β· `opencode/gpt-5.4`
172
- Get key from: [OpenCode.ai](https://opencode.ai/auth)
 
 
 
 
 
 
 
 
 
 
 
 
173
 
174
- ### OpenCode Go (low-cost open models)
175
- ```
176
- LLM_API_KEY=your_opencode_api_key
177
- LLM_MODEL=opencode-go/kimi-k2.5
178
- ```
179
- Get key from: [OpenCode.ai](https://opencode.ai/auth)
180
 
181
- ### Z.ai (GLM)
182
- ```
183
- LLM_API_KEY=your_zai_api_key
184
- LLM_MODEL=zai/glm-5
185
- ```
186
- Models: `zai/glm-5` Β· `zai/glm-5-turbo` Β· `zai/glm-4.7` Β· `zai/glm-4.7-flash`
187
- Get key from: [Z.ai](https://z.ai) Β· Note: `z-ai/` and `z.ai/` prefixes auto-normalize to `zai/`
188
 
189
- ### Moonshot (Kimi)
190
- ```
191
- LLM_API_KEY=sk-...
192
- LLM_MODEL=moonshot/kimi-k2.5
193
- ```
194
- Models: `moonshot/kimi-k2.5` Β· `moonshot/kimi-k2-thinking`
195
- Get key from: [Moonshot API](https://platform.moonshot.cn)
196
-
197
- ### Mistral
198
- ```
199
- LLM_API_KEY=your_mistral_api_key
200
- LLM_MODEL=mistral/mistral-large-latest
201
- ```
202
- Models: `mistral/mistral-large-latest` Β· `mistral/mistral-small-2603` Β· `mistral/devstral-medium` Β· `mistral/codestral-2508`
203
- Get key from: [Mistral Console](https://console.mistral.ai)
204
-
205
- ### xAI (Grok)
206
- ```
207
- LLM_API_KEY=your_xai_api_key
208
- LLM_MODEL=xai/grok-4.20-beta
209
- ```
210
- Models: `xai/grok-4.20-beta` Β· `xai/grok-4` Β· `xai/grok-4.1-fast`
211
- Get key from: [xAI Console](https://console.x.ai)
212
-
213
- ### MiniMax
214
- ```
215
- LLM_API_KEY=your_minimax_api_key
216
- LLM_MODEL=minimax/minimax-m2.7
217
- ```
218
- Models: `minimax/minimax-m2.7` Β· `minimax/minimax-m2.5`
219
- Get key from: [MiniMax Platform](https://platform.minimax.io)
220
-
221
- ### NVIDIA
222
- ```
223
- LLM_API_KEY=your_nvidia_api_key
224
- LLM_MODEL=nvidia/nemotron-3-super-120b-a12b
225
- ```
226
- Get key from: [NVIDIA API](https://api.nvidia.com)
227
-
228
- ### Xiaomi (MiMo)
229
- ```
230
- LLM_API_KEY=your_xiaomi_api_key
231
- LLM_MODEL=xiaomi/mimo-v2-pro
232
- ```
233
- Models: `xiaomi/mimo-v2-pro` Β· `xiaomi/mimo-v2-omni`
234
-
235
- ### Volcengine (Doubao / ByteDance)
236
- ```
237
- LLM_API_KEY=your_volcengine_api_key
238
- LLM_MODEL=volcengine/doubao-seed-1-8-251228
239
- ```
240
- Models: `volcengine/doubao-seed-1-8-251228` Β· `volcengine/kimi-k2-5-260127` Β· `volcengine/glm-4-7-251222`
241
- Get key from: [Volcengine](https://www.volcengine.com)
242
-
243
- ### Groq
244
- ```
245
- LLM_API_KEY=your_groq_api_key
246
- LLM_MODEL=groq/mixtral-8x7b-32768
247
  ```
248
- Get key from: [Groq Console](https://console.groq.com)
249
 
250
- ### Cohere
251
- ```
252
- LLM_API_KEY=your_cohere_api_key
253
- LLM_MODEL=cohere/command-a
254
- ```
255
- Get key from: [Cohere Dashboard](https://dashboard.cohere.com)
256
 
257
- ### HuggingFace Inference
258
- ```
259
- LLM_API_KEY=hf_your_token
260
- LLM_MODEL=huggingface/deepseek-ai/DeepSeek-R1
261
- ```
262
- Get key from: [HuggingFace Tokens](https://huggingface.co/settings/tokens)
263
 
264
- ### OpenRouter (300+ models via single API key)
265
- ```
266
- LLM_API_KEY=sk-or-v1-...
267
- LLM_MODEL=openrouter/anthropic/claude-sonnet-4-6
268
- ```
269
- With OpenRouter, you can access **every model above** with a single API key! Just prefix with `openrouter/`:
270
- - `openrouter/anthropic/claude-sonnet-4-6` β€” Anthropic Claude
271
- - `openrouter/openai/gpt-5.4` β€” OpenAI
272
- - `openrouter/deepseek/deepseek-v3.2` β€” DeepSeek
273
- - `openrouter/google/gemini-2.5-flash` β€” Google Gemini
274
- - `openrouter/meta-llama/llama-3.3-70b-instruct:free` β€” Llama (free!)
275
- - `openrouter/moonshotai/kimi-k2.5` β€” Moonshot Kimi
276
- - `openrouter/z-ai/glm-5-turbo` β€” Z.ai GLM
277
-
278
- Get key from: [OpenRouter.ai](https://openrouter.ai) Β· [Full model list](https://openrouter.ai/models)
279
-
280
- ### Kilo Gateway
281
- ```
282
- LLM_API_KEY=your_kilocode_api_key
283
- LLM_MODEL=kilocode/anthropic/claude-opus-4.6
284
- ```
285
- Get key from: [Kilo.ai](https://kilo.ai)
286
 
287
- ### Any Other Provider
288
- HuggingClaw supports **any LLM provider** that OpenClaw supports. Just use:
289
- ```
290
  LLM_API_KEY=your_api_key
291
  LLM_MODEL=provider/model-name
292
  ```
293
- The provider prefix is auto-detected and mapped to the appropriate environment variable.
294
-
295
- Full provider list: [OpenClaw Model Providers](https://docs.openclaw.ai/concepts/model-providers) Β· [OpenCode Providers](https://opencode.ai/docs/providers)
296
-
297
- ---
298
-
299
- ## πŸ“± Telegram Setup
300
-
301
- 1. Message [@BotFather](https://t.me/BotFather) β†’ `/newbot` β†’ copy the token
302
- 2. Message [@userinfobot](https://t.me/userinfobot) to get your user ID
303
- 3. Add secrets: `TELEGRAM_BOT_TOKEN` and `TELEGRAM_USER_ID`
304
- 4. Restart the Space β†’ DM your bot πŸŽ‰
305
-
306
- **Multiple users?** Use `TELEGRAM_USER_IDS=123,456,789` (comma-separated)
307
-
308
- ---
309
-
310
- ## πŸ’Ύ Workspace Backup
311
-
312
- Set `HF_USERNAME` + `HF_TOKEN` and HuggingClaw handles everything:
313
-
314
- 1. **Auto-creates** the dataset if it doesn't exist
315
- 2. **Restores** workspace on every startup
316
- 3. **Smart sync** β€” uses `huggingface_hub` Python library (handles auth, LFS, retries automatically; falls back to git if unavailable)
317
- 4. **Auto-syncs** changes every 10 minutes (configurable via `SYNC_INTERVAL`)
318
- 5. **Saves** on shutdown (graceful SIGTERM handling)
319
-
320
- Custom dataset name: `BACKUP_DATASET_NAME=my-custom-backup`
321
-
322
- ---
323
-
324
- ## πŸ’“ How It Stays Alive
325
-
326
- HF Spaces sleeps after 48h of no HTTP requests. HuggingClaw prevents this with:
327
-
328
- - **Self-ping** β€” pings its own URL every 5 min (uses HF's `SPACE_HOST` env var)
329
- - **Health endpoint** β€” returns `200 OK` with uptime info
330
- - **Zero dependencies** β€” no external cron, no third-party pinger
331
 
332
- Your Space runs forever, powered entirely by HF. 🎯
333
-
334
- ---
335
 
336
  ## πŸ’» Local Development
337
 
@@ -339,93 +191,89 @@ Your Space runs forever, powered entirely by HF. 🎯
339
  git clone https://github.com/somratpro/huggingclaw.git
340
  cd huggingclaw
341
  cp .env.example .env
342
- nano .env # fill in your values
343
  ```
344
 
345
- **Docker:**
 
346
  ```bash
347
  docker build -t huggingclaw .
348
  docker run -p 7860:7860 --env-file .env huggingclaw
349
  ```
350
 
351
  **Without Docker:**
 
352
  ```bash
353
  npm install -g openclaw@latest
354
  export $(cat .env | xargs)
355
  bash start.sh
356
  ```
357
 
358
- ---
359
 
360
- ## πŸ”— Connect via CLI
361
 
362
  ```bash
363
  npm install -g openclaw@latest
364
- openclaw channels login --gateway https://YOUR-SPACE-URL.hf.space
365
- # Enter your GATEWAY_TOKEN when prompted
366
  ```
367
 
368
- ---
369
-
370
  ## πŸ—οΈ Architecture
371
 
372
- ```
373
  HuggingClaw/
374
- β”œβ”€β”€ Dockerfile # Multi-stage build with pre-built OpenClaw image
375
- β”œβ”€β”€ start.sh # Config generator + validation + orchestrator
376
- β”œβ”€β”€ keep-alive.sh # Self-ping to prevent HF sleep
377
- β”œβ”€β”€ workspace-sync.py # Smart sync via huggingface_hub (with git fallback)
378
- β”œβ”€β”€ health-server.js # Health endpoint (/health)
379
- β”œβ”€β”€ dns-fix.js # DNS override for HF network restrictions
380
- β”œβ”€β”€ .env.example # Complete configuration reference
381
- └── README.md # You are here
382
- ```
383
-
384
- **Startup flow:**
385
- 1. Validate secrets β†’ fail fast with clear errors
386
- 2. Validate HF token β†’ warn if expired
387
- 3. Auto-create backup dataset if missing
388
- 4. Restore workspace from HF Dataset
389
- 5. Generate `openclaw.json` config from env vars
390
- 6. Print startup summary
391
- 7. Start background services (keep-alive, auto-sync)
392
- 8. Launch OpenClaw gateway
393
- 9. On SIGTERM β†’ save workspace β†’ exit cleanly
394
-
395
- ---
 
 
 
 
 
 
396
 
397
  ## πŸ› Troubleshooting
398
 
399
- **Missing secrets** β†’ Check **Settings β†’ Secrets** for `LLM_API_KEY` and `GATEWAY_TOKEN`
400
-
401
- **Telegram not working** β†’ Verify bot token is valid, check logs for `πŸ“± Enabling Telegram`
402
-
403
- **Workspace not restoring** β†’ Check `HF_USERNAME` and `HF_TOKEN` are set, token has write access
404
-
405
- **Space sleeping** β†’ Check logs for `πŸ’“ Keep-alive started`. If missing, `SPACE_HOST` might not be set
406
-
407
- **"Proxy headers detected" or auth errors** β†’ Set `TRUSTED_PROXIES` with the IPs from your Space logs (`remote=x.x.x.x`)
408
-
409
- **Control UI blocked** β†’ Set `ALLOWED_ORIGINS=https://your-space.hf.space` or check logs for origin errors
410
-
411
- **Version issues** β†’ Pin with `OPENCLAW_VERSION=2026.3.24` in secrets
412
-
413
- ---
414
 
415
  ## πŸ“š Links
416
 
417
- - [OpenClaw Docs](https://docs.openclaw.ai) Β· [OpenClaw GitHub](https://github.com/openclaw/openclaw) Β· [HF Spaces Docs](https://huggingface.co/docs/hub/spaces)
418
-
419
- ---
420
 
421
  ## 🀝 Contributing
422
 
423
- Contributions welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
424
 
425
  ## πŸ“„ License
426
 
427
  MIT β€” see [LICENSE](LICENSE) for details.
428
 
429
- ---
430
-
431
- Made with ❀️ by [@somratpro](https://github.com/somratpro) for the [OpenClaw](https://github.com/openclaw/openclaw) community
 
6
  sdk: docker
7
  app_port: 7860
8
  pinned: true
9
+ license: mit
10
  ---
11
 
12
  <!-- Badges -->
 
15
  [![HF Space](https://img.shields.io/badge/πŸ€—%20HuggingFace-Space-blue?style=flat-square)](https://huggingface.co/spaces)
16
  [![OpenClaw](https://img.shields.io/badge/OpenClaw-Gateway-red?style=flat-square)](https://github.com/openclaw/openclaw)
17
 
18
+ **Your always-on AI assistant β€” free, no server needed.** HuggingClaw runs [OpenClaw](https://openclaw.ai) on HuggingFace Spaces, giving you a 24/7 AI chat assistant Telegram. It works with *any* large language model (LLM) – Claude, ChatGPT, Gemini, etc. – and even supports custom models via [OpenRouter](https://openrouter.ai). Deploy in minutes on the free HF Spaces tier (2 vCPU, 16GB RAM, 50GB) with automatic workspace backup to a HuggingFace Dataset so your chat history and settings persist across restarts.
19
+
20
+ ## Table of Contents
21
+
22
+ - [✨ Features](#-features)
23
+ - [πŸŽ₯ Video Tutorial](#-video-tutorial)
24
+ - [πŸš€ Quick Start](#-quick-start)
25
+ - [πŸ“± Telegram Setup *(Optional)*](#-telegram-setup-optional)
26
+ - [πŸ’Ύ Workspace Backup *(Optional)*](#-workspace-backup-optional)
27
+ - [βš™οΈ Full Configuration Reference](#-full-configuration-reference)
28
+ - [πŸ€– LLM Providers](#-llm-providers)
29
+ - [πŸ’» Local Development](#-local-development)
30
+ - [πŸ”— CLI Access](#-cli-access)
31
+ - [πŸ—οΈ Architecture](#-architecture)
32
+ - [πŸ’“ Staying Alive](#-staying-alive)
33
+ - [πŸ› Troubleshooting](#-troubleshooting)
34
+ - [πŸ“š Links](#-links)
35
+ - [🀝 Contributing](#-contributing)
36
+ - [πŸ“„ License](#-license)
37
+
38
+ ## ✨ Features
39
+
40
+ - πŸ”Œ **Any LLM:** Use Claude, OpenAI GPT, Google Gemini, Grok, DeepSeek, Qwen, and 40+ providers (set `LLM_API_KEY` and `LLM_MODEL` accordingly).
41
+ - ⚑ **Zero Config:** Duplicate this Space and set **just three** secrets (LLM_API_KEY, LLM_MODEL, GATEWAY_TOKEN) – no other setup needed.
42
+ - 🐳 **Fast Builds:** Uses a pre-built OpenClaw Docker image to deploy in minutes.
43
+ - πŸ’Ύ **Workspace Backup:** Chats and settings sync to a private HF Dataset via the `huggingface_hub` (Git fallback), preserving data automatically.
44
+ - πŸ’“ **Always-On:** Built-in keep-alive pings prevent the HF Space from sleeping, so the assistant is always online.
45
+ - πŸ‘₯ **Multi-User Telegram:** Configure one or more user IDs to control who can message the bot.
46
+ - πŸ” **Flexible Auth:** Secure the Control UI with either a gateway token or password.
47
+ - 🏠 **100% HF-Native:** Runs entirely on HuggingFace’s free infrastructure (2 vCPU, 16GB RAM).
48
 
49
  ## πŸŽ₯ Video Tutorial
 
50
 
51
+ Watch a quick walkthrough on YouTube: [Deploying HuggingClaw on HF Spaces](https://www.youtube.com/watch?v=S6pl7NmjX7g&t=73s).
52
 
53
  ## πŸš€ Quick Start
54
 
55
+ ### Step 1: Duplicate this Space
56
+
57
  [![Duplicate this Space](https://huggingface.co/datasets/huggingface/badges/resolve/main/duplicate-this-space-xl.svg)](https://huggingface.co/spaces/somratpro/HuggingClaw?duplicate=true)
58
 
59
+ Click the button above to duplicate the template. And set the visibility to **Private** (recommended).
60
 
61
+ ### Step 2: Add Your Secrets
 
62
 
63
+ Navigate to your new Space's **Settings**, scroll down to the **Variables and secrets** section, and add the following three under **Secrets**:
 
 
 
 
64
 
65
+ - `LLM_API_KEY` – Your provider API key (e.g., Anthropic, OpenAI, OpenRouter).
66
+ - `LLM_MODEL` – The model ID string you wish to use (e.g., `openai/gpt-4o` or `google/gemini-2.5-flash`).
67
+ - `GATEWAY_TOKEN` – A custom password or token to secure your Control UI. *(You can use any strong password, or generate one with `openssl rand -hex 32` if you prefer).*
68
 
69
+ > [!TIP]
70
+ > HuggingClaw is completely flexible! You only need these three secrets to get started. You can set other secrets later.
 
 
 
71
 
72
+ ### Step 3: Deploy & Run
 
 
 
 
73
 
74
+ That's it! The Space will build the container and start up automatically. You can monitor the build process in the **Logs** tab.
75
 
76
+ ## πŸ“± Telegram Setup *(Optional)*
77
 
78
+ To chat via Telegram:
79
 
80
+ 1. Create a bot via [@BotFather](https://t.me/BotFather): send `/newbot`, follow prompts, and copy the bot token.
81
+ 2. Find your Telegram user ID with [@userinfobot](https://t.me/userinfobot).
82
+ 3. Add these secrets in Settings β†’ Secrets:
83
+ - `TELEGRAM_BOT_TOKEN` – The token from @BotFather.
84
+ - `TELEGRAM_USER_ID` – Your Telegram user ID (for a single user).
85
+ - `TELEGRAM_USER_IDS` – Comma-separated user IDs (for team access, e.g. `123,456,789`).
86
 
87
+ After restarting, the bot should appear online on Telegram.
88
 
89
+ ## πŸ’Ύ Workspace Backup *(Optional)*
 
 
 
 
90
 
91
+ For persistent chat history and configuration:
92
 
93
+ - Set `HF_USERNAME` to your HuggingFace username.
94
+ - Set `HF_TOKEN` to a HuggingFace token with write access.
 
 
 
95
 
96
+ Optionally set `BACKUP_DATASET_NAME` (default: `huggingclaw-backup`) to choose the HF Dataset name. On first run, HuggingClaw will create (or use) the private Dataset repo `HF_USERNAME/SPACE-backup`, then restore your workspace on startup and sync changes every 10 minutes. The workspace is also saved on graceful shutdown. This ensures your data survives restarts.
97
 
98
+ ## βš™οΈ Full Configuration Reference
 
 
 
 
 
 
99
 
100
+ See `.env.example` for complete settings. Key environment variables:
101
 
102
+ ### Core
 
 
 
103
 
104
+ | Variable | Description |
105
+ |----------------|---------------------------------------|
106
+ | `LLM_API_KEY` | LLM provider API key (e.g. OpenAI, Anthropic, etc.) |
107
+ | `LLM_MODEL` | Model ID (prefix `<provider>/`, auto-detected from prefix) |
108
+ | `GATEWAY_TOKEN`| Gateway token for Control UI access (required) |
109
 
110
+ ### Background Services
 
 
 
 
111
 
112
+ | Variable | Default | Description |
113
+ |----------------------|---------|-----------------------------------|
114
+ | `KEEP_ALIVE_INTERVAL`| `300` | Self-ping interval in seconds (0 to disable) |
115
+ | `SYNC_INTERVAL` | `600` | Workspace sync interval (sec.) to HF Dataset |
116
 
117
+ ### Security
 
 
 
118
 
119
+ | Variable | Description |
120
+ |---------------------|---------------------------------------------------|
121
+ | `OPENCLAW_PASSWORD` | (optional) Enable simple password auth instead of token |
122
+ | `TRUSTED_PROXIES` | Comma-separated IPs of HF proxies (for reverse-proxy fixes) |
123
+ | `ALLOWED_ORIGINS` | Comma-separated allowed origins for Control UI (e.g. `https://your-space.hf.space`) |
124
 
125
+ ### Workspace Backup
126
 
127
+ | Variable | Default | Description |
128
+ |---------------------|-------------------|------------------------------------------------|
129
+ | `HF_USERNAME` | β€” | Your HuggingFace username |
130
+ | `HF_TOKEN` | β€” | HF token with write access (for backups) |
131
+ | `BACKUP_DATASET_NAME`| `huggingclaw-backup`| Dataset name for backup repo (auto-created) |
132
+ | `WORKSPACE_GIT_USER`| `openclaw@example.com` | Git commit email for workspace commits |
133
+ | `WORKSPACE_GIT_NAME`| `OpenClaw Bot` | Git commit name for workspace commits |
134
 
135
+ ### Advanced
 
 
 
 
 
136
 
137
+ | Variable | Default | Description |
138
+ |---------------------|-----------|-------------------------------------|
139
+ | `OPENCLAW_VERSION` | `latest` | Pin a specific OpenClaw version |
140
+ | `HEALTH_PORT` | `7861` | Internal health endpoint port |
 
 
141
 
142
+ ## πŸ€– LLM Providers
 
 
 
 
 
143
 
144
+ HuggingClaw supports **all providers** from OpenClaw. Set `LLM_MODEL=<provider/model>` and the provider is auto-detected. For example:
 
 
 
 
 
 
145
 
146
+ | Provider | Prefix | Example Model | API Key Source |
147
+ |---------------|---------------|--------------------------------|-----------------------------------|
148
+ | **Anthropic** | `anthropic/` | `anthropic/claude-sonnet-4-6` | [Anthropic Console](https://console.anthropic.com/) |
149
+ | **OpenAI** | `openai/` | `openai/gpt-5.4` | [OpenAI Platform](https://platform.openai.com/) |
150
+ | **Google** | `google/` | `google/gemini-2.5-flash` | [AI Studio](https://ai.google.dev/) |
151
+ | **DeepSeek** | `deepseek/` | `deepseek/deepseek-v3.2` | [DeepSeek](https://platform.deepseek.com) |
152
+ | **xAI (Grok)**| `xai/` | `xai/grok-4` | [xAI](https://console.x.ai) |
153
+ | **Mistral** | `mistral/` | `mistral/mistral-large-latest` | [Mistral Console](https://console.mistral.ai) |
154
+ | **Moonshot** | `moonshot/` | `moonshot/kimi-k2.5` | [Moonshot](https://platform.moonshot.cn) |
155
+ | **Cohere** | `cohere/` | `cohere/command-a` | [Cohere Dashboard](https://dashboard.cohere.com) |
156
+ | **Groq** | `groq/` | `groq/mixtral-8x7b-32768` | [Groq](https://console.groq.com) |
157
+ | **MiniMax** | `minimax/` | `minimax/minimax-m2.7` | [MiniMax](https://platform.minimax.io) |
158
+ | **NVIDIA** | `nvidia/` | `nvidia/nemotron-3-super-120b-a12b` | [NVIDIA API](https://api.nvidia.com) |
159
+ | **Z.ai (GLM)**| `zai/` | `zai/glm-5` | [Z.ai](https://z.ai) |
160
+ | **Volcengine**| `volcengine/` | `volcengine/doubao-seed-1-8-251228` | [Volcengine](https://www.volcengine.com) |
161
+ | **HuggingFace**| `huggingface/`| `huggingface/deepseek-ai/DeepSeek-R1` | [HF Tokens](https://huggingface.co/settings/tokens) |
162
+ | **OpenCode Zen**| `opencode/` | `opencode/claude-opus-4-6` | [OpenCode.ai](https://opencode.ai/auth) |
163
+ | **OpenCode Go**| `opencode-go/`| `opencode-go/kimi-k2.5` | [OpenCode.ai](https://opencode.ai/auth) |
164
+ | **Kilo Gateway**| `kilocode/` | `kilocode/anthropic/claude-opus-4.6` | [Kilo.ai](https://kilo.ai) |
165
 
166
+ ### OpenRouter – 200+ Models with One Key
 
 
 
 
 
167
 
168
+ Get an [OpenRouter](https://openrouter.ai) API key to use *all* providers. For example:
 
 
 
 
 
 
169
 
170
+ ```bash
171
+ LLM_API_KEY=sk-or-v1-xxxxxxxx
172
+ LLM_MODEL=openrouter/openai/gpt-5.4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
173
  ```
 
174
 
175
+ Popular options include `openrouter/google/gemini-2.5-flash` or `openrouter/meta-llama/llama-3.3-70b-instruct`.
 
 
 
 
 
176
 
177
+ ### Any Other Provider
 
 
 
 
 
178
 
179
+ You can also use any custom provider:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
180
 
181
+ ```bash
 
 
182
  LLM_API_KEY=your_api_key
183
  LLM_MODEL=provider/model-name
184
  ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
 
186
+ The provider prefix in `LLM_MODEL` tells HuggingClaw how to call it. See [OpenClaw Model Providers](https://docs.openclaw.ai/concepts/model-providers) for the full list.
 
 
187
 
188
  ## πŸ’» Local Development
189
 
 
191
  git clone https://github.com/somratpro/huggingclaw.git
192
  cd huggingclaw
193
  cp .env.example .env
194
+ # Edit .env with your secret values
195
  ```
196
 
197
+ **With Docker:**
198
+
199
  ```bash
200
  docker build -t huggingclaw .
201
  docker run -p 7860:7860 --env-file .env huggingclaw
202
  ```
203
 
204
  **Without Docker:**
205
+
206
  ```bash
207
  npm install -g openclaw@latest
208
  export $(cat .env | xargs)
209
  bash start.sh
210
  ```
211
 
212
+ ## πŸ”— CLI Access
213
 
214
+ After deploying, you can connect via the OpenClaw CLI (e.g., to onboard channels or run agents):
215
 
216
  ```bash
217
  npm install -g openclaw@latest
218
+ openclaw channels login --gateway https://YOUR_SPACE_NAME.hf.space
219
+ # When prompted, enter your GATEWAY_TOKEN
220
  ```
221
 
 
 
222
  ## πŸ—οΈ Architecture
223
 
224
+ ```bash
225
  HuggingClaw/
226
+ β”œβ”€β”€ Dockerfile # Multi-stage build using pre-built OpenClaw image
227
+ β”œβ”€β”€ start.sh # Config generator, validator, and orchestrator
228
+ β”œβ”€β”€ keep-alive.sh # Self-ping to prevent HF Space sleep
229
+ β”œβ”€β”€ workspace-sync.py # Syncs workspace to HF Datasets (with Git fallback)
230
+ β”œβ”€β”€ health-server.js # /health endpoint for uptime checks
231
+ β”œβ”€β”€ dns-fix.js # DNS-over-HTTPS fallback (for blocked domains)
232
+ β”œβ”€β”€ .env.example # Environment variable reference
233
+ └── README.md # (this file)
234
+
235
+ **Startup sequence:**
236
+ 1. Validate required secrets (fail fast with clear error).
237
+ 2. Check HF token (warn if expired or missing).
238
+ 3. Auto-create backup dataset if missing.
239
+ 4. Restore workspace from HF Dataset.
240
+ 5. Generate `openclaw.json` from environment variables.
241
+ 6. Print startup summary.
242
+ 7. Launch background tasks (keep-alive, auto-sync).
243
+ 8. Launch the OpenClaw gateway (start listening).
244
+ 9. On `SIGTERM`, save workspace and exit cleanly.
245
+ ```
246
+
247
+ ## πŸ’“ Staying Alive
248
+
249
+ HuggingClaw keeps the Space awake without external cron tools:
250
+
251
+ - **Self-ping:** It periodically sends HTTP requests to its own URL (default every 5 minutes).
252
+ - **Health endpoint:** `/health` returns `200 OK` and uptime info.
253
+ - **No external deps:** Fully managed within HF Spaces (no outside pingers or servers).
254
 
255
  ## πŸ› Troubleshooting
256
 
257
+ - **Missing secrets:** Ensure `LLM_API_KEY`, `LLM_MODEL`, and `GATEWAY_TOKEN` are set in your Space **Settings β†’ Secrets**.
258
+ - **Telegram bot issues:** Verify your `TELEGRAM_BOT_TOKEN`. Check Space logs for lines like `πŸ“± Enabling Telegram`.
259
+ - **Backup restore failing:** Make sure `HF_USERNAME` and `HF_TOKEN` are correct (token needs write access to your Dataset).
260
+ - **Space keeps sleeping:** Check logs for `Keep-alive` messages. Ensure `KEEP_ALIVE_INTERVAL` isn’t set to `0`.
261
+ - **Auth errors / proxy:** If you see reverse-proxy auth errors, add the logged IPs under `TRUSTED_PROXIES` (from logs `remote=x.x.x.x`).
262
+ - **UI blocked (CORS):** Set `ALLOWED_ORIGINS=https://your-space-name.hf.space`.
263
+ - **Version mismatches:** You can pin a specific OpenClaw version via the `OPENCLAW_VERSION` secret.
 
 
 
 
 
 
 
 
264
 
265
  ## πŸ“š Links
266
 
267
+ - [OpenClaw Docs](https://docs.openclaw.ai)
268
+ - [OpenClaw GitHub](https://github.com/openclaw/openclaw)
269
+ - [HuggingFace Spaces Docs](https://huggingface.co/docs/hub/spaces)
270
 
271
  ## 🀝 Contributing
272
 
273
+ Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
274
 
275
  ## πŸ“„ License
276
 
277
  MIT β€” see [LICENSE](LICENSE) for details.
278
 
279
+ *Made with ❀️ by [@somratpro](https://github.com/somratpro) for the OpenClaw community.*