agentleFS
Jjat00Jjat00/hf-studio/AGENTS.md

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.

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

    Do not make real generation calls in tests or checks.

    line 76

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

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) 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).
  • 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.
  • 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), free_voices.py (free Spanish voices with edge-tts: catalog and cached samples, used by the /voices page), pricing.py (quotes), mcp_server.py (MCP tools), setup.py (first run and connect), launcher.py (start), catalog.json (82 model schemas, regenerated with hf-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, optional ANTHROPIC_API_KEY).
  • 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/.
  • 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.

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.