Ollama - how to use it with cURL

By Piotr Sikora

  • ollama

  • 10 November 2025

List Ollama models

└─$ ollama ls               
NAME                    ID              SIZE      MODIFIED      
qwen2.5-coder:latest    dae161e27b0e    4.7 GB    8 minutes ago    
gpt-oss:latest          17052f91a42e    13 GB     3 weeks ago      
llama3:latest           365c0bd3c000    4.7 GB    3 weeks ago      
gemma2:latest           ff02c3702f32    5.4 GB    3 weeks ago      
deepseek-r1:latest      6995872bfe4c    5.2 GB    3 weeks ago      
starcoder:latest        847e5a7aa26f    1.8 GB    3 weeks ago    s

Ollama chat cURL request

Now lets write a simple cURL which will invoke *llama3 model:

curl http://localhost:11434/api/chat -d '{
  "model": "llama3",
  "messages": [
    { "role": "user", "content": "Give me very short answer. The capitol of Poland is?" }                       
  ]
}'

The output will be similar to:

{"model":"llama3","created_at":"2025-11-10T10:10:03.318829243Z","message":{"role":"assistant","content":"Wars"},"done":false}
{"model":"llama3","created_at":"2025-11-10T10:10:03.519302483Z","message":{"role":"assistant","content":"aw"},"done":false}
{"model":"llama3","created_at":"2025-11-10T10:10:03.703234588Z","message":{"role":"assistant","content":"!"},"done":false}
{"model":"llama3","created_at":"2025-11-10T10:10:03.883560841Z","message":{"role":"assistant","content":""},"done":true,"done_reason":"stop","total_duration":1631819270,"load_duration":103364571,"prompt_eval_count":23,"prompt_eval_duration":961241860,"eval_count":4,"eval_duration":559116162}

Ollama chat cURL without streaming

 curl http://localhost:11434/api/chat -d '{
  "model": "llama3",
  "messages": [
    { "role": "user", "content": "Give me very short answer. The capitol of Poland is?" }
  ], 
  "stream": false
}'

Ollama generate response

curl http://localhost:11434/api/generate -d '{
  "model": "llama3",
  "prompt": "Give me very short answer. Write a simple code in Python with hello world example." , "stream": false}
}' | jq -r ".response"

Categories

Recent Posts

About Me

Piotr Sikora - Process Automation | AI | n8n | Python | JavaScript

Piotr Sikora

Process Automation Specialist

I implement automation that saves time and money, streamlines operations, and increases the predictability of results. Specializing in process automation, AI implementation, and workflow optimization using n8n, Python, and JavaScript.

n8n Workflows

n8n workflow automation templates

Explore my workflow templates on n8n. Ready-to-use automations for blog management, data collection, and AI-powered content processing.

3Workflow Templates

• Auto-Categorize Blog Posts with AI

• Collect LinkedIn Profiles

• Export WordPress Posts for SEO