Spaces:
Running
Running
File size: 13,065 Bytes
c7e4cd8 c3abaa8 6ad52e8 c7e4cd8 6ad52e8 0d39314 6ad52e8 4b5ca71 c7e4cd8 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 c3abaa8 6ad52e8 be8c7bb 6ad52e8 4b5ca71 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 c3abaa8 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 c3abaa8 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 6e26197 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 4b5ca71 be8c7bb 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 6b586fa be8c7bb 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 6e26197 be8c7bb 6e26197 be8c7bb 6ad52e8 be8c7bb 6ad52e8 c3abaa8 4b5ca71 be8c7bb 6ad52e8 c3abaa8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 c3abaa8 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 c3abaa8 6ad52e8 4b5ca71 be8c7bb 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 be8c7bb 32ab05a c996923 2484e7d 32ab05a 299ce41 32ab05a 6ad52e8 be8c7bb 6ad52e8 be8c7bb 32ab05a 0d39314 32ab05a 0d39314 32ab05a 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 be8c7bb 6ad52e8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 | ---
title: HuggingClip
emoji: π
colorFrom: gray
colorTo: purple
sdk: docker
app_port: 7861
pinned: true
license: mit
secrets:
- name: HF_TOKEN
description: Hugging Face API token for database backup.
- name: CLAUDE_CODE_OAUTH_TOKEN
description: Anthropic Claude API key for Claude-powered agents.
- name: GEMINI_API_KEY
description: Google Gemini API key for Gemini-powered agents.
- name: OPENAI_API_KEY
description: OpenAI API key for GPT-powered agents.
- name: CLOUDFLARE_WORKERS_TOKEN
description: "Cloudflare API token β auto-creates a Worker proxy and KeepAlive monitor."
---
<!-- Badges -->
[](https://github.com/somratpro/huggingclip)
[](https://opensource.org/licenses/MIT)
[](https://huggingface.co/spaces/somratpro/HuggingClip)
[](https://paperclip.ing)
**Run your own AI agent orchestration platform β free, no server needed.** HuggingClip deploys [Paperclip](https://paperclip.ing) on Hugging Face Spaces, giving you a persistent AI agent platform that works with any LLM (Claude, GPT, Gemini, etc.). Deploy in minutes on the free HF Spaces tier (2 vCPU, 16GB RAM) with automatic database backup to a private HF Dataset so your agents, tasks, and conversations survive restarts.
## Table of Contents
- [β¨ Features](#-features)
- [π Quick Start](#-quick-start)
- [π Configuration](#-configuration)
- [π€ LLM Providers](#-llm-providers)
- [π Cloudflare Proxy *(Optional)*](#-cloudflare-proxy-optional)
- [πΎ Database Backup *(Optional)*](#-database-backup-optional)
- [π Staying Alive](#-staying-alive)
- [π» Local Development](#-local-development)
- [ποΈ Architecture](#οΈ-architecture)
- [π Troubleshooting](#-troubleshooting)
- [π Links](#-links)
- [π€ Contributing](#-contributing)
- [π License](#-license)
## β¨ Features
- π€ **Any LLM:** Use Claude, OpenAI GPT, Google Gemini, and more β just set the API key.
- β‘ **One-click deploy:** Duplicate the Space and add your API key β nothing else needed to get started.
- πΎ **Persistent Database:** PostgreSQL database auto-backed up to a private HF Dataset and restored on every restart β no data loss.
- π **Visual Dashboard:** Real-time status dashboard at `/` with Paperclip service health, backup status, and uptime.
- β° **Keep-Alive:** Uses `CLOUDFLARE_WORKERS_TOKEN` to automatically set up a cron-triggered keep-awake worker at boot.
- π **Cloudflare Proxy:** Auto-provisions a Cloudflare Worker proxy for blocked outbound connections.
- π **Secure by Default:** Auth secrets randomly generated on first boot and persisted across restarts.
- π **100% HF-Native:** Runs entirely on Hugging Face's free infrastructure.
## π Quick Start
### Step 1: Duplicate this Space
[](https://huggingface.co/spaces/somratpro/HuggingClip?duplicate=true)
### Step 2: Add Your Secrets
In your new Space's **Settings β Variables and secrets**, add at least one LLM key under **Secrets**:
| Secret | Description |
| :--- | :--- |
| `ANTHROPIC_API_KEY` | Claude API key from [console.anthropic.com](https://console.anthropic.com) |
| `GEMINI_API_KEY` | Google AI Studio key from [ai.google.dev](https://ai.google.dev) |
| `OPENAI_API_KEY` | OpenAI key from [platform.openai.com](https://platform.openai.com) |
> [!TIP]
> Add `HF_TOKEN` (a token with write access to your account) to enable database backup persistence. Without it, data is lost on restart.
### Step 3: Deploy & Run
The Space builds automatically. Monitor progress in the **Logs** tab. First build takes ~60s; subsequent builds are cached.
### Step 4: Set Up Admin Account
On first boot, the dashboard at `/` shows an admin setup link. Click it to create your admin account and complete Paperclip onboarding.
## π Configuration
### Required
No secrets are strictly required to start, but you need at least one LLM key to use agents:
| Variable | Description |
| :--- | :--- |
| `ANTHROPIC_API_KEY` | Claude agents |
| `GEMINI_API_KEY` | Gemini agents |
| `OPENAI_API_KEY` | OpenAI agents |
### Recommended
| Variable | Default | Description |
| :--- | :--- | :--- |
| `HF_TOKEN` | β | HF token with write access β enables DB backup persistence |
| `BACKUP_DATASET_NAME` | `huggingclip-backup` | Dataset name for backup repo |
| `SYNC_INTERVAL` | `180` | Backup interval in seconds |
### Advanced
| Variable | Default | Description |
| :--- | :--- | :--- |
| `PAPERCLIP_DEPLOYMENT_MODE` | `authenticated` | `authenticated` or `local` |
| `BETTER_AUTH_SECRET` | auto-generated | Auth secret (auto-persisted on first boot) |
| `PAPERCLIP_AGENT_JWT_SECRET` | auto-generated | Agent JWT secret (auto-persisted on first boot) |
| `SYNC_MAX_FILE_BYTES` | `52428800` | Max backup size in bytes (50MB default) |
| `CLOUDFLARE_KEEPALIVE_ENABLED` | `true` | Set to `false` to disable the automatic Cloudflare KeepAlive worker |
## π€ LLM Providers
Set the relevant API key and Paperclip will use it automatically when you configure agents:
| Provider | Secret | Get Key |
| :--- | :--- | :--- |
| **Anthropic (Claude)** | `ANTHROPIC_API_KEY` | [console.anthropic.com](https://console.anthropic.com) |
| **Google (Gemini)** | `GEMINI_API_KEY` | [ai.google.dev](https://ai.google.dev) |
| **OpenAI (GPT)** | `OPENAI_API_KEY` | [platform.openai.com](https://platform.openai.com) |
You can add multiple providers β Paperclip lets you choose the model per-agent.
## π Cloudflare Proxy *(Optional)*
Hugging Face Spaces sometimes blocks outbound connections to external APIs. HuggingClip includes the same transparent Cloudflare proxy approach used in HuggingClaw and Hugging8n.
**Automatic setup:**
1. Create a Cloudflare API Token (`Workers Scripts: Edit` permission).
2. Add `CLOUDFLARE_WORKERS_TOKEN` as a Space secret.
3. Restart the Space.
HuggingClip will:
- Create or update a Worker named from your Space host
- Generate a private shared secret automatically
- Transparently route outbound traffic through Cloudflare
| Variable | Default | Description |
| :--- | :--- | :--- |
| `CLOUDFLARE_WORKERS_TOKEN` | β | Cloudflare API token |
| `CLOUDFLARE_ACCOUNT_ID` | auto | Optional account ID override |
| `CLOUDFLARE_PROXY_DOMAINS` | β | Extra domains to proxy, merged with built-in defaults. Set to `*` to proxy all external traffic. |
## πΎ Database Backup *(Optional)*
HuggingClip automatically backs up your Paperclip PostgreSQL database to a private HF Dataset on every sync cycle and restores it on startup.
**What's backed up:**
- Full PostgreSQL SQL dump
- Paperclip config, secrets, and data files
- Packaged as `snapshots/latest.tar.gz` in your `huggingclip-backup` dataset
**Setup:** Add `HF_TOKEN` (write-access token) to Space secrets. The dataset `<your-username>/huggingclip-backup` is created automatically on first sync.
> [!NOTE]
> Without `HF_TOKEN`, the app runs fine but all data is lost on Space restart. Set it up from the start to avoid losing agent configurations.
## π Staying Alive *(Recommended on Free HF Spaces)*
Your Space will automatically be kept awake by a background Cloudflare Worker when you configure the `CLOUDFLARE_WORKERS_TOKEN` secret. The worker uses a cron trigger to regularly ping your Space's `/health` endpoint. The dashboard displays the current keep-alive worker status.
## π» Local Development
```bash
git clone https://github.com/somratpro/huggingclip.git
cd huggingclip
cp .env.example .env
# Edit .env with your API keys and HF_TOKEN
```
**With Docker:**
```bash
docker build -t huggingclip .
docker run -p 7861:7861 \
-e HF_TOKEN=hf_xxxx \
-e ANTHROPIC_API_KEY=sk-ant-xxxx \
-v paperclip_data:/paperclip \
huggingclip
```
**With Docker Compose:**
```bash
docker-compose up -d
# Dashboard: http://localhost:7861/
# Paperclip UI: http://localhost:7861/app/
```
## ποΈ Architecture
```
HuggingClip/
βββ Dockerfile # Multi-stage build: compile Paperclip from source
βββ start.sh # Orchestrator: PostgreSQL, restore, config, launch
βββ health-server.js # Dashboard, /health endpoint, reverse proxy to Paperclip
βββ paperclip-sync.py # PostgreSQL backup/restore to HF Dataset
βββ cloudflare-proxy.js # Transparent outbound proxy for blocked domains
βββ .env.example # Environment variable reference
βββ README.md
```
**Startup sequence:**
1. Validate LLM provider keys (warn if none configured).
2. Start PostgreSQL and create database.
3. Generate or restore auth secrets (persist across restarts).
4. Restore database and data files from HF Dataset backup (if `HF_TOKEN` set).
5. Start background sync loop (every `SYNC_INTERVAL` seconds).
6. Launch health server on port 7861 (dashboard + reverse proxy).
7. Generate Paperclip instance config on first boot.
8. Launch Paperclip server on port 3100.
9. Bootstrap first admin account (shows invite URL in dashboard).
10. On `SIGTERM`, wait for any in-flight sync, run final backup, exit cleanly.
**Port layout:**
| Port | Service | Public? |
| :--- | :--- | :--- |
| `7861` | Health server (dashboard + proxy) | β
Yes |
| `3100` | Paperclip API + UI | β Internal only |
| `5432` | PostgreSQL | β Internal only |
## π Troubleshooting
**No LLM providers configured warning**
Set at least one of `ANTHROPIC_API_KEY`, `GEMINI_API_KEY`, or `OPENAI_API_KEY` in Space secrets.
**Admin setup link not showing**
Check Space logs β if Paperclip started but admin setup link is missing, the bootstrap ran but found an existing account. Log in at `/app/`.
**Backup not uploading**
Verify `HF_TOKEN` is set and has write access. Check the dashboard backup status. Run manually: `python3 /app/paperclip-sync.py sync` from inside the container.
**Data lost after restart**
`HF_TOKEN` is not set. Add it and the next restart will restore from backup. The backup also needs to have been run at least once before the restart.
**Space keeps sleeping**
Add `CLOUDFLARE_WORKERS_TOKEN` as a Space secret to enable automatic keep-awake monitoring via Cloudflare Workers.
**Paperclip unreachable (502 errors)**
Wait 60β90s after boot for Paperclip to initialize. If it stays unreachable, check logs for PostgreSQL connection errors or memory issues.
**Backup too large (>50MB)**
Reduce `SYNC_MAX_FILE_BYTES` to skip large backups, or increase it. Alternatively, archive old agent runs inside Paperclip to reduce DB size.
**Stack overflow in recovery chains**
Deep issue-dependency chains (1000+ nodes) created by runaway agents can hit a 500-node limit in the upstream recovery graph traversal. This is patched conservatively in the Dockerfile. File an issue upstream at [paperclipai/paperclip](https://github.com/paperclipai/paperclip) if you need larger chains.
## π More Projects
Similar projects by [@somratpro](https://github.com/somratpro) β all free, one-click deploy on HF Spaces:
| Project | What it runs | HF Space | GitHub |
| :--- | :--- | :--- | :--- |
| **HuggingFlow** | DeerFlow β deep research agent | [Space](https://huggingface.co/spaces/somratpro/HuggingFlow) | [Repo](https://github.com/somratpro/HuggingFlow) |
| **HuggingMes** | Hermes β Self-hosted agent gateway | [Space](https://huggingface.co/spaces/somratpro/HuggingMes) | [Repo](https://github.com/somratpro/huggingmes) |
| **HuggingClaw** | OpenClaw β Claude Code in the browser | [Space](https://huggingface.co/spaces/somratpro/HuggingClaw) | [Repo](https://github.com/somratpro/huggingclaw) |
| **Hugging8n** | n8n β workflow & automation platform | [Space](https://huggingface.co/spaces/somratpro/Hugging8n) | [Repo](https://github.com/somratpro/hugging8n) |
| **HuggingPost** | Postiz β social media scheduler | [Space](https://huggingface.co/spaces/somratpro/HuggingPost) | [Repo](https://github.com/somratpro/HuggingPost) |
## π Links
- [Paperclip Docs](https://paperclip.ing)
- [Paperclip GitHub](https://github.com/paperclipai/paperclip)
- [HuggingFace Spaces Docs](https://huggingface.co/docs/hub/spaces)
## β€οΈ Support
If HuggingClip saves you time, consider buying me a coffee to keep the projects alive!
**USDT (TRC-20 / TRON network only)**
```
TELx8TJz1W1h7n6SgpgGNNGZXpJCEUZrdB
```
> [!WARNING]
> Send **USDT on TRC-20 network only**. Sending other tokens or using a different network will result in permanent loss.
## π€ Contributing
Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
## π License
MIT β see [LICENSE](LICENSE) for details.
*Made with β€οΈ by [@somratpro](https://github.com/somratpro) for the Paperclip community.*
|