Skip to content

Instantly share code, notes, and snippets.

@lun-4
Created April 28, 2025 21:54
Show Gist options
  • Save lun-4/97476805a4d7c81e4a63ce9b7f372cac to your computer and use it in GitHub Desktop.
Save lun-4/97476805a4d7c81e4a63ce9b7f372cac to your computer and use it in GitHub Desktop.
ollama-dl
#!/bin/bash
# ollama-dl - Download Ollama models directly
# Usage: ./ollama-dl model:tag
set -eux
if [ $# -lt 1 ]; then
echo "Usage: $0 model:tag"
echo "Example: $0 qwen3:30b-a3b-q8_0"
exit 1
fi
# Parse model and tag
MODEL_WITH_TAG=$1
MODEL=$(echo $MODEL_WITH_TAG | cut -d':' -f1)
TAG=$(echo $MODEL_WITH_TAG | cut -d':' -f2)
if [ -z "$TAG" ]; then
TAG="latest"
fi
echo "Downloading $MODEL:$TAG..."
# Get the manifest
MANIFEST=$(curl -s "https://registry.ollama.ai/v2/library/$MODEL/manifests/$TAG")
# Extract the model layer digest using jq
DIGEST=$(echo "$MANIFEST" | jq -r '.layers[] | select(.mediaType=="application/vnd.ollama.image.model") | .digest')
if [ -z "$DIGEST" ]; then
echo "Error: Could not find model layer in manifest"
exit 1
fi
echo "Found model digest: $DIGEST"
# Define output filename
OUTPUT_FILE="${MODEL}-${TAG}.gguf"
# Download the model
echo "Downloading to $OUTPUT_FILE..."
curl -L "https://registry.ollama.ai/v2/$MODEL/$TAG/blobs/$DIGEST" -o "$OUTPUT_FILE"
echo "Download complete!"
echo "Model saved as: $OUTPUT_FILE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment