Download README.md from Crealink/spaces-as-agent-tools: direct link, hf CLI and curl.
- Browser
- Download file 7.25 kB
-
https://huggingface.co/spaces/Crealink/spaces-as-agent-tools/resolve/main/README.md
- Command line
-
hf download hf://spaces/Crealink/spaces-as-agent-tools/README.md
-
curl -L -o README.md https://huggingface.co/spaces/Crealink/spaces-as-agent-tools/resolve/main/README.md
A newer version of the Gradio SDK is available: 6.29.1
title: Spaces as Agent Tools
emoji: π€
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: 5.33.0
app_file: app.py
pinned: false
license: mit
tags:
- agents
- mcp
- spaces-api
- demo
short_description: Use any HF Space as a coding agent tool via agents.md
π€ 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 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.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:
- 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:
| Step | Space | Input | Output |
|---|---|---|---|
| 1 | FLUX Klein 9B | text prompt | image |
| 2 | TRELLIS.2 | image | 3D 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
| Space | What it does | Try it |
|---|---|---|
| FLUX Klein 9B | Text β Image | curl https://huggingface.co/spaces/black-forest-labs/flux-klein-9b-kv/agents.md |
| FLUX.2 Klein 9B | Text β Image (v2) | curl https://huggingface.co/spaces/black-forest-labs/FLUX.2-klein-9B/agents.md |
| TRELLIS.2 | Image β 3D Model | curl https://huggingface.co/spaces/microsoft/TRELLIS.2/agents.md |
| Qwen3 ASR | Audio β Text | curl https://huggingface.co/spaces/Qwen/Qwen3-ASR/agents.md |
| Z-Image Turbo | Text β 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
| Tier | ZeroGPU quota | How to get it |
|---|---|---|
| No token | 2 min/day | β |
| Free account | 3.5 min/day | Sign up |
| PRO account | 25 min/day | Upgrade |
Get your token at: huggingface.co/settings/tokens