CoolFace
Apppublic

Crealink/spaces-as-agent-tools

sourceHugging Facemitupdated 5mo agoView on Hugging Face
1likes
App README

๐Ÿค– Spaces as Agent Tools

Every Gradio Space on Hugging Face exposes a plain-text `agents.md` that coding agents (Claude Code, Codex, OpenCode, Pi, etc.) can call directly โ€” no client library, no hardcoded integration.

This Space is both a live demo you can use in the browser and a reference guide you can copy into your agent.


๐Ÿ–ฅ๏ธ Browser Walkthrough

What you need

Step-by-step

1. Open the Space

Go to [โ–ถ Open the demo](https://huggingface.co/spaces/Crealink/spaces-as-agent-tools) in your browser.

You'll see three tabs at the top: ๐Ÿ” Explore a Space, โ›“๏ธ Chain: Text โ†’ Image โ†’ 3D, and ๐Ÿ“‹ curl Reference.


2. ๐Ÿ” Explore a Space (works immediately โ€” no token needed)

This tab lets you inspect any Gradio Space's agent interface.

  1. 1.The Space ID field is pre-filled with black-forest-labs/flux-klein-9b-kv
  2. 2.Click ๐Ÿ” Explore
  3. 3.You'll see three things:
  4. 4.agents.md โ€” the exact 4-line text a coding agent reads to know how to call this Space
  5. 5.curl command โ€” copy-paste this into Claude Code, Codex, or any terminal
  6. 6.API Endpoints โ€” every function the Space exposes, with parameter names, types, and defaults
Try it: Click one of the example buttons below the input (e.g. microsoft/TRELLIS.2 or Qwen/Qwen3-ASR) to explore other Spaces.
Tip: You can type any Gradio Space ID here โ€” not just the examples. Try one of your own Spaces!

3. โ›“๏ธ Chain: Text โ†’ Image โ†’ 3D (requires one-time token setup)

This tab demonstrates chaining two Spaces โ€” the same thing a coding agent does behind the scenes, but visible step by step.

One-time setup (2 minutes):

Since this demo calls GPU-powered Spaces on your behalf, it needs your Hugging Face token.

  1. 1.Create a token (if you don't have one):
  2. 2.Go to huggingface.co/settings/tokens
  3. 3.Click Create new token
  4. 4.Name it anything (e.g. "spaces-demo")
  5. 5.Type: Read is enough
  6. 6.Click Create token and copy it
  1. 1.Add the token to this Space:
  2. 2.Go to โš™๏ธ Space Settings
  3. 3.Scroll down to Variables and secrets
  4. 4.Click New secret
  5. 5.Name: HF_TOKEN
  6. 6.Value: paste your token
  7. 7.Click Save
  8. 8.The Space will restart automatically (takes ~30 seconds)

Using the chain demo:

  1. 1.Switch to the โ›“๏ธ Chain: Text โ†’ Image โ†’ 3D tab
  2. 2.Type a prompt (or keep the default: "a glowing crystal dragon perched on a rocky mountain peak")
  3. 3.Click ๐Ÿš€ Generate
  4. 4.Watch the pipeline log at the bottom as it:
  5. 5.Calls FLUX Klein 9B to generate an image from your text
  6. 6.Sends that image to TRELLIS.2 for background removal
  7. 7.Generates a 3D model from the image
  8. 8.Extracts a downloadable .GLB mesh
  9. 9.The generated image appears on the left, the 3D preview on the right, and the GLB download below
โฑ๏ธ The full pipeline takes about 1โ€“3 minutes depending on queue times.
๐Ÿ’ก This is the exact same REST protocol (POST โ†’ poll SSE) that a coding agent uses. The log shows you every step.

4. ๐Ÿ“‹ curl Reference (no token needed)

This tab is a full copy-paste cheatsheet. It covers:

  • โ€”How to read any Space's agents.md
  • โ€”How to inspect the API schema
  • โ€”How to submit a job and poll for results
  • โ€”How to chain FLUX โ†’ TRELLIS.2 end to end
  • โ€”A Python gradio_client alternative
  • โ€”Authentication tiers and quotas
For coding agent users: Copy the curl commands from this tab directly into your agent's context.

๐Ÿ”‘ How agents.md works

Every Gradio Space automatically exposes a URL:

https://huggingface.co/spaces/{owner}/{name}/agents.md

The response is always 4 lines of plain text:

To use this application (owner/name: description):
API schema: GET https://owner-name.hf.space/gradio_api/info
Call endpoint: POST https://owner-name.hf.space/gradio_api/call/{endpoint} {"data": [...]}
Poll result: GET https://owner-name.hf.space/gradio_api/call/{endpoint}/{event_id}
Auth: Bearer $HF_TOKEN

A coding agent reads this, fetches the schema to learn the parameters, and then makes standard HTTP calls. That's it.


๐Ÿ”— From any Space's UI

You don't need this demo to use agent tools. On any compatible Space page:

  1. 1.Look for the Agents button in the Space header
  2. 2.Click it โ†’ the curl command is copied to your clipboard
  3. 3.Paste it into your coding agent (Claude Code, Codex, OpenCode, etc.)

โ›“๏ธ Chaining โ€” why this is powerful

An agent can compose Spaces like building blocks:

StepSpaceInputOutput
1FLUX Klein 9Btext promptimage
2TRELLIS.2image3D model (.GLB)

The image URL from step 1 is passed directly as input to step 2. No file download, no SDK, no glue code โ€” just HTTP.

Other possible chains:

  • โ€”Text โ†’ Image โ†’ Video (FLUX โ†’ video generation Space)
  • โ€”Audio โ†’ Text โ†’ Translation (ASR Space โ†’ translation Space)
  • โ€”Image โ†’ Caption โ†’ Image (captioning Space โ†’ image gen Space)

๐Ÿ“‹ Popular Spaces to try

SpaceWhat it doesTry it
FLUX Klein 9BText โ†’ Imagecurl https://huggingface.co/spaces/black-forest-labs/flux-klein-9b-kv/agents.md
FLUX.2 Klein 9BText โ†’ Image (v2)curl https://huggingface.co/spaces/black-forest-labs/FLUX.2-klein-9B/agents.md
TRELLIS.2Image โ†’ 3D Modelcurl https://huggingface.co/spaces/microsoft/TRELLIS.2/agents.md
Qwen3 ASRAudio โ†’ Textcurl https://huggingface.co/spaces/Qwen/Qwen3-ASR/agents.md
Z-Image TurboText โ†’ Image (fast)curl https://huggingface.co/spaces/mrfakename/Z-Image-Turbo/agents.md
Find more on huggingface.co/spaces โ€” any Gradio Space has an agents.md.

๐Ÿ” Authentication tiers

TierZeroGPU quotaHow to get it
No token2 min/dayโ€”
Free account3.5 min/daySign up
PRO account25 min/dayUpgrade

Get your token at: huggingface.co/settings/tokens