import json import urllib.request OLLAMA = "http://10.30.20.29:11434" # 1. model list d = json.load(urllib.request.urlopen(OLLAMA + "/api/tags", timeout=15)) names = [m["name"] for m in d["models"]] print("MODELS:", len(names)) for n in names: print(" -", n) # 2. quick chat (non-streaming, think:false) payload = { "model": names[0], "messages": [{"role": "user", "content": "Reply with exactly: METATRON OK"}], "stream": False, "think": False, "options": {"num_predict": 30}, } req = urllib.request.Request( OLLAMA + "/api/chat", data=json.dumps(payload).encode(), headers={"Content-Type": "application/json"}) r = json.load(urllib.request.urlopen(req, timeout=90)) print("REPLY:", repr(r["message"].get("content", "")))