hf-studio
AGENTS.md9 starsChanged 2 months agoMITView on GitHub
Guide for AI agents (Claude Code, Codex, Cursor…) working with HF Studio. Humans: see README.md. HF Studio is a self-hosted studio on the Higgsfield (video, image) and ElevenLabs (audio) APIs: a FastAPI backend (src/hf_studio/), an MCP server over stdio (hf-studio mcp) and a Next.js UI (web/). Generating spends the owner's credits. 1. Prerequisites: uv, and for the UI also Node.js 20+ and pnpm. ffmpeg is needed for the audio features (on macOS brew install ffmpeg-full: the plain formula lacks the…
- Reads credentials
- Installs packages
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository3 other files it gives its agents.
- web/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- web/CLAUDE.mdCLAUDE.md
The file
We split this AGENTS.md into the rules it gives an agent
7 rules. About 0 are common, 0 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 17
Run uv run hf-studio setup --no-input once .env has the key.
- Very specific: line 20
Start it with uv run hf-studio start (API on 127.0.0.1:8787 and UI on http://localhost:3000) or uv run hf-studio start --api-only (API …
- Very specific: line 40
Every tool that starts a paid run needs a single-use quote_id (15 min) from quoting the exact same request.
- Very specific: line 43
After an ambiguous error, check list_generations before calling generate again, and reuse the same idempotency_key when retrying.
- Very specific: line 45
Before generating a sound, search list_sounds: reusing one is free.
- Very specific: line 71
Every MCP tool declares title and all four hints (readOnlyHint, destructiveHint, idempotentHint, openWorldHint).
- Very specific: line 76
Do not make real generation calls in tests or checks.
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md
Guide for AI agents (Claude Code, Codex, Cursor…) working with HF Studio. Humans: see README.md.
HF Studio is a self-hosted studio on the Higgsfield (video, image) and ElevenLabs (audio) APIs: a FastAPI backend
(src/hf_studio/), an MCP server over stdio (hf-studio mcp) and a Next.js UI (web/). Generating spends the
owner's credits.
Set it up for a user
- Prerequisites:
uv, and for the UI also Node.js 20+ andpnpm.ffmpegis needed for the audio features (on macOSbrew install ffmpeg-full: the plain formula lacks therubberbandfilter). - The only required secret is the Higgsfield key (
HF_API_KEY, formatKEY_ID:KEY_SECRET, from https://console.higgsfield.ai).ELEVENLABS_API_KEYis optional and only enables audio.APIMART_API_KEYandKIE_API_KEYare optional and make videos cheaper (uv run hf-studio providersshows them).ANTHROPIC_API_KEYis optional and only enables the Assistant node in Spaces. Ask the user for the keys; never invent, print or commit them. They go in.env(created from.env.example, git-ignored). - Run
uv run hf-studio setup --no-inputonce.envhas the key. It validates the key without spending credits and writes the UI key toweb/.env.local. A human can just run./dev.sh(Windows:.\dev), which asks for the keys interactively. - Start it with
uv run hf-studio start(API on127.0.0.1:8787and UI onhttp://localhost:3000) oruv run hf-studio start --api-only(API only, enough for MCP). Same command on Windows, macOS and Linux;./dev.shanddev.cmdare shortcuts. It is a long-running process: start it in the background. Health check:GET /health. - Connect an agent:
uv run hf-studio connect claude-code(orcodex,claude-desktop,json). It creates a new key for that client (never rotates an existing one) and registers the server.--printprints the command or config (with a new key) instead. Ifhf-studiois already registered, it stops without changes. If the agent's CLI is missing, nothing is registered (exit code 0): run the printed command where that CLI is installed. The client must be restarted.
Use it through MCP
- Generations go to the cheapest provider with a key (Higgsfield, APIMart, KIE).
estimate_costreturns every option; a generation inawaiting_approvalneeds the user's OK on its new price (cost_usd, andreserve_usdif the provider holds more upfront). Approving is separate and takes noquote_id:approve_fallbackwithmax_usdandmax_reserve_usd, oraccept_unknown_cost=Trueonly if the user accepts an unknown cost (no cap withoutmax_usd).providers_statusshows keys, balances and the links to sign up or top up. - Flow:
recommend_modelsorfind_models→get_model(readinput_schemaandstudio_notes) →upload_mediafor local files →estimate_cost→ tell the user the cost and wait for their OK →generatewith thatquote_id→get_generationuntilterminalis true →download_outputs. - Every tool that starts a paid run needs a single-use
quote_id(15 min) from quoting the exact same request. Paid tools say "spends credits" in their title. Never passconfirm_unknown_cost=Trueunless the user explicitly accepts an unknown price. - After an ambiguous error, check
list_generationsbefore callinggenerateagain, and reuse the sameidempotency_keywhen retrying. - Before generating a sound, search
list_sounds: reusing one is free. - Kling 3.0 elements:
list_elements/create_element(2–4 JPG/PNG images). Put theirel_…ids in the model'selementsfield and cite each as@namein the prompt; they run on APIMart and KIE only (KIE also needsimage_url). - Spaces (node canvases):
create_space/update_spacebuild one;estimate_space_runquotes every step and the total (with aquote_id), and after the user's OKrun_spaceruns it on the server under that budget. A run that pauses (awaiting_approval) needs the user's OK onpause.needed_total_usdbeforeapprove_space_run. - The server instructions (in
src/hf_studio/mcp_server.py,INSTRUCTIONS) are the source of truth.
Work on the code
uv run pytest -q # Higgsfield and ElevenLabs are mocked: never spends credits
uv run ruff check src tests && uv run ruff format src tests
cd web && pnpm lint && pnpm exec next typegen && npx tsc --noEmit- Map:
api.py(REST routes),service.py(generation logic),worker.py(queue and polling),higgsfield.py(Higgsfield client),elements.py(Kling 3.0 elements: local images, refreshed URLs),providers/(provider contract inbase.py, APIMart and KIE adapters; add a provider by writing aProvidersubclass and listing it inregistry.py),voice.pyandelevenlabs_audio.py(ElevenLabs audio),free_voices.py(free Spanish voices with edge-tts: catalog and cached samples, used by the/voicespage),pricing.py(quotes),mcp_server.py(MCP tools),setup.py(first run andconnect),launcher.py(start),catalog.json(82 model schemas, regenerated withhf-studio sync-catalog),spaces.py(Spaces canvas: graph validation),space_runs.py(server-side runs of a canvas with an approved budget),space_tools.py(free local tools as catalog models: frame, combine, mix, run with ffmpeg by an internal worker-only provider),space_audio.py(Spaces audio nodes: voice, effect and music on ElevenLabs as catalog models),space_assistant.py(Spaces Assistant node: Claude writes text for other nodes, optionalANTHROPIC_API_KEY). - Every MCP tool declares
titleand all four hints (readOnlyHint,destructiveHint,idempotentHint,openWorldHint);tests/test_mcp_tools.pypins them. Keep them true to what the handler does. landing/is the public landing page (static Next.js 16, deployed on Vercel from that folder; media inlanding/public/media, all from approved generations). It is separate fromweb/.- The UI is Next.js 16, which differs from older versions: read
web/AGENTS.mdbefore touchingweb/. - Do not make real generation calls in tests or checks. Do not expose the UI beyond
127.0.0.1: its proxy does not authenticate visitors.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

