Artificial Intelligence

How to use local ollama API in Python with mistral-small3.1 ?

• Bookmarks: 5


0:00 create python file

0:10 start ollama in terminal and check if its running

0:22 paste python code

0:38 run python file

0:45 read answer

import requests

# API-Endpunkt
url = "http://localhost:11434/api/generate"

# Prompt und Modell
payload = {
    "model": "mistral-small3.1",         # Modellname anpassen
    "prompt": "Hello, what is AI?",   # Prompt
    "stream": False            # kein Streaming
}

# Anfrage senden
response = requests.post(url, json=payload)

# Antwort ausgeben
print(response.json()['response'])
5 recommended
comments icon0 comments
0 notes
24 views
bookmark icon

Write a comment...

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.