title: OpenCode Cloud
emoji: π€
colorFrom: blue
colorTo: indigo
sdk: docker
app_port: 4096
pinned: false
license: mit
OpenCode on Hugging Face Spaces
Run OpenCode β an open-source AI coding agent that supports 75+ LLM providers β in your browser, hosted on Hugging Face's free CPU tier.
Setup (one-time, ~2 minutes)
Duplicate this Space to your own HF account (top-right β
Duplicate Space).Add your secrets in Settings β Variables and secrets:
Secret name Required? Where to get it OPENCODE_SERVER_PASSWORDYes Any password you choose β protects the web UI ANTHROPIC_API_KEYOne of these https://console.anthropic.com OPENAI_API_KEY(pick your https://platform.openai.com/api-keys GEMINI_API_KEYprovider) https://aistudio.google.com/apikey OPENCODE_API_KEYhttps://opencode.ai/zen (curated models) The Space will rebuild (~60-90 seconds) and start on the URL shown above.
Log in with username
opencodeand the password you set.
That's it. You now have a free, browser-accessible AI coding agent.
How it works
- The
Dockerfileinstalls OpenCode via the official install script and runsopencode web. - The web UI is bound to
0.0.0.0:4096so HF's reverse proxy can reach it. - HTTP basic auth is enabled via the
OPENCODE_SERVER_PASSWORDsecret. - Your workspace lives at
/home/user/workspaceinside the container.
Using OpenCode
Once you're in the web UI:
- New session β describe what you want to build, refactor, or fix
- Files panel β browse your workspace, upload code, or open the in-browser editor
- Plan mode (press
Tab) β have the agent draft a plan before changing anything - Share β get a public link to any session for sharing or debugging
/initβ generates anAGENTS.mdfor your project so OpenCode remembers context across sessions
For full usage docs, see https://opencode.ai/docs/
Persistence: read this
Free CPU Spaces are ephemeral. Anything not pushed to git will be lost when the Space restarts (which happens after ~48h of inactivity, or when the free tier quota resets).
Recommended workflow:
- In the OpenCode terminal,
cd workspace git clone https://github.com/your-user/your-repo.git- Work on the project
git add . && git commit -m "..." && git pushbefore stepping away
For pure scratch work (no git), everything resets on restart β so commit early and often.
Caveats
- CPU only β no GPU. The agent works fine; you just can't run local LLMs here.
- Sleeps after ~48h idle on the free tier (Hugging Face does this automatically).
- Resource limits β free CPU Spaces are throttled compared to local dev. Heavy multi-file refactors can be slower.
- No outbound ports β the agent can
git clonepublic repos, but you can't expose additional services. - CORS / session storage β sessions live in the container's filesystem, so restarts wipe them. Use the
/sharecommand to save a session URL externally.
If you want to upgrade later
When you outgrow the free tier:
| Need | Upgrade to |
|---|---|
| Always-on, no sleep | HF Spaces paid CPU ($0.03/hr β $5/mo) |
| Persistent storage | HF Spaces Storage bucket add-on |
| More CPU/RAM | Spaces hardware upgrade to cpu-upgrade or cpu-performance |
| Always-on + git auto-sync | Self-host on Oracle Cloud Always Free (24GB RAM, 4 ARM cores) β different guide |
License
MIT. OpenCode is Β© Anomaly. This Dockerfile is just glue.