Skip to content

add space hardware option to create repo - #277

Merged
evalstate merged 9 commits into
huggingface:mainfrom
pngwn:create-repo-hardware
Oct 26, 2026
Merged

evalstate merged 9 commits into
huggingface:mainfrom
pngwn:create-repo-hardware

Conversation

@pngwn

@pngwn pngwn commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

create_repo takes a new optional hardware param, so an agent can create a ZeroGPU Space, or a Space on any other hardware, in one call. Today every Space it creates starts on cpu-basic, and changing that needs a second Hub API call.

{ "uri": "hf://spaces/alice/demo", "sdk": "gradio", "hardware": "zero-a10g" }
# create_repo created

URI: `hf://spaces/alice/demo`
Repo: `alice/demo`
Type: `space`
Hardware: `zero-a10g`
URL: https://huggingface.co/spaces/alice/demo

New Spaces pass hardware to createRepo, which accepts it as of @huggingface/hub 2.17.9 (huggingface/huggingface.js#2683). Duplicated Spaces pass it to the Hub duplicate endpoint. The hardware comes back in the result for Spaces.

hardware is a plain string, and the tool makes no checks of its own. The Hub's errors come back for an unknown flavor, ZeroGPU without Gradio, or an account without access. So new hardware works without a schema change, the same as #278 does for hf_jobs. The param description lists the current Space flavors from GET /api/spaces/hardware as examples. It also tells the model that a README suggested_hardware does NOT set the hardware, that ZeroGPU needs the gradio sdk and a PRO account (or a Team or Enterprise plan for an org-owned Space), and that paid flavors bill the owner as soon as the Space is created.

A contribute-repos OAuth token, the scope HuggingChat forwards, can set hardware on both endpoints (results in the comment below).

@pngwn

pngwn commented Oct 19, 2026

Copy link
Copy Markdown
Member Author

Checked the open question live. An OAuth token scoped only to contribute-repos can set hardware at creation time, on both endpoints.

The token came from the device-code flow and had scope exactly openid profile contribute-repos. The account is PRO, and every Space was private:

Endpoint hardware Result
POST /api/repos/create cpu-upgrade 200, runtime requested: cpu-upgrade
POST /api/repos/create zero-a10g 200, reached RUNNING on current: zero-a10g
POST /api/spaces/{id}/duplicate cpu-upgrade 200, reached RUNNING on current: cpu-upgrade
POST /api/spaces/{id}/duplicate zero-a10g 200, runtime requested: zero-a10g

The Hub never dropped the field: requested always matched what we sent. The same token could also delete the Spaces it created. Not tested: a non-PRO account asking for zero-a10g, and org-owned Spaces.

@pngwn
pngwn marked this pull request as draft October 19, 2026 08:57
@pngwn
pngwn marked this pull request as ready for review October 22, 2026 08:40
@evalstate
evalstate merged commit 3e803a6 into huggingface:main Oct 26, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants