Skip to content

[CLI] Add hf spaces hardware command#4169

Merged
Wauplin merged 8 commits into
mainfrom
cursor/add-spaces-hardware-cmd-9495
Apr 30, 2026
Merged

[CLI] Add hf spaces hardware command#4169
Wauplin merged 8 commits into
mainfrom
cursor/add-spaces-hardware-cmd-9495

Conversation

@Wauplin

@Wauplin Wauplin commented Apr 29, 2026

Copy link
Copy Markdown
Collaborator

Follow-up #4163 (review).

Adds hf spaces hardware to list available Space hardware options (from GET /api/spaces/hardware).

list_spaces_hardware returns a JobHardware even though it's not Job's specific. Not very important, we can always change if the data format changes between Jobs and Spaces in the future.

Includes a hint at the end: "Use hf spaces settings <space_id> --hardware <name> to set hardware on a Space."

$ hf spaces hardware
NAME         PRETTY_NAME            CPU               RAM     ACCELERATOR      COST/MIN COST/HOUR
------------ ---------------------- ----------------- ------- ---------------- -------- ---------
cpu-basic    CPU Basic              2 vCPU            16 GB                    free     free     
zero-a10g    ZeroGPU                Dynamic resources -                        free     free     
cpu-upgrade  CPU Upgrade            8 vCPU            32 GB                    $0.0005  $0.03    
t4-small     Nvidia T4 - small      4 vCPU            15 GB   1x T4 (16 GB)    $0.0067  $0.40    
t4-medium    Nvidia T4 - medium     8 vCPU            30 GB   1x T4 (16 GB)    $0.0100  $0.60    
a10g-small   Nvidia A10G - small    4 vCPU            15 GB   1x A10G (24 GB)  $0.0167  $1.00    
a10g-large   Nvidia A10G - large    12 vCPU           46 GB   1x A10G (24 GB)  $0.0250  $1.50    
a10g-largex2 2x Nvidia A10G - large 24 vCPU           92 GB   2x A10G (48 GB)  $0.0500  $3.00    
a10g-largex4 4x Nvidia A10G - large 48 vCPU           184 GB  4x A10G (96 GB)  $0.0833  $5.00    
a100-large   Nvidia A100 - large    12 vCPU           142 GB  1x A100 (80 GB)  $0.0417  $2.50    
a100x4       4x Nvidia A100         48 vCPU           568 GB  4x A100 (320 GB) $0.1667  $10.00   
a100x8       8x Nvidia A100         96 vCPU           1136 GB 8x A100 (640 GB) $0.3333  $20.00   
l4x1         1x Nvidia L4           8 vCPU            30 GB   1x L4 (24 GB)    $0.0133  $0.80    
l4x4         4x Nvidia L4           48 vCPU           186 GB  1x L4 (96 GB)    $0.0633  $3.80    
l40sx1       1x Nvidia L40S         8 vCPU            62 GB   1x L4 (48 GB)    $0.0300  $1.80    
l40sx4       4x Nvidia L40S         48 vCPU           382 GB  4x L4 (192 GB)   $0.1383  $8.30    
l40sx8       8x Nvidia L40S         192 vCPU          1534 GB 8x L4 (384 GB)   $0.3917  $23.50   
Hint: Use `hf spaces settings <space_id> --hardware <name>` to request hardware for a Space.

Slack Thread

Open in Web Open in Cursor 

Note

Low Risk
Primarily adds a new read-only CLI/API endpoint call and documentation updates, with minimal impact on existing behavior aside from small formatting changes in hf jobs hardware output.

Overview
Adds a new hf spaces hardware CLI subcommand that fetches GET /api/spaces/hardware and renders available Space hardware (CPU/RAM/accelerator) with per-minute and per-hour pricing.

Exposes this capability in the Python API via HfApi.list_spaces_hardware (and top-level list_spaces_hardware) and updates spaces settings --hardware help/docs to point users to the new listing command; also adjusts hf jobs hardware output to display missing/zero pricing as free instead of N/A, and adds a production-gated CLI test for the new command.

Reviewed by Cursor Bugbot for commit 468940a. Bugbot is set up for automated code reviews on this repo. Configure here.

cursoragent and others added 2 commits April 29, 2026 12:38
Co-authored-by: Lucain <Wauplin@users.noreply.github.com>
Co-authored-by: Lucain <Wauplin@users.noreply.github.com>
@bot-ci-comment

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@Wauplin Wauplin left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️

@Wauplin Wauplin marked this pull request as ready for review April 29, 2026 13:00

@davanstrien davanstrien left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! Claude wondered whether it'd be worth dropping the cpu / ram asserts since they're testing API response wording rather than CLI behaviour, but no strong opinion!

Comment thread src/huggingface_hub/cli/spaces.py Outdated
accelerator = (
f"{hw.accelerator.quantity}x {hw.accelerator.model} ({hw.accelerator.vram})" if hw.accelerator else None
)
cost_per_hour = f"${hw.unit_cost_usd * 60:.2f}/h" if hw.unit_cost_usd else "free"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing comparing this to hf jobs hardware the two commands diverge on cost display in a few ways:

  • Columns: Jobs has COST/MIN + COST/HOUR, Spaces has a single COST.
  • Values: Jobs bare ($0.01), Spaces suffixed ($0.03/h).
  • Free hardware: Jobs shows "N/A", Spaces shows "free".

Not sure it's a massive deal though?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes good catch, definitely not wanted.

I've pushed an update and now both are the same:

