Crealink/spaces-as-agent-tools
๐ค 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
- A free Hugging Face account
- A Hugging Face token (only for the Chain demo) โ create one here
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.
- The Space ID field is pre-filled with
black-forest-labs/flux-klein-9b-kv - Click ๐ Explore
- You'll see three things:
- agents.md โ the exact 4-line text a coding agent reads to know how to call this Space
- curl command โ copy-paste this into Claude Code, Codex, or any terminal
- 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.2orQwen/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.
- Create a token (if you don't have one):
- Go to huggingface.co/settings/tokens
- Click Create new token
- Name it anything (e.g. "spaces-demo")
- Type: Read is enough
- Click Create token and copy it
- Add the token to this Space:
- Go to โ๏ธ Space Settings
- Scroll down to Variables and secrets
- Click New secret
- Name:
HF_TOKEN - Value: paste your token
- Click Save
- The Space will restart automatically (takes ~30 seconds)
Using the chain demo:
- Switch to the โ๏ธ Chain: Text โ Image โ 3D tab
- Type a prompt (or keep the default: "a glowing crystal dragon perched on a rocky mountain peak")
- Click ๐ Generate
- Watch the pipeline log at the bottom as it:
- Calls FLUX Klein 9B to generate an image from your text
- Sends that image to TRELLIS.2 for background removal
- Generates a 3D model from the image
- Extracts a downloadable .GLB mesh
- 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_clientalternative - 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.mdThe 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_TOKENA 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:
- Look for the Agents button in the Space header
- Click it โ the curl command is copied to your clipboard
- Paste it into your coding agent (Claude Code, Codex, OpenCode, etc.)
โ๏ธ Chaining โ why this is powerful
An agent can compose Spaces like building blocks:
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
Find more on huggingface.co/spaces โ any Gradio Space has an agents.md.๐ Authentication tiers
Get your token at: huggingface.co/settings/tokens
