RUNLOCALAIv38
->Will it run?Best GPUCompareTroubleshootStartLearnPulseModelsHardwareToolsBench
Run check
RUNLOCALAI

Independently operated catalog for local-AI hardware and software. Hand-written verdicts. Source-cited claims. Reproducible commands when we have them.

OP·Eruo Fredoline
DIR
  • Models
  • Hardware
  • Tools
  • Benchmarks
TOOLS
  • Will it run?
  • Compare hardware
  • Cost vs cloud
  • Choose my GPU
  • Prompting kits
  • Quick answers
REF
  • All buyer guides
  • Learn local AI
  • Methodology
  • Glossary
  • Errors KB
  • Trust
EDITOR
  • About
  • Author
  • How we make money
  • Editorial policy
  • Contact
LEGAL
  • Privacy
  • Terms
  • Sitemap
MAIL · MONTHLY DIGEST
Get monthly local AI changes
Monthly recap. No spam.
DISCLOSURE

Some links on this site are affiliate links (Amazon Associates and other first-class retailers). When you buy through them, we earn a small commission at no extra cost to you. Affiliate links do not influence our verdicts — there are cards we rate highly that we don't have affiliate relationships with, and cards that sell well that we refuse to recommend. Read more →

© 2026 runlocalai.coIndependently operated
RUNLOCALAI · v38
  1. >
  2. Home
  3. /Learn
  4. /How-to
  5. /How to format image prompts correctly for LLaVA models
HOW-TO · INF

How to format image prompts correctly for LLaVA models

intermediate·10 min·By Eruo Fredoline
Target environment
Ubuntu 24.04 · Ollama 0.4.x
PREREQUISITES

LLaVA model installed in Ollama, at least one image file available for testing

What this does

Explains the correct syntax for passing image paths and questions to LLaVA via the Ollama CLI and API. After this guide image prompts will be formatted correctly for reliable vision model inference.

Steps

  1. Use correct CLI argument order. The image path must come after the prompt string.

    ollama run llava "What is shown in this image?" /absolute/path/to/image.jpg
    

    Placing the image before the prompt produces unexpected behavior.

  2. Prefer absolute paths for reliability. Relative paths resolve from the current working directory.

    ollama run llava "Describe this image." /home/user/photos/landscape.png
    

    Absolute paths eliminate ambiguity when running scripts from different directories.

  3. Query via the REST API with base64-encoded images. Formats the request body as JSON.

    curl -X POST http://localhost:11434/api/generate -d '{"model":"llava","prompt":"What objects are in this image?","images":["'$(base64 -w0 /path/to/image.jpg)'"]}'
    

    The image must be base64-encoded without line wrapping using -w0.

  • Record the local run evidence. Save the exact command, runtime or package version, model name if applicable, and observed output so the result can be reproduced later.

Verification

curl -s -X POST http://localhost:11434/api/generate -d '{"model":"llava","prompt":"Is the sky blue?","images":["'$(base64 -w0 /path/to/image.jpg)'"]}' | jq '.response'
# Expected: A textual answer to the question about the image content

Common failures

  • image path in wrong order - The model receives no image; always place path as the final CLI argument.
  • base64 line wrapping - Missing -w0 causes malformed JSON; always use base64 -w0.
  • connection refused - Ollama daemon not running; start with ollama serve.
  • relative path not found - Script runs from a different directory; use pwd to verify or use absolute paths.
  • large base64 payload - Very large images exceed request limits; resize before encoding.

Related guides

  • How to run LLaVA vision model to analyze images
  • How to process multiple images with a single vision model request
RELATED GUIDES
INF
How to run LLaVA vision model to analyze images
INF
How to process multiple images with a single vision model request
← All how-to guidesCourses →