Ollama runs a local REST API at http://localhost:11434. It's OpenAI-compatible, so any code that calls OpenAI can call Ollama with one line changed. You can call it with curl, Python, Node, or anything else.
$curl http://localhost:11434/api/generate -d '{"model":"llama3.2","prompt":"Hello!","stream":false}'
OpenAI-compatible endpoint (drop-in for most SDKs):
from openai import OpenAI
client = OpenAI(base_url="http://localhost:11434/v1", api_key="ollama")
response = client.chat.completions.create(
model="llama3.2",
messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)
What you should see (curl response)
{
"model": "llama3.2",
"response": "Hello! How can I help you today?",
"done": true
}