✗ hf jobs hardware  
NAME            PRETTY NAME            CPU      RAM     ACCELERATOR       COST/MIN COST/HOUR 
--------------- ---------------------- -------- ------- ----------------- -------- --------- 
cpu-basic       CPU Basic              2 vCPU   16 GB                     $0.0002  $0.01     
cpu-upgrade     CPU Upgrade            8 vCPU   32 GB                     $0.0005  $0.03     
cpu-performance CPU Performance        32 vCPU  256 GB                    $0.3117  $18.70    
cpu-xl          CPU XL                 16 vCPU  124 GB                    $0.0167  $1.00     
t4-small        Nvidia T4 - small      4 vCPU   15 GB   1x T4 (16 GB)     $0.0067  $0.40     
t4-medium       Nvidia T4 - medium     8 vCPU   30 GB   1x T4 (16 GB)     $0.0100  $0.60     
a10g-small      Nvidia A10G - small    4 vCPU   15 GB   1x A10G (24 GB)   $0.0167  $1.00     
a10g-large      Nvidia A10G - large    12 vCPU  46 GB   1x A10G (24 GB)   $0.0250  $1.50     
a10g-largex2    2x Nvidia A10G - large 24 vCPU  92 GB   2x A10G (48 GB)   $0.0500  $3.00     
a10g-largex4    4x Nvidia A10G - large 48 vCPU  184 GB  4x A10G (96 GB)   $0.0833  $5.00     
a100-large      Nvidia A100 - large    12 vCPU  142 GB  1x A100 (80 GB)   $0.0417  $2.50     
a100x4          4x Nvidia A100         48 vCPU  568 GB  4x A100 (320 GB)  $0.1667  $10.00    
a100x8          8x Nvidia A100         96 vCPU  1136 GB 8x A100 (640 GB)  $0.3333  $20.00    
h200            Nvidia H200            23 vCPU  256 GB  1x H200 (141 GB)  $0.0833  $5.00     
h200x2          Nvidia H200            46 vCPU  512 GB  2x H200 (282 GB)  $0.1667  $10.00    
h200x4          Nvidia H200            92 vCPU  1024 GB 4x H200 (564 GB)  $0.3333  $20.00    
h200x8          Nvidia H200            184 vCPU 2048 GB 8x H200 (1128 GB) $0.6667  $40.00    
l4x1            1x Nvidia L4           8 vCPU   30 GB   1x L4 (24 GB)     $0.0133  $0.80     
l4x4            4x Nvidia L4           48 vCPU  186 GB  4x L4 (96 GB)     $0.0633  $3.80     
l40sx1          1x Nvidia L40S         8 vCPU   62 GB   1x L40S (48 GB)   $0.0300  $1.80     
l40sx4          4x Nvidia L40S         48 vCPU  382 GB  4x L40S (192 GB)  $0.1383  $8.30     
l40sx8          8x Nvidia L40S         192 vCPU 1534 GB 8x L40S (384 GB)  $0.3917  $23.50    

✗ hf spaces hardware
NAME         PRETTY_NAME            CPU               RAM     ACCELERATOR      COST_MIN COST_HOUR
------------ ---------------------- ----------------- ------- ---------------- -------- ---------
cpu-basic    CPU Basic              2 vCPU            16 GB                    free     free     
zero-a10g    ZeroGPU                Dynamic resources -                        free     free     
cpu-upgrade  CPU Upgrade            8 vCPU            32 GB                    $0.0005  $0.03    
t4-small     Nvidia T4 - small      4 vCPU            15 GB   1x T4 (16 GB)    $0.0067  $0.40    
t4-medium    Nvidia T4 - medium     8 vCPU            30 GB   1x T4 (16 GB)    $0.0100  $0.60    
a10g-small   Nvidia A10G - small    4 vCPU            15 GB   1x A10G (24 GB)  $0.0167  $1.00    
a10g-large   Nvidia A10G - large    12 vCPU           46 GB   1x A10G (24 GB)  $0.0250  $1.50    
a10g-largex2 2x Nvidia A10G - large 24 vCPU           92 GB   2x A10G (48 GB)  $0.0500  $3.00    
a10g-largex4 4x Nvidia A10G - large 48 vCPU           184 GB  4x A10G (96 GB)  $0.0833  $5.00    
a100-large   Nvidia A100 - large    12 vCPU           142 GB  1x A100 (80 GB)  $0.0417  $2.50    
a100x4       4x Nvidia A100         48 vCPU           568 GB  4x A100 (320 GB) $0.1667  $10.00   
a100x8       8x Nvidia A100         96 vCPU           1136 GB 8x A100 (640 GB) $0.3333  $20.00   
l4x1         1x Nvidia L4           8 vCPU            30 GB   1x L4 (24 GB)    $0.0133  $0.80    
l4x4         4x Nvidia L4           48 vCPU           186 GB  1x L4 (96 GB)    $0.0633  $3.80    
l40sx1       1x Nvidia L40S         8 vCPU            62 GB   1x L4 (48 GB)    $0.0300  $1.80    
l40sx4       4x Nvidia L40S         48 vCPU           382 GB  4x L4 (192 GB)   $0.1383  $8.30    
l40sx8       8x Nvidia L40S         192 vCPU          1534 GB 8x L4 (384 GB)   $0.3917  $23.50   
Hint: Use `hf spaces settings <space_id> --hardware <name>` to request hardware for a Space.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit d1d5224. Configure here.

Comment thread src/huggingface_hub/cli/spaces.py
…me")

Co-authored-by: Lucain <Wauplin@users.noreply.github.com>
@Wauplin Wauplin merged commit 6a57790 into main Apr 30, 2026
21 checks passed
@Wauplin Wauplin deleted the cursor/add-spaces-hardware-cmd-9495 branch April 30, 2026 08:41
@huggingface-hub-bot

Copy link
Copy Markdown
Contributor

This PR has been shipped as part of the v1.13.0 release.

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.

3 participants