{"id":441,"date":"2024-03-06T13:08:18","date_gmt":"2024-03-06T13:08:18","guid":{"rendered":"https:\/\/blog.200oksolutions.com\/?p=441"},"modified":"2025-12-04T07:44:09","modified_gmt":"2025-12-04T07:44:09","slug":"how-to-build-your-own-offline-chatgpt-using-ollama-and-large-language-models","status":"publish","type":"post","link":"https:\/\/www.200oksolutions.com\/blog\/how-to-build-your-own-offline-chatgpt-using-ollama-and-large-language-models\/","title":{"rendered":"How to Build Your Own Offline ChatGPT Using Ollama and Large Language Models"},"content":{"rendered":"\n<p>System Requirements: Mac, Linux, Windows with a minimum RAM of 8GB<\/p>\n\n\n\n<p>Technology: We will use React JS for creating the frontend and run Ollama in the terminal, utilizing Ollama APIs.<\/p>\n\n\n\n<p>I believe you are already familiar with React.js and npm packages. Our main focus will be on Ollama and how to access its APIs, so feel free to choose a different frontend framework to create a chat UI.<\/p>\n\n\n\n<p><strong>What is LLM \u2013 Large Language Model<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>LLM typically stands for &#8220;Large Language Model.&#8221; These are advanced natural language processing models that are trained on extensive datasets to understand and generate human-like language. Examples of large language models include GPT-3 (Generative Pre-trained Transformer 3) developed by OpenAI, BERT (Bidirectional Encoder Representations from Transformers) by Google, and others. These models have billions of parameters and are capable of performing a wide range of language-related tasks, such as text generation, translation, summarization, and question-answering.<\/li>\n\n\n\n<li>LLMs, or Large Language Models, are sophisticated language models trained on vast datasets ranging from thousands of terabytes to petabytes of data. These models utilize parameters, and for our purposes, we will be employing Gemma, an open model developed by Google.<\/li>\n\n\n\n<li>Gemma is equipped with two sets of parameters: one with 2 billion parameters and another with 7 billion parameters. These parameters play a crucial role in shaping the model&#8217;s understanding and generation of language, enabling it to handle a wide array of linguistic tasks and contexts.<\/li>\n<\/ul>\n\n\n\n<p><strong>What is ollama?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Ollama is a platform that enables users to run open-source large language models, such as Llama 2 and Gemma, locally on their machines. This offers a great deal of flexibility and control, allowing users to leverage the power of advanced AI models without relying on external cloud services.<\/li>\n\n\n\n<li>By visiting the Ollama library at https:\/\/ollama.com\/library, users can explore and choose from multiple models available, each optimized for different types of tasks.<\/li>\n\n\n\n<li>These models vary in their specialties; for example, some are fine-tuned to excel in coding-related tasks, providing assistance with programming, debugging, or understanding codebases.<\/li>\n\n\n\n<li>This local deployment can significantly enhance privacy, reduce latency, and offer customization opportunities that might not be as readily available when using cloud-hosted models.<\/li>\n<\/ul>\n\n\n\n<p>Step 1: Visit <a href=\"https:\/\/ollama.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/ollama.com\/<\/a> to download Ollama to your local machine and install it.<\/p>\n\n\n\n<p>Step 2: Open the terminal and verify if Ollama is installed by typing \u2018ollama\u2019.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1200\" height=\"675\" src=\"https:\/\/blog.200oksolutions.com\/wp-content\/uploads\/2024\/03\/image1-edited-2.png\" alt=\"\" class=\"wp-image-445\" style=\"width:976px;height:auto\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2024\/03\/image1-edited-2.png 1200w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2024\/03\/image1-edited-2-300x169.png 300w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2024\/03\/image1-edited-2-1024x576.png 1024w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2024\/03\/image1-edited-2-768x432.png 768w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>Step 3: Download Gemma locally by executing \u2018ollama run gemma:2b\u2019.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"675\" src=\"https:\/\/blog.200oksolutions.com\/wp-content\/uploads\/2024\/03\/image2-edited-2.png\" alt=\"\" class=\"wp-image-449\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2024\/03\/image2-edited-2.png 1200w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2024\/03\/image2-edited-2-300x169.png 300w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2024\/03\/image2-edited-2-1024x576.png 1024w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2024\/03\/image2-edited-2-768x432.png 768w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>This command will download a model approximately 1.4GB in size and then run this model in the terminal, allowing you to interact with the model by asking questions.<\/li>\n\n\n\n<li>However, if you aim to create a tool that can be used by multiple users, you will need to develop a UI and integrate APIs to interact with the model.<\/li>\n<\/ul>\n\n\n\n<p>Step 4: create frontend ui with some basic design like search bar and question answer screen.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1324\" height=\"744\" src=\"https:\/\/blog.200oksolutions.com\/wp-content\/uploads\/2024\/03\/image3-edited-3.png\" alt=\"\" class=\"wp-image-459\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2024\/03\/image3-edited-3.png 1324w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2024\/03\/image3-edited-3-300x169.png 300w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2024\/03\/image3-edited-3-1024x575.png 1024w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2024\/03\/image3-edited-3-768x432.png 768w\" sizes=\"(max-width: 1324px) 100vw, 1324px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>Step 5: We need to integrate the Ollama API with the frontend. By default, Ollama operates on <a href=\"http:\/\/localhost:11434\/\" target=\"_blank\" rel=\"noreferrer noopener\">http:\/\/localhost:11434\/<\/a> You can refer to this documentation for the API:<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/ollama\/ollama\/blob\/main\/docs\/api.md\">https:\/\/github.com\/ollama\/ollama\/blob\/main\/docs\/api.md<\/a><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>We will be using the POST \/api\/generate endpoint to create the chat.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>const getChat = async (question) => {\r\n    if (!question) return;\r\n    const payload = {\r\n        model: \"gemma:2b\",\r\n        prompt: question,\r\n        stream: false,\r\n    };\r\n    try {\r\n        const response = await axios.post(\r\n            \"http:\/\/localhost:11434\/api\/generate\",\r\n            payload\r\n        );\r\n        return response?.data;\r\n    } catch {\r\n        console.log(\"error\");\r\n        return \"\";\r\n    }\r\n};<\/code><\/pre>\n\n\n\n<p>Right now, we are using stream: false which means it will give single response instead of objects of response. You can enable stream and use streaming api to look and feel like chat gpt response writing.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>So, output will look like this.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1333\" height=\"750\" src=\"https:\/\/blog.200oksolutions.com\/wp-content\/uploads\/2024\/03\/image4-edited-1.png\" alt=\"\" class=\"wp-image-462\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2024\/03\/image4-edited-1.png 1333w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2024\/03\/image4-edited-1-300x169.png 300w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2024\/03\/image4-edited-1-1024x576.png 1024w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2024\/03\/image4-edited-1-768x432.png 768w\" sizes=\"(max-width: 1333px) 100vw, 1333px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>System Requirements: Mac, Linux, Windows with a minimum RAM of 8GB Technology: We will use React JS&hellip;<\/p>\n","protected":false},"author":5,"featured_media":590,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[79,82,80,81],"class_list":["post-441","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-front-end","tag-chatgpt","tag-full-stack-development","tag-ollama","tag-react-js"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Build Your Own Offline ChatGPT Using Ollama and Large Language Models Web Development, Software, and App Blog | 200OK Solutions<\/title>\n<meta name=\"description\" content=\"Explore the 200OK Blog \u2013 your go-to source for insights on web development, backend architecture, API design, and tech best practices from industry professionals.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.200oksolutions.com\/blog\/how-to-build-your-own-offline-chatgpt-using-ollama-and-large-language-models\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Build Your Own Offline ChatGPT Using Ollama and Large Language Models Web Development, Software, and App Blog | 200OK Solutions\" \/>\n<meta property=\"og:description\" content=\"Explore the 200OK Blog \u2013 your go-to source for insights on web development, backend architecture, API design, and tech best practices from industry professionals.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.200oksolutions.com\/blog\/how-to-build-your-own-offline-chatgpt-using-ollama-and-large-language-models\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Development, Software, and App Blog | 200OK Solutions\" \/>\n<meta property=\"article:published_time\" content=\"2024-03-06T13:08:18+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-12-04T07:44:09+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2024\/03\/How-to-Build-Your-Own-Offline-ChatGPT-Using-Ollama.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1299\" \/>\n\t<meta property=\"og:image:height\" content=\"731\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"Piyush Solanki\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Piyush Solanki\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Build Your Own Offline ChatGPT Using Ollama and Large Language Models Web Development, Software, and App Blog | 200OK Solutions","description":"Explore the 200OK Blog \u2013 your go-to source for insights on web development, backend architecture, API design, and tech best practices from industry professionals.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.200oksolutions.com\/blog\/how-to-build-your-own-offline-chatgpt-using-ollama-and-large-language-models\/","og_locale":"en_US","og_type":"article","og_title":"How to Build Your Own Offline ChatGPT Using Ollama and Large Language Models Web Development, Software, and App Blog | 200OK Solutions","og_description":"Explore the 200OK Blog \u2013 your go-to source for insights on web development, backend architecture, API design, and tech best practices from industry professionals.","og_url":"https:\/\/www.200oksolutions.com\/blog\/how-to-build-your-own-offline-chatgpt-using-ollama-and-large-language-models\/","og_site_name":"Web Development, Software, and App Blog | 200OK Solutions","article_published_time":"2024-03-06T13:08:18+00:00","article_modified_time":"2025-12-04T07:44:09+00:00","og_image":[{"width":1299,"height":731,"url":"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2024\/03\/How-to-Build-Your-Own-Offline-ChatGPT-Using-Ollama.webp","type":"image\/webp"}],"author":"Piyush Solanki","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Piyush Solanki","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.200oksolutions.com\/blog\/how-to-build-your-own-offline-chatgpt-using-ollama-and-large-language-models\/#article","isPartOf":{"@id":"https:\/\/www.200oksolutions.com\/blog\/how-to-build-your-own-offline-chatgpt-using-ollama-and-large-language-models\/"},"author":{"name":"Piyush Solanki","@id":"https:\/\/www.200oksolutions.com\/blog\/#\/schema\/person\/e07f6b8e3c9a90ce7b3b09427d26155e"},"headline":"How to Build Your Own Offline ChatGPT Using Ollama and Large Language Models","datePublished":"2024-03-06T13:08:18+00:00","dateModified":"2025-12-04T07:44:09+00:00","mainEntityOfPage":{"@id":"https:\/\/www.200oksolutions.com\/blog\/how-to-build-your-own-offline-chatgpt-using-ollama-and-large-language-models\/"},"wordCount":575,"commentCount":0,"publisher":{"@id":"https:\/\/www.200oksolutions.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.200oksolutions.com\/blog\/how-to-build-your-own-offline-chatgpt-using-ollama-and-large-language-models\/#primaryimage"},"thumbnailUrl":"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2024\/03\/How-to-Build-Your-Own-Offline-ChatGPT-Using-Ollama.webp","keywords":["ChatGPT","full stack development","Ollama","react.js"],"articleSection":["FrontEnd"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.200oksolutions.com\/blog\/how-to-build-your-own-offline-chatgpt-using-ollama-and-large-language-models\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.200oksolutions.com\/blog\/how-to-build-your-own-offline-chatgpt-using-ollama-and-large-language-models\/","url":"https:\/\/www.200oksolutions.com\/blog\/how-to-build-your-own-offline-chatgpt-using-ollama-and-large-language-models\/","name":"How to Build Your Own Offline ChatGPT Using Ollama and Large Language Models Web Development, Software, and App Blog | 200OK Solutions","isPartOf":{"@id":"https:\/\/www.200oksolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.200oksolutions.com\/blog\/how-to-build-your-own-offline-chatgpt-using-ollama-and-large-language-models\/#primaryimage"},"image":{"@id":"https:\/\/www.200oksolutions.com\/blog\/how-to-build-your-own-offline-chatgpt-using-ollama-and-large-language-models\/#primaryimage"},"thumbnailUrl":"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2024\/03\/How-to-Build-Your-Own-Offline-ChatGPT-Using-Ollama.webp","datePublished":"2024-03-06T13:08:18+00:00","dateModified":"2025-12-04T07:44:09+00:00","description":"Explore the 200OK Blog \u2013 your go-to source for insights on web development, backend architecture, API design, and tech best practices from industry professionals.","breadcrumb":{"@id":"https:\/\/www.200oksolutions.com\/blog\/how-to-build-your-own-offline-chatgpt-using-ollama-and-large-language-models\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.200oksolutions.com\/blog\/how-to-build-your-own-offline-chatgpt-using-ollama-and-large-language-models\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.200oksolutions.com\/blog\/how-to-build-your-own-offline-chatgpt-using-ollama-and-large-language-models\/#primaryimage","url":"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2024\/03\/How-to-Build-Your-Own-Offline-ChatGPT-Using-Ollama.webp","contentUrl":"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2024\/03\/How-to-Build-Your-Own-Offline-ChatGPT-Using-Ollama.webp","width":1299,"height":731,"caption":"How to Build Your Own Offline ChatGPT Using Ollama and Large Language Models"},{"@type":"BreadcrumbList","@id":"https:\/\/www.200oksolutions.com\/blog\/how-to-build-your-own-offline-chatgpt-using-ollama-and-large-language-models\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.200oksolutions.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Build Your Own Offline ChatGPT Using Ollama and Large Language Models"}]},{"@type":"WebSite","@id":"https:\/\/www.200oksolutions.com\/blog\/#website","url":"https:\/\/www.200oksolutions.com\/blog\/","name":"Web Development, Software, and App Blog | 200OK Solutions","description":"","publisher":{"@id":"https:\/\/www.200oksolutions.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.200oksolutions.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.200oksolutions.com\/blog\/#organization","name":"Web Development Blog | Software Blog | App Blog","url":"https:\/\/www.200oksolutions.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.200oksolutions.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/09\/200ok_logo-CGzMrWDu.png","contentUrl":"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/09\/200ok_logo-CGzMrWDu.png","width":500,"height":191,"caption":"Web Development Blog | Software Blog | App Blog"},"image":{"@id":"https:\/\/www.200oksolutions.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.instagram.com\/200ok_solutions\/"]},{"@type":"Person","@id":"https:\/\/www.200oksolutions.com\/blog\/#\/schema\/person\/e07f6b8e3c9a90ce7b3b09427d26155e","name":"Piyush Solanki","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.200oksolutions.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/962a2b0b4db856e6851ec7d838597a0395adcaae9c0091d223de9942a4254461?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/962a2b0b4db856e6851ec7d838597a0395adcaae9c0091d223de9942a4254461?s=96&d=mm&r=g","caption":"Piyush Solanki"},"description":"Piyush is a seasoned PHP Tech Lead with 10+ years of experience architecting and delivering scalable web and mobile backend solutions for global brands and fast-growing SMEs. He specializes in PHP, MySQL, CodeIgniter, WordPress, and custom API development, helping businesses modernize legacy systems and launch secure, high-performance digital products. He collaborates closely with mobile teams building Android &amp; iOS apps , developing RESTful APIs, cloud integrations, and secure payment systems using platforms like Stripe, AWS S3, and OTP\/SMS gateways. His work extends across CMS customization, microservices-ready backend architectures, and smooth product deployments across Linux and cloud-based environments. Piyush also has a strong understanding of modern front-end technologies such as React and TypeScript, enabling him to contribute to full-stack development workflows and advanced admin panels. With a successful delivery track record in the UK market and experience building digital products for sectors like finance, hospitality, retail, consulting, and food services, Piyush is passionate about helping SMEs scale technology teams, improve operational efficiency, and accelerate innovation through backend excellence and digital tools.","url":"https:\/\/www.200oksolutions.com\/blog\/author\/piyush\/"}]}},"_links":{"self":[{"href":"https:\/\/www.200oksolutions.com\/blog\/wp-json\/wp\/v2\/posts\/441","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.200oksolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.200oksolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.200oksolutions.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.200oksolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=441"}],"version-history":[{"count":5,"href":"https:\/\/www.200oksolutions.com\/blog\/wp-json\/wp\/v2\/posts\/441\/revisions"}],"predecessor-version":[{"id":463,"href":"https:\/\/www.200oksolutions.com\/blog\/wp-json\/wp\/v2\/posts\/441\/revisions\/463"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.200oksolutions.com\/blog\/wp-json\/wp\/v2\/media\/590"}],"wp:attachment":[{"href":"https:\/\/www.200oksolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=441"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.200oksolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=441"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.200oksolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=441"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}