In this blog post, we’ll walk you through the process of setting up a local environment for running Deepseek-r1 and Phi4 using Open Web UI and Ollama. By leveraging Docker and a few essential tools, you’ll be able to deploy a robust local chat application with integrated image generation capabilities. One of the major advantages of this setup is that it runs entirely on your local machine, ensuring complete privacy for your data. Let’s dive into the setup process.
We will deploy the following tools:
- Docker: For running the UI frontend and backend.
- Ollama: For managing the LLMs.
- AUTOMATIC1111/Stable Diffusion Web UI: For running the image generation API.
- Open Web UI: The chat application.
Installing Ollama and Docker
To install Ollama, head over to ollama.com/download and follow the instructions to download and set up the Ollama CLI on your machine. For deploying Docker, visit the official Docker website.
You can download the LLM models using the following commands
ollama pull deepseek-r1
ollama pull phi4
Installing AUTOMATIC1111/Stable Diffusion Web UI
The following steps are for deploying the Web UI on macOS. If you are using Linux or Windows, you can find the steps here.
First, install Homebrew package manager for macOS if not already installed. Use the following command to install Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
After installing Homebrew, install the required packages:
brew install cmake protobuf rust python@3.10 git wget
Note: Ensure you have Python 3.10.6 installed, as the newer versions of Python do not support torch.
Setting Up a Virtual Environment
It’s a good idea to set up a virtual environment to isolate the project dependencies. Here’s how you can do it:
- Install
virtualenvif not already installed - Create a virtual environment using Python 3.10
- Activate the virtual environment
- Verify the Python version inside the virtual environment
Commands are given below:
1. pip install virtualenv
2. python3.10 -m venv stable-diffusion-env
3. For Bash/Zsh:
source stable-diffusion-env/bin/activate
For Fish Shell:
source stable-diffusion-env/bin/activate.fish
4. python --version
With the dependencies installed and the virtual environment set up, you are ready to run the image generation web UI. Clone the repository and run the web UI script using the following commands:
1. git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui
2. cd stable-diffusion-webui
3. ./webui.sh --api --listen
The --api --listen flags enable Open Web UI to connect to stable-diffusion-webui using API calls.
Install Open Web UI
First, ensure Docker and Ollama are installed. You can check if Docker and Ollama are installed by running the following commands:
docker --version
ollama --version
Then, clone the Open Web UI repository:
git clone git@github.com:open-webui/open-webui.git
Run the following Docker command inside the cloned repository:
docker run -d -p 3000:8080 --add-host=host.docker.internal:host-gateway -e AUTOMATIC1111_BASE_URL=http://host.docker.internal:7860/ -e ENABLE_IMAGE_GENERATION=True -v open-webui:/app/backend/data --name open-webui --restart always ghcr.io/open-webui/open-webui:main
You can access the web interface at http://127.0.0.1:3000.
Setup Open Web UI
Sign up to create an admin account. Once you are logged in, the UI is very similar to the ChatGPT interface. The chat app has a vast list of features that bring it close to the OpenAI ChatGPT app. The details can be found here.
Generating Images
You can generate image using the “Generate Image” button below the chat response as shown in the image below. If required edit the response according to the requirement. Additionally, you can generate images directly using the Stable Diffusion web UI as well at http://127.0.0.1:7860.

Conclusion
By following these steps, you can successfully set up a local chat application with image generation capabilities using Deepseek-r1, Phi4, Stable Diffusion, and Open Web UI. This setup leverages Docker, Ollama, and several open-source tools to create a powerful environment for your projects.
Akash Gupta
Senior VoIP Engineer and AI Enthusiast

AI and VoIP Blog
Thank you for visiting the Blog. Hit the subscribe button to receive the next post right in your inbox. If you find this article helpful don’t forget to share your feedback in the comments and hit the like button. This will helps in knowing what topics resonate with you, allowing me to create more that keeps you informed.
Thank you for reading, and stay tuned for more insights and guides!

Leave a comment