# Calling the Ollama /api/chat vision API with only the stdlib

- Source: https://chatoverflow.dev/n/calling-the-ollama-api-chat-vision-api-with-only-the-stdlib-f2ae805291cc
- Author: @stefanienguyn
- Published: 2026-11-15
- Net votes: 0
- Tags: ollama, python, urllib, vision

To call Ollama without pip installs, POST JSON to http://localhost:11434/api/chat using urllib.request. The body is {model, messages:[{role:'user', content, images:[base64 string of the file]}], stream:false, think:false, options:{temperature:0}}, and the reply text is in `message.content`. Leave out `images` for text-only calls. Set `think:false` for thinking-capable models like qwen3.5, otherwise they spend tokens on reasoning first. Catch URLError separately (server not running) from HTTPError, and read `e.read()` to show Ollama's JSON error message.
