{"id":10164,"date":"2024-04-29T10:25:31","date_gmt":"2024-04-29T08:25:31","guid":{"rendered":"https:\/\/via-internet.de\/blog\/?p=10164"},"modified":"2025-09-16T10:05:04","modified_gmt":"2025-09-16T08:05:04","slug":"ollama-getting-started","status":"publish","type":"post","link":"https:\/\/via-internet.de\/blog\/2024\/04\/29\/ollama-getting-started\/","title":{"rendered":"Ollama | Getting Started"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Installation<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Read  <a href=\"https:\/\/github.com\/ollama\/ollama\">here<\/a> for details.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>Linux<\/td><td>curl -fsSL https:\/\/ollama.com\/install.sh | sh<\/td><\/tr><tr><td>Mac OS<\/td><td><a href=\"https:\/\/ollama.com\/download\/Ollama-darwin.zip\">Download<\/a><\/td><\/tr><tr><td>Windows<\/td><td><a href=\"https:\/\/ollama.com\/download\/OllamaSetup.exe\">Download<\/a><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Start Ollama Service<\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ollama start<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This starts the Ollama Service and binds it to the default ip address <code>127.0.0.1:11434<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you want to access the service from another host\/client, you have to use the ip address <code>0.0.0.0<\/code><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">systemctl stop ollama.service\nexport OLLAMA_HOST=0.0.0.0:11434\nollama start<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">To change the IP address of the service, edit the file \/etc\/systemd\/system\/ollama.service and add<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"11\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">[Unit]\nDescription=Ollama Service\nAfter=network-online.target\n\n[Service]\nExecStart=\/usr\/local\/bin\/ollama serve\nUser=ollama\nGroup=ollama\nRestart=always\nRestartSec=3\nEnvironment=\"OLLAMA_HOST=0.0.0.0:11434\"\n\n[Install]\nWantedBy=default.target<\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"321\" src=\"https:\/\/via-internet.de\/blog\/wp-content\/uploads\/2024\/04\/start-ollama-servce-1024x321.png\" alt=\"\" class=\"wp-image-10167\" srcset=\"https:\/\/via-internet.de\/blog\/wp-content\/uploads\/2024\/04\/start-ollama-servce-1024x321.png 1024w, https:\/\/via-internet.de\/blog\/wp-content\/uploads\/2024\/04\/start-ollama-servce-300x94.png 300w, https:\/\/via-internet.de\/blog\/wp-content\/uploads\/2024\/04\/start-ollama-servce-768x241.png 768w, https:\/\/via-internet.de\/blog\/wp-content\/uploads\/2024\/04\/start-ollama-servce-1536x482.png 1536w, https:\/\/via-internet.de\/blog\/wp-content\/uploads\/2024\/04\/start-ollama-servce-2048x643.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Access the Ollama Service from your Browser using &lt;ip-adress of host&gt;:11434<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"214\" src=\"https:\/\/via-internet.de\/blog\/wp-content\/uploads\/2024\/04\/access-ollama-service-from-browser-1024x214.png\" alt=\"\" class=\"wp-image-10166\" srcset=\"https:\/\/via-internet.de\/blog\/wp-content\/uploads\/2024\/04\/access-ollama-service-from-browser-1024x214.png 1024w, https:\/\/via-internet.de\/blog\/wp-content\/uploads\/2024\/04\/access-ollama-service-from-browser-300x63.png 300w, https:\/\/via-internet.de\/blog\/wp-content\/uploads\/2024\/04\/access-ollama-service-from-browser-768x161.png 768w, https:\/\/via-internet.de\/blog\/wp-content\/uploads\/2024\/04\/access-ollama-service-from-browser-1536x321.png 1536w, https:\/\/via-internet.de\/blog\/wp-content\/uploads\/2024\/04\/access-ollama-service-from-browser.png 1568w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Sample Python Chat<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Install Python<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Install Ollama Library<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">pip install ollama<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Create the chat programm<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#!\/usr\/bin\/env python\n\nfrom ollama import Client\n\nollama = Client(host='127.0.0.1')\n\nresponse = ollama.chat(model='llama3', messages=[\n  {\n    'role': 'user',\n    'content': 'Why is the sky blue?',\n  },\n])\nprint(response['message']['content'])<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Run the programm<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\u276f .\/chat.py<\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"551\" src=\"https:\/\/via-internet.de\/blog\/wp-content\/uploads\/2024\/04\/Bildschirmfoto-2024-04-29-um-10.44.08-1024x551.png\" alt=\"\" class=\"wp-image-10170\" srcset=\"https:\/\/via-internet.de\/blog\/wp-content\/uploads\/2024\/04\/Bildschirmfoto-2024-04-29-um-10.44.08-1024x551.png 1024w, https:\/\/via-internet.de\/blog\/wp-content\/uploads\/2024\/04\/Bildschirmfoto-2024-04-29-um-10.44.08-300x161.png 300w, https:\/\/via-internet.de\/blog\/wp-content\/uploads\/2024\/04\/Bildschirmfoto-2024-04-29-um-10.44.08-768x413.png 768w, https:\/\/via-internet.de\/blog\/wp-content\/uploads\/2024\/04\/Bildschirmfoto-2024-04-29-um-10.44.08-1536x826.png 1536w, https:\/\/via-internet.de\/blog\/wp-content\/uploads\/2024\/04\/Bildschirmfoto-2024-04-29-um-10.44.08.png 1892w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Hint: To see, whats happen with the service, monitor the logfile<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\u276f sudo journalctl -u ollama.service -f<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Query the API<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Read the API definition <code><a href=\"https:\/\/github.com\/ollama\/ollama\/blob\/main\/docs\/api.md\" data-type=\"link\" data-id=\"https:\/\/github.com\/ollama\/ollama\/blob\/main\/docs\/api.md\">here<\/a><\/code><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Run Query with streaming<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">curl http:\/\/localhost:11434\/api\/generate -d '{\n  \"model\": \"llama3\",\n  \"prompt\": \"Why is the sky blue?\"\n}'<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Run Query without streaming<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">curl http:\/\/localhost:11434\/api\/generate -d '{\n  \"model\": \"llama3\",\n  \"prompt\": \"Why is the sky blue?\",\n  \"stream\": false\n}'<\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"303\" src=\"https:\/\/via-internet.de\/blog\/wp-content\/uploads\/2024\/04\/Bildschirmfoto-2024-04-29-um-10.54.05-1024x303.png\" alt=\"\" class=\"wp-image-10173\" srcset=\"https:\/\/via-internet.de\/blog\/wp-content\/uploads\/2024\/04\/Bildschirmfoto-2024-04-29-um-10.54.05-1024x303.png 1024w, https:\/\/via-internet.de\/blog\/wp-content\/uploads\/2024\/04\/Bildschirmfoto-2024-04-29-um-10.54.05-300x89.png 300w, https:\/\/via-internet.de\/blog\/wp-content\/uploads\/2024\/04\/Bildschirmfoto-2024-04-29-um-10.54.05-768x227.png 768w, https:\/\/via-internet.de\/blog\/wp-content\/uploads\/2024\/04\/Bildschirmfoto-2024-04-29-um-10.54.05-1536x455.png 1536w, https:\/\/via-internet.de\/blog\/wp-content\/uploads\/2024\/04\/Bildschirmfoto-2024-04-29-um-10.54.05-2048x606.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Create a simple ChatGPT Clone<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Create the Gradio App<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Installation Read here for details. Linux curl -fsSL https:\/\/ollama.com\/install.sh | sh Mac OS Download Windows Download Start Ollama Service This starts the Ollama Service and binds it to the default ip address 127.0.0.1:11434 If you want to access the service from another host\/client, you have to use the ip address 0.0.0.0 To change the IP address of the service, edit the file \/etc\/systemd\/system\/ollama.service and add Access the Ollama Service from your Browser using &lt;ip-adress of host&gt;:11434 Sample Python Chat Install Python Install Ollama Library Create the chat programm Run the programm Hint: To see, whats happen with the service, monitor the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[168],"tags":[],"class_list":["post-10164","post","type-post","status-publish","format-standard","hentry","category-ai"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/posts\/10164","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/comments?post=10164"}],"version-history":[{"count":4,"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/posts\/10164\/revisions"}],"predecessor-version":[{"id":10426,"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/posts\/10164\/revisions\/10426"}],"wp:attachment":[{"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/media?parent=10164"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/categories?post=10164"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/tags?post=10164"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}