← Presentation home · Part 11 of 10

Quick Reference

Part 11 · Quick Reference

No slide image for this part. Notes below.

← Previous All parts →

Deep dive

Quick Reference

Commands and patterns to copy/paste.

Ollama Commands

Start the server

ollama serve

Check if running

curl http://localhost:11434/api/tags

List installed models

ollama list

Download a vision model

ollama pull ministral
ollama pull llava
ollama pull minicpm-v

Base64 Encoding

Encode an image (macOS/Linux)

base64 -i image.png

# Encode without whitespace (for JSON)
base64 -i image.png | perl -pe's~\s~~g'

Store in a variable

IMAGE_B64=$(base64 -i image.png | perl -pe's~\s~~g')

# Check it worked (shows length)
echo ${#IMAGE_B64}

Check terminal character limit

getconf ARG_MAX

Resize if image is too large

sips --resampleHeightWidthMax 768 image.png --out resized.png

Raw Curl Request

IMAGE_B64=$(base64 -i image.png | perl -pe's~\s~~g')

curl -s http://localhost:11434/api/generate \
  -H "Content-Type: application/json" \
  -d '{
    "model": "ministral",
    "prompt": "Describe this image",
    "images": ["'"$IMAGE_B64"'"],
    "stream": false
  }' | jq -r '.response'

Description Prompt

Describe this image. Use plain text only. DO NOT use asterisks,
bold, or any markdown formatting.
List these aspects with a dash prefix:
- SUBJECT:
- SETTING:
- COLORS:
- CLOTHING:
- OBJECTS:
- MOOD:
Keep each line brief. No sub-bullets.

Moderation Prompt

Answer YES or NO only for each question.
1. NUDE_CHEST: Is bare chest, breasts, or nipples visible?
2. NUDE_LOWER: Is bare buttocks or genitals visible?
3. WEAPON: Is the person holding a weapon (gun, knife, etc)?
NUDE_CHEST: YES or NO
NUDE_LOWER: YES or NO
WEAPON: YES or NO

Regex Patterns

Bash (grep):

Check for a value

echo "$RESPONSE" | grep -qi "NUDE_CHEST: YES"

# -q = quiet (no output)
# -i = case-insensitive

With extended regex for flexible whitespace

echo "$RESPONSE" | grep -Ei "NUDE_CHEST:\s*YES"

Json Request Format

{
  "model": "ministral",
  "prompt": "Your question here",
  "images": ["base64_data_here"],
  "stream": false,
  "options": {
    "temperature": 0.1
  }
}

Json Response Format

{
  "model": "ministral",
  "response": "The model's answer...",
  "done": true
}

Directory Structure

2026-01-08-ai-watchman/
  01-overview.txt
  02-technology-stack.txt
  03-base64-encoding.txt
  04-first-vision-request.txt
  05-structured-prompting.txt
  06-pattern-matching.txt
  08-building-your-own.txt
  09-troubleshooting.txt
  10-glossary.txt
  11-quick-reference.txt    <- You are here

Links

Ollama: https://ollama.com
API Docs: https://github.com/ollama/ollama/blob/main/docs/api.md
Regex tester: https://regex101.com
Techalicious: https://techalicious.club