Foundry managed compute is currently in preview. Preview features might not be available in all regions and are subject to supplemental terms. For more information, see Supplemental Terms of Use for Microsoft Azure Previews.Hugging Face models in Foundry are globally available. For general service availability information by region, see Azure products by region.
Use Hugging Face models responsibly
Models sourced from Hugging Face are Non-Microsoft Products that aren’t tested or evaluated by Microsoft. Before you deploy a model, ensure it’s appropriate for your specific use case, including by evaluating any legal or export-control considerations and conducting your own model risk and safety evaluations. Learn about Foundry risk and safety evaluations and Hugging Face security measures for models offered in Foundry.Models from Hugging Face are subject to third-party license terms available on the Hugging Face model details page. It’s your responsibility to comply with the model’s license terms.
Prerequisites
- A Foundry project.
- The following role assignments on the Foundry account scope:
- Cognitive Services Contributor (or Foundry Owner / Foundry Account Owner) to create, update, and delete managed compute deployments.
- Foundry User to call the deployment with Microsoft Entra ID from the playground, SDK, or REST. For role definitions, see Role-based access control in Foundry.
- Available GPU managed compute quota in your Azure subscription for the selected accelerator family. Foundry managed compute quota is separate from Azure VM quota and uses a different request path. In the Foundry portal, go to Operate > Quota > Managed compute > Request quota to check your current allocation or request an increase. For detailed guidance, see Request more quota.
Deploy a Hugging Face model
Find and select the model
- In the Foundry portal, go to Discover in the upper navigation bar, and then select Models in the left pane.
- In the Collections filter, select Hugging Face to see available Hugging Face-published models.
- Select the Available in my Project filter to see only models that you can currently deploy in your project and region.
- In the Deployment options filter, select Managed compute to show only models available for managed compute deployment.
- Select a model tile to open the model details card.
Configure and deploy
- On the model details card, select Deploy. This action opens the deployment configuration panel with default selections.
-
Enter a Deployment name. You need a deployment name and it can’t contain a dot (
.). Use only alphanumeric characters, underscores, and hyphens, and use 2 to 64 characters. - Select the Deployment template.
- Select the Accelerator type that matches your model size and performance requirements. The portal prefilters available options to compatible accelerators.
-
Specify the Instance count:
- Use 1 instance for testing and development.
- Use 2 or more instances for production to ensure availability and handle traffic spikes.
-
Select Deploy. The deployment process typically takes several minutes. When it’s done, the portal displays the deployment details page with:
- The endpoint URL for invoking the model
- API keys for authentication
- Deployment status and logs
Deploy with Python SDK (alternative)
If you prefer automation, use the Python management SDK to create the same managed compute deployment. Replace placeholders with values from your subscription and selected model. To get values forMODEL and TEMPLATE, open the model details card and deployment wizard in the Foundry portal, and then copy the fully qualified registry asset IDs.
Verify and use your deployment
After the deployment finishes, validate the endpoint before you integrate it into your application:- Confirm the deployment status is Succeeded on the deployment details page.
- Run a test inference from the deployment details page to confirm that the model returns a successful response for your task type.
- If deployment fails, review the deployment logs. Then, verify GPU quota and regional availability for the selected model and accelerator type. Foundry managed compute quota is separate from Azure VM quota. For quota checks and increase requests, see Request more quota.
Invoke the endpoint from your application
After verification succeeds, invoke your deployment through the unified Foundry endpoint base URL:https://<account>.services.ai.azure.com/openai/v1/
In request bodies, set the model field to your deployment name, not the model ID.
Python OpenAI SDK with Microsoft Entra ID
Python OpenAI SDK with API key
Test the endpoint with cURL
Use a cURL request to validate your deployment outside the portal. Replace the endpoint URL, API key, and model name with your deployment values.200 and includes choices[0].message.content.
How Hugging Face models work in Foundry
Hugging Face models in Foundry use the managed compute deployment path, which creates a dedicated GPU-backed endpoint for inference. At a high level:- You discover Hugging Face models in the model catalog.
- You filter to models that are deployable in your current project.
- You deploy a supported model; Foundry provisions dedicated GPU compute instances and exposes an endpoint.
- You invoke the deployment through the endpoint by using Foundry managed compute pricing.
Data hosting and model weights
For Hugging Face models available through Foundry, model weights are stored on Azure. This behavior differs from Hugging Face-published models in Foundry (classic) and Azure Machine Learning where model weights are downloaded from Hugging Face Hub at deployment.Discover deployable Hugging Face models
In the model catalog, use model filters to narrow discovery to Hugging Face-published models. To focus on models that you can deploy now, turn on Available in my Project. When you enable this filter, the catalog shows only models that are currently deployable in your selected project context. A model appears in this filtered view when all of the following conditions are true:- The model is in the Foundry model catalog.
- Your subscription has available GPU managed compute quota for at least one compatible accelerator type.
- The model is available in your project’s Azure region.
Supported models
Foundry supports Hugging Face models that meet all of the following criteria:- Must have the
Transformers,Diffusers, orSentence-Transformerstag on Hugging Face Hub. - Have a permissive license (such as Apache 2.0, MIT, or OpenRAIL-M) that permits commercial use and redistribution.
- Have a supported task such as
chat-completion,image-to-text, orembeddings. - The model weights are in the Safetensors format and the model doesn’t require
trust_remote_code.
Security requirements
Before deployment, all models in the Hugging Face collection undergo mandatory security scanning:- Malware scanning: The process scans models to identify embedded malware or harmful binaries.
- Code inspection: The process disallows models that require
trust_remote_code=Trueunless Hugging Face explicitly verifies them or they come from trusted organizations. - Safe format enforcement: Model weights must be in Safetensors format to eliminate risks from pickle-based formats.
- Validation checks: The process tests all model, runtime, and accelerator combinations for API conformance and performance before publication.