Skip to content

Instantly share code, notes, and snippets.

@ilosamart
Created June 23, 2025 19:47
Show Gist options
  • Save ilosamart/a92508c6fe810214683682af53208f62 to your computer and use it in GitHub Desktop.
Save ilosamart/a92508c6fe810214683682af53208f62 to your computer and use it in GitHub Desktop.
import os
import requests
OLLAMA_ENDPOINT = "https://mpgpt.lab.mp.rs.gov.br/ollama"
API_KEY = os.getenv("API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
payload = {
"model": "gemma3:12b",
"prompt": """Why is the sky blue?"
"The output should have this JSON format:
{ "question": [THE QUESTION], "response": [THE RESPONSE]}
""",
"format": "json",
"stream": False,
"raw": False,
"options": {
"num_ctx": 8000,
"seed": 0,
"temperature": 1.0,
},
}
resposta = requests.post(
f"{OLLAMA_ENDPOINT}/api/generate", headers=headers, json=payload,
)
print(resposta.text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment