hf-msft-foundry
hf-msft-foundry is an extension for the hf CLI to deploy open models from the Hugging Face collection on Microsoft Foundry, on managed compute within your own Azure subscription, powered by engines such as vLLM on NVIDIA A100, H100 and H200, or AMD Instinct MI300X.
It lets you browse the models and their deployment templates, check capacity and quota, and create, scale and delete deployments, all from the terminal and without having to go through the Microsoft Foundry portal.
Installation
hf extensions install alvarobartt/hf-msft-foundry
Alternatively, it can also be installed as a standalone CLI from PyPI, and used as hf-msft-foundry instead of hf msft-foundry:
uv tool install hf-msft-foundry
# or
pip install hf-msft-foundry
It requires Python 3.10 or higher.
Authentication
hf-msft-foundry authenticates with DefaultAzureCredential, so either log in with the Azure CLI via az login, or set the environment variables for a service principal or a managed identity.
The subscription defaults to the one selected in the Azure CLI, and the Microsoft Foundry resource defaults to the only one in the subscription. If there's more than one, the commands fail listing them, so set them as follows:
export AZURE_SUBSCRIPTION_ID=...
export FOUNDRY_ACCOUNT_NAME=...
Or pass --subscription-id and --account to any command. If you don't have a Microsoft Foundry resource yet, you can create one with:
hf msft-foundry accounts create my-foundry --resource-group my-foundry-rg --location eastus
Getting started
Some models to get started with, on different sizes:
| Model | Size | Default deployment template |
|---|---|---|
zai-org/GLM-5.3-Flash |
321B | 4 x AMD Instinct MI300X at 512K context |
nvidia/NVIDIA-Nemotron-3-Super-120B-A12B-FP8 |
120B (12B active) | 2 x NVIDIA H100 at 256K context |
google/gemma-4-26B-A4B-it |
26B (4B active) | 1 x NVIDIA A100 at 256K context |
Check whether a model is available, and which deployment templates i.e., the ready-to-use configurations for each instance and context length, can be used with it and at which price:
hf msft-foundry models --search "gemma 4"
hf msft-foundry models google/gemma-4-26B-A4B-it
hf msft-foundry models google/gemma-4-26B-A4B-it deployment-templates
NAME ACCELERATOR_TYPE ACCELERATOR_COUNT MAX_MODEL_LEN ENVIRONMENT PRICE_PER_HOUR DEFAULT
google--gemma-4-26b-a4b-it--256k-amd-mi300x MI300_192GB 1 262144 hf-vllm-v0-33-0-amd 7.91 False
google--gemma-4-26b-a4b-it--256k-nvidia-a100 A100_80GB 1 262144 hf-vllm-v0-33-0-nvidia 3.95 True
google--gemma-4-26b-a4b-it--256k-nvidia-h100 H100_80GB 1 262144 hf-vllm-v0-33-0-nvidia 7.91 False
google--gemma-4-26b-a4b-it--256k-nvidia-h200 H200_141GB 1 262144 hf-vllm-v0-33-0-nvidia 9.1 False
The price is the on-demand list price in USD per hour and instance, from the Azure Retail Prices API. Both commands use the latest version of the model, unless --version is provided.
Check that your subscription has enough quota, and that there's capacity available, for the accelerators of the template you want to use:
hf msft-foundry quota
hf msft-foundry capacity
Then deploy it with its default deployment template, or with another one via --deployment-template, either with its full name or its suffix:
hf msft-foundry deploy google/gemma-4-26B-A4B-it
hf msft-foundry deploy google/gemma-4-26B-A4B-it --deployment-template 256k-nvidia-h100
It waits until the deployment is ready, which can take 20+ minutes, unless --no-wait is provided. The deployment name defaults to <author>--<model>--<7-digit timestamp> e.g., google--gemma-4-26b-a4b-it--5083872, so that it doesn't collide with other deployments, and can be set with --name instead, using only letters, digits, underscores and hyphens.
Once deployed, you can send OpenAI-compatible Chat Completions requests to it, setting the deployment name as the model, with the endpoint and API key of your Microsoft Foundry resource:
export OPENAI_BASE_URL=$(hf msft-foundry accounts info -o json | jq -r .openai_base_url)
export OPENAI_API_KEY=$(hf msft-foundry accounts keys -o json | jq -r .key1)
from openai import OpenAI
client = OpenAI()
completion = client.chat.completions.create(
model="google--gemma-4-26b-a4b-it--5083872",
messages=[{"role": "user", "content": "What's the capital of France?"}],
max_completion_tokens=1024,
)
print(completion.choices[0].message.content)
Finally, delete the deployment to stop paying for it:
hf msft-foundry deployments delete google--gemma-4-26b-a4b-it--5083872 --wait
Commands
| Command | Description |
|---|---|
models [--search] |
List the models in the Hugging Face collection |
models <model> [info] [--version] |
Show a model, its task, modalities and deployment templates |
models <model> deployment-templates [--version] |
List the deployment templates of a model, with their accelerators, context length and price |
deploy <model> [--version] [--deployment-template] [--name] [--instances] [--no-wait] |
Deploy a model |
deployments list |
List the deployments |
deployments status <name> |
Show a deployment |
deployments wait <name> |
Wait until a deployment succeeds |
deployments scale <name> --instances <n> |
Change the number of instances |
deployments delete <name> [--wait] |
Delete a deployment |
accounts list |
List the Microsoft Foundry resources |
accounts info |
Show the Microsoft Foundry resource and its endpoint |
accounts keys |
Show the API keys of the Microsoft Foundry resource |
accounts create <name> --resource-group --location |
Create a Microsoft Foundry resource and project |
capacity |
Show the available accelerators |
quota [--location] |
Show the managed compute quota |
All the commands accept -o json for machine-readable output, including errors, which makes hf-msft-foundry friendly to scripts and agents.
Agent skill
The skills/hf-msft-foundry/SKILL.md skill teaches agents how to use hf-msft-foundry to find, deploy, use and delete models on Microsoft Foundry.
Development
uv sync --group lint --group test
uv run pre-commit install
uv run pytest
The tests mock the Azure APIs, so they don't need an Azure subscription nor create any resource.
To release a new version, bump it with uv version --bump <major|minor|patch>, commit it, and push a matching v<version> tag, which publishes it to PyPI via trusted publishing.
License
MIT
Metadata
Release files for hf-msft-foundry 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hf_msft_foundry-0.1.0.tar.gz | 15.0 kB | Without provenance | Details for hf_msft_foundry-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hf_msft_foundry-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for hf_msft_foundry-0.1.0-py3-none-any.whl |
Total release size: 33.6 kB
Release files / hf_msft_foundry-0.1.0.tar.gz
| Download URL | hf_msft_foundry-0.1.0.tar.gz |
|---|---|
| Size | 15.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d95b1902e02675ca3f05b5738905bca4bd3b7e0c61a9c1ac369bf9def3a23c10
|
|
BLAKE2b-256 checksum How to use checksums |
f34bec6b023235487ead6abab0c59e0e9952738d5006a95daedc5e0416985e8d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / hf_msft_foundry-0.1.0-py3-none-any.whl
| Download URL | hf_msft_foundry-0.1.0-py3-none-any.whl |
|---|---|
| Size | 18.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fd35bd2092c896658038d09b9f50be40914b8b4277283f0d2b3b587db1cefa67
|
|
BLAKE2b-256 checksum How to use checksums |
af9fdca086a5c1aa8e2643db41a0c2709f93a841451700f201ca1fbf1be3c091
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for hf-msft-foundry 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.