huggingface/curl.py
2025-08-18 13:20:56 +02:00

21 lines
396 B
Python

import requests
import json
url = "http://localhost:11434/api/chat"
payload = {
"model": "gpt-oss",
"messages": [
{"role": "user", "content": "why is the sky blue?"}
]
}
resp = requests.post(url, json=payload, timeout=120)
resp.raise_for_status()
data = resp.json()
# Ollama returns the assistant reply under data["message"]["content"]
print(data["message"]["content"])