CoolFace
Apppublic

teremir/ratsomclip

sourceHugging Facemitupdated 5mo agoView on Hugging Face
0likes
App README

<!-- Badges --> ![GitHub Stars](https://github.com/somratpro/huggingclip) ![License: MIT](https://opensource.org/licenses/MIT) ![HF Space](https://huggingface.co/spaces/somratpro/HuggingClip) ![Paperclip](https://paperclip.ing)

Run your own AI agent orchestration platform โ€” free, no server needed. HuggingClip deploys Paperclip on Hugging Face Spaces, giving you a persistent AI agent platform with NVIDIA models via OpenCode and optional Gemini support. 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

  • โ€”๐Ÿค– NVIDIA via OpenCode: Run OpenCode-backed agents with one or more NVIDIA API keys, plus optional Gemini support.
  • โ€”โšก 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

![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:

SecretDescription
NVAPI_KEYSComma-separated NVIDIA keys from build.nvidia.com
GEMINI_API_KEYGoogle AI Studio key from ai.google.dev
[!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:

VariableDescription
NVAPI_KEYSOpenCode agents using NVIDIA models; supports multiple comma-separated keys
GEMINI_API_KEYGemini agents

Recommended

VariableDefaultDescription
HF_TOKENโ€”HF token with write access โ€” enables DB backup persistence
BACKUP_DATASET_NAMEhuggingclip-backupDataset name for backup repo
SYNC_INTERVAL180Backup interval in seconds

Advanced

VariableDefaultDescription
PAPERCLIP_DEPLOYMENT_MODEauthenticatedauthenticated or local
BETTER_AUTH_SECRETauto-generatedAuth secret (auto-persisted on first boot)
PAPERCLIP_AGENT_JWT_SECRETauto-generatedAgent JWT secret (auto-persisted on first boot)
SYNC_MAX_FILE_BYTES52428800Max backup size in bytes (50MB default)
CLOUDFLARE_KEEPALIVE_ENABLEDtrueSet to false to disable the automatic Cloudflare KeepAlive worker
NVIDIA_BASE_URLโ€”Optional custom NVIDIA/OpenCode endpoint, for example a local NIM server

๐Ÿค– LLM Providers

Set the relevant provider secret and Paperclip will use it automatically when you configure agents:

ProviderSecretGet Key
NVIDIA via OpenCodeNVAPI_KEYSbuild.nvidia.com
Google (Gemini)GEMINI_API_KEYai.google.dev
NVIDIA NIM (optional)NVIDIA_BASE_URLCustom OpenAI-compatible NVIDIA endpoint

NVAPI_KEYS accepts one or more comma-separated NVIDIA API keys. HuggingClip writes them into the OpenCode runtime config and rotates them across invocations.

๐ŸŒ 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. 1.Create a Cloudflare API Token (Workers Scripts: Edit permission).
  2. 2.Add CLOUDFLARE_WORKERS_TOKEN as a Space secret.
  3. 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
VariableDefaultDescription
CLOUDFLARE_WORKERS_TOKENโ€”Cloudflare API token
CLOUDFLARE_ACCOUNT_IDautoOptional 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 NVAPI_KEYS, optional GEMINI_API_KEY, and HF_TOKEN

With Docker:

bash
docker build -t huggingclip .
docker run -p 7861:7861 \
  -e HF_TOKEN=hf_xxxx \
  -e NVAPI_KEYS=nvapi-xxxx,nvapi-yyyy \
  -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. 1.Validate LLM provider keys (warn if none configured).
  2. 2.Start PostgreSQL and create database.
  3. 3.Generate or restore auth secrets (persist across restarts).
  4. 4.Restore database and data files from HF Dataset backup (if HF_TOKEN set).
  5. 5.Start background sync loop (every SYNC_INTERVAL seconds).
  6. 6.Launch health server on port 7861 (dashboard + reverse proxy).
  7. 7.Generate Paperclip instance config on first boot.
  8. 8.Launch Paperclip server on port 3100.
  9. 9.Bootstrap first admin account (shows invite URL in dashboard).
  10. 10.On SIGTERM, wait for any in-flight sync, run final backup, exit cleanly.

Port layout:

PortServicePublic?
7861Health server (dashboard + proxy)โœ… Yes
3100Paperclip API + UIโŒ Internal only
5432PostgreSQLโŒ Internal only

๐Ÿ› Troubleshooting

No LLM providers configured warning Set at least one of NVAPI_KEYS, GEMINI_API_KEY, or NVIDIA_BASE_URL in Space secrets/variables.

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 if you need larger chains.

๐ŸŒŸ More Projects

Similar projects by @somratpro โ€” all free, one-click deploy on HF Spaces:

ProjectWhat it runsHF SpaceGitHub
HuggingFlowDeerFlow โ€” deep research agentSpaceRepo
HuggingMesHermes โ€” Self-hosted agent gatewaySpaceRepo
HuggingClawOpenClaw โ€” Claude Code in the browserSpaceRepo
Hugging8nn8n โ€” workflow & automation platformSpaceRepo
HuggingPostPostiz โ€” social media schedulerSpaceRepo

๐Ÿ“š Links

โค๏ธ 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 for guidelines.

๐Ÿ“„ License

MIT โ€” see LICENSE for details.

Made with โค๏ธ by [@somratpro](https://github.com/somratpro) for the Paperclip community.