agentleFS
Jjat00Jjat00/hf-studio/AGENTS.md

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.

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
  1. Very specific:

    Run uv run hf-studio setup --no-input once .env has the key.

    line 17
  2. Very specific:

    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 …

    line 20
  3. Very specific:

    Every tool that starts a paid run needs a single-use quote_id (15 min) from quoting the exact same request.

    line 40
  4. Very specific:

    After an ambiguous error, check list_generations before calling generate again, and reuse the same idempotency_key when retrying.

    line 43
  5. Very specific:

    Before generating a sound, search list_sounds: reusing one is free.

    line 45
  6. Very specific:

    Every MCP tool declares title and all four hints (readOnlyHint, destructiveHint, idempotentHint, openWorldHint).

    line 86
  7. Very specific:

    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: …

    line 91
  8. Very specific:

    Do not make real generation calls in tests or checks.

    line 99

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

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

  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 rubberband filter).
  2. The only required secret is the Higgsfield key (HF_API_KEY, format KEY_ID:KEY_SECRET, from https://console.higgsfield.ai). ELEVENLABS_API_KEY is optional and only enables audio. APIMART_API_KEY and KIE_API_KEY are optional and make videos cheaper (uv run hf-studio providers shows them). ANTHROPIC_API_KEY is 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).
  3. Run uv run hf-studio setup --no-input once .env has the key. It validates the key without spending credits and writes the UI key to web/.env.local. A human can just run ./dev.sh (Windows: .\dev), which asks for the keys interactively.
  4. 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 only, enough for MCP). Same command on Windows, macOS and Linux; ./dev.sh and dev.cmd are shortcuts. It is a long-running process: start it in the background. Health check: GET /health.
  5. Connect an agent: uv run hf-studio connect claude-code (or codex, claude-desktop, json). It creates a new key for that client (never rotates an existing one) and registers the server. --print prints the command or config (with a new key) instead. If hf-studio is 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_cost returns every option; a generation in awaiting_approval needs the user's OK on its new price (cost_usd, and reserve_usd if the provider holds more upfront). Approving is separate and takes no quote_id: approve_fallback with max_usd and max_reserve_usd, or accept_unknown_cost=True only if the user accepts an unknown cost (no cap without max_usd). providers_status shows keys, balances and the links to sign up or top up.
  • Flow: recommend_models or find_models → get_model (read input_schema and studio_notes) → upload_media for local files → estimate_cost → tell the user the cost and wait for their OK → generate with that quote_id → get_generation until terminal is 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 pass confirm_unknown_cost=True unless the user explicitly accepts an unknown price.
  • After an ambiguous error, check list_generations before calling generate again, and reuse the same idempotency_key when 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 their el_… ids in the model's elements field and cite each as @name in the prompt; they run on APIMart and KIE only (KIE also needs image_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, generate bytedance/seedance-2.5-draft/final with draft_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 with list_styles and pass its id in preset_id (styles change without notice). Prefer Higgsfield's own functions over imitating them: AI Influencer (higgsfield/ai-influencer) takes selection keys from list_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_space build one; estimate_space_run quotes every step and the total (with a quote_id), and after the user's OK run_space runs it on the server under that budget. A run that pauses (awaiting_approval) needs the user's OK on pause.needed_total_usd before approve_space_run.
  • In clients that render MCP Apps (Claude Desktop), the tools that start a generation and show_generations open 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 in base.py, APIMart and KIE adapters; add a provider by writing a Provider subclass and listing it in registry.py), voice.py and elevenlabs_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 /voices page), pricing.py (quotes), usage.py (spend by day, provider and model for the /usage page: 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 and connect), launcher.py (start), store/ (models that only APIMart and KIE sell, store: true: one module per family with MODELS, its routes and price; the router never offers them to Higgsfield. A module may also add cheaper store routes to a Higgsfield id, as seedream.py, kling_image.py, ltx.py and magi.py do), catalog.json (111 model schemas, regenerated with hf-studio sync-catalog; entries whose docs_url is 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: the hf-studio/content-factory catalog model and its worker-only provider; narrates each scene with edge-tts or ElevenLabs, renders 9:16, 16:9 or 1:1 with a pinned npx hyperframes and 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 and POST /v1/factory/scripts: Claude with structured output, or with web search and a strict submit_script tool when the format researches; technical fields travel in one data JSON 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 by hf-seek with a 2D fallback, diagrams, code; KaTeX and three.js vendored in factory_assets/vendor), factory_math.py (whitelist expression parser evaluated with numpy, never eval; LaTeX checks, FFT, code highlighting, JSON safe inside <script>), factory_styles.py (the visual styles; bundled OFL fonts in factory_assets/fonts, previews in web/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, optional ANTHROPIC_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 /name mentions; stored in the skills table), 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 in api.py; the directing skills ship in builtin_skills/).
  • Every MCP tool declares title and all four hints (readOnlyHint, destructiveHint, idempotentHint, openWorldHint); tests/test_mcp_tools.py pins 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 in landing/public/media, all from approved generations). It is separate from web/.
  • The UI is Next.js 16, which differs from older versions: read web/AGENTS.md before touching web/.
  • 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.ts and the "models" columns in web/src/lib/menu.ts, with badge: "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 in Route.notes and are listed in UNPRICED in tests/test_routes.py. They quote as unavailable and 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.1 without STUDIO_PASSWORD: without it the proxy does not authenticate visitors. To put it online use the Dockerfile (hf-studio cloud, which refuses to start without that password); see "Deploy it to your own cloud" in README.md.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.