> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/microsoft/onnxruntime-genai/llms.txt
> Use this file to discover all available pages before exploring further.

# Download Models

> Learn how to download ONNX Runtime GenAI models from Foundry Local, Hugging Face Hub, or build your own

This guide covers different ways to download and obtain models for use with ONNX Runtime GenAI.

## Download via Foundry Local

Foundry Local provides an easy way to download pre-optimized models for ONNX Runtime GenAI.

<Steps>
  <Step title="Install Foundry Local">
    Download and install [foundry-local](https://github.com/microsoft/Foundry-Local/releases) for your platform.
  </Step>

  <Step title="List Available Models">
    View all available models:

    ```bash theme={null}
    foundry model list
    ```
  </Step>

  <Step title="Download a Model">
    Download your chosen model. For example, to download Phi-4:

    ```bash theme={null}
    foundry model download Phi-4-generic-cpu
    ```
  </Step>

  <Step title="Locate the Model">
    Find where the model is saved on disk:

    ```bash theme={null}
    foundry cache location
    ```

    The model will be in a path like:

    ```
    C:\Users\<user>\.foundry\Microsoft\Phi-4-generic-cpu\cpu-int4-rtn-block-32-acc-level-4
    ```
  </Step>
</Steps>

<Note>
  Foundry Local CLI is not available on Linux at the moment. Please download the model from a Windows or macOS machine and copy it over to your Linux machine if you would like to run on Linux.
</Note>

## Download via Hugging Face Hub

You can download ONNX models directly from Hugging Face using the Hugging Face CLI.

<Steps>
  <Step title="Install Hugging Face CLI">
    ```bash theme={null}
    pip install huggingface-hub[cli]
    ```
  </Step>

  <Step title="Login to Hugging Face">
    ```bash theme={null}
    huggingface-cli login
    ```
  </Step>

  <Step title="Download a Model">
    Use the `huggingface-cli download` command with the model name and subfolder:

    ```bash theme={null}
    huggingface-cli download <model_name> --include <subfolder_name>/* --local-dir .
    ```

    For example, to download the Phi-4 mini instruct GPU model:

    ```bash theme={null}
    huggingface-cli download microsoft/Phi-4-mini-instruct-onnx --include gpu/* --local-dir .
    ```
  </Step>

  <Step title="Identify the Model Path">
    The model will be downloaded to your specified directory. For example:

    ```
    gpu/gpu-int4-rtn-block-32
    ```
  </Step>
</Steps>

## Build Your Own Model

Alternatively, you can build your own ONNX model locally using one of these tools:

<CardGroup cols={2}>
  <Card title="Model Builder" icon="hammer" href="/guides/model-builder">
    Use the ONNX Runtime GenAI Model Builder to convert and optimize PyTorch models
  </Card>

  <Card title="Olive" icon="olive" href="https://microsoft.github.io/Olive/examples.html">
    Use Microsoft Olive for advanced model optimization and conversion
  </Card>
</CardGroup>

## Next Steps

After downloading or building your model, you can:

* Follow the [Quickstart](/quickstart) to run your first inference
* Learn about [Runtime Options](/guides/runtime-options) to configure your model
* Explore [Constrained Decoding](/guides/constrained-decoding) for structured outputs
