Path A · local
Run AI on your computer
We will use Ollama because it has a short install path, works on macOS, Windows, and Linux, and gives you a local API after it is installed.
- 1
Install Ollama
Download it for your operating system, install it, and open a new terminal window.
- 2
Run a model
This command downloads the model the first time. Then it opens a chat in your terminal.
terminalbash1ollama run gemma4When you see a prompt, type: Explain what a black hole is in two sentences. You are now running AI locally. - 3
Use the local model from Python
Ollama serves a local API at
localhost:11434. Install the smallrequestslibrary, then run this file.terminalbash1python -m pip install requestslocal_request.pypython1import requests23response = requests.post(4 "http://localhost:11434/api/generate",5 json={6 "model": "gemma4",7 "prompt": "Explain gravity in two short sentences.",8 "stream": False,9 },10)1112print(response.json()["response"])
Ollama loaded the model into your computer's memory, gave it your prompt, and returned the answer. The Python code talks to the same local service instead of opening a website.
