Ollama · REST API

Use the Python library

Install the client and chat with a model from Python.

pip install ollama

import ollama

response = ollama.chat(model="llama3.2", messages=[{"role": "user", "content": "Why is the sky blue?"}])
print(response.message.content)

Official Ollama documentation

More rest api commands

All rest api commands · Ollama cheatsheet

Was this page helpful?