Written by Jakub Rusinowski · Last updated July 10, 2026
Turn your local machine into an AI backend for other apps.
Turn your local machine into an AI backend for other apps.
Ollama runs a server by default on port 11434.
curl http://localhost:11434/api/generate -d '{
"model": "llama3.1",
"prompt": "Why is the sky blue?"
}'
Many apps expect the OpenAI API format. Ollama provides this too! Endpoint: http://localhost:11434/v1/chat/completions
from openai import OpenAI
client = OpenAI(
base_url='http://localhost:11434/v1',
api_key='ollama', # required but unused
)
response = client.chat.completions.create(
model="llama3.1",
messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)