hf-studio
AGENTS.md24 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), APIMart and KIE (more video and image models) 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…
- Reads credentials
- Installs packages
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 33,398 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
8 rules. About 0 are common, 0 are distinctive, and 8 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.
8
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 86
Every MCP tool declares title and all four hints (readOnlyHint, destructiveHint, idempotentHint, openWorldHint).
- Very specific: line 91
Every model update also updates the home: When you add models (from any provider), list the notable new ones in the UI's home and menus: …
- Very specific: line 99
Do not make real generation calls in tests or checks.
≈ “Common” is an estimate: at least 1 in 5 of the 43,423 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), APIMart and KIE (more video and image models) 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). - Seedance 2.5 Draft (
bytedance/seedance-2.5-draft/…, on Higgsfield, APIMart and KIE): a cheap 480p draft of a Seedance 2.5 video. To get the same scene at 1080p, generatebytedance/seedance-2.5-draft/finalwithdraft_generation_id= the draft's generation id; it runs on the provider that made the draft (within 7 days on Higgsfield and KIE, 3 on APIMart) and its price is approximate. - Genjutsu Restyle (
higgsfield/genjutsu/restyle/v1.0) restyles a video and keeps its motion and audio: pick the style withlist_stylesand pass its id inpreset_id(styles change without notice). Prefer Higgsfield's own functions over imitating them: AI Influencer (higgsfield/ai-influencer) takesselectionkeys fromlist_model_options, and its sheet is animated with Genjutsu (Light) motion transfer over a motion video. Ads Studio (higgsfield/ads-studio/v1.0) makes 1 to 8 ad images from a brief and product photos (batch_size= number of images). - 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. - In clients that render MCP Apps (Claude Desktop), the tools that start a generation and
show_generationsopen a card in the chat that follows it and shows the result; the user does not need you to poll just to see it. - 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),voice_creation.py(clone a voice from samples or design one from a description, all through the ElevenLabs API),free_voices.py(free Spanish voices with edge-tts: catalog and cached samples, used by the/voicespage),pricing.py(quotes),usage.py(spend by day, provider and model for the/usagepage: quoted price, not the reconciled charge),mcp_server.py(MCP tools),mcp_ui/generation.html(MCP Apps chat card, plain HTML and JS that talks to the host over postMessage),setup.py(first run andconnect),launcher.py(start),store/(models that only APIMart and KIE sell,store: true: one module per family withMODELS, its routes and price; the router never offers them to Higgsfield. A module may also add cheaper store routes to a Higgsfield id, asseedream.py,kling_image.py,ltx.pyandmagi.pydo),catalog.json(111 model schemas, regenerated withhf-studio sync-catalog; entries whosedocs_urlis on open.higgsfield.ai are hand-written and kept),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),factory.py(Content Factory: thehf-studio/content-factorycatalog model and its worker-only provider; narrates each scene with edge-tts or ElevenLabs, renders 9:16, 16:9 or 1:1 with a pinnednpx hyperframesand mixes the voice at -14 LUFS; reports unavailable without Node.js 22+),factory_formats.py(video formats: what-if, quick and long explainers, top list, news, tutorial, versus, story, product ad and a custom one; structure, tone, pacing, durations, aspects and whether they search the web),factory_script.py(episode script format andPOST /v1/factory/scripts: Claude with structured output, or with web search and a strictsubmit_scripttool when the format researches; technical fields travel in onedataJSON string and are validated here),factory_compose.py(deterministic HyperFrames HTML: data layouts, word-synced captions, WAAPI animations, safe zones per aspect),factory_rich.py(technical layouts: KaTeX equations revealed on cue words, function plots, signals with a real FFT spectrum, three.js 3D driven byhf-seekwith a 2D fallback, diagrams, code; KaTeX and three.js vendored infactory_assets/vendor),factory_math.py(whitelist expression parser evaluated with numpy, nevereval; LaTeX checks, FFT, code highlighting, JSON safe inside<script>),factory_styles.py(the visual styles; bundled OFL fonts infactory_assets/fonts, previews inweb/public/factory),factory_world.py(hand-drawn continent outlines for the dot map),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),supercomputer.py(Supercomputer chat agent at/supercomputer: Claude with tools to find, read and propose models, ask clickable questions, web search and skills; it never generates, the user's click does),skills.py(Supercomputer skills: SKILL.md parsing and/namementions; stored in theskillstable),director.py(AI Director in a Cinema Studio project: shot list, project documents, brief sections and video frames for reviews; its agent tools and routes live inapi.py; the directing skills ship inbuiltin_skills/). - 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/. - Every model update also updates the home. When you add models (from any provider), list the notable new ones
in the UI's home and menus: the tiles in
web/src/lib/features.tsand the "models" columns inweb/src/lib/menu.ts, withbadge: "NEW". In the same change, remove"NEW"from every model that came in an earlier update: only the latest update's models are new. Features (pages such as Spaces or Content Factory) keep"NEW"for 30 days after they ship. Models with an unknown price (no route quotes them) do not go on the home. - Store routes with no price on purpose (billed by tokens, per output layer, or with an ambiguous rate) return
None, explain why inRoute.notesand are listed inUNPRICEDintests/test_routes.py. They quote asunavailableand only run if the user accepts an unknown cost. - Do not make real generation calls in tests or checks. Do not expose the UI beyond
127.0.0.1withoutSTUDIO_PASSWORD: without it the proxy does not authenticate visitors. To put it online use theDockerfile(hf-studio cloud, which refuses to start without that password); see "Deploy it to your own cloud" in README.md.
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.

