# Set Up Workflow: Self-Hosted AI on Linux: A DevOps Home Lab Guide
## What This Is
This guide explains how to run AI models on your own private servers for enhanced data privacy and control. It outlines the key components, such as an inference engine and containerization tools, to build a secure, in-house AI infrastructure connected to business workflows.
Source: https://dev.to/akshaygore/self-hosted-ai-on-linux-a-devops-home-lab-guide-28kc
## Before You Start
Scan my workspace and analyze:
- The project language, framework, and directory structure
- Existing AI provider config (check .env, .env.local, config files for API keys — OpenRouter, OpenAI, Anthropic, Google AI, etc.)
Then ask me before proceeding:
1. Which AI provider/API should this use? (Use whatever I already have configured, or ask me to set one up — options include direct provider APIs or a unified service like OpenRouter)
2. Where in my project should this be integrated?
3. Are there any customizations I need (model preferences, naming conventions, constraints)?
## Source Access Note
The source URL (https://dev.to/akshaygore/self-hosted-ai-on-linux-a-devops-home-lab-guide-28kc) may not be directly accessible from the terminal. Use the Reference Implementation and Additional Context sections below instead. If you need more details, ask me to paste relevant content from the source.
## What to Implement
This is an **AI Workflow** — an end-to-end automation pattern or integration pipeline.
- Study the workflow architecture from the source and context below
- Identify which parts I can implement locally vs. parts that need external services
- For local parts: implement them using my existing stack and API keys
- For external parts: tell me exactly what services I need and help me configure the integration code
- Wire up any required API calls using keys from my .env files
## Additional Context
- Generate a `docker-compose.yml` file to define a self-hosted AI stack. The file must specify two services: 'ollama' using the `ollama/ollama` image with a persistent volume for models, and 'n8n' using the `n8nio/n8n` image, connecting both services to a shared bridge network.
- Create a Python script `test_model.py` to verify the Ollama service. The script should use the `requests` library to send a POST request to `http://localhost:11434/api/generate` with a payload to run the 'tinyllama' model, printing the streaming response.
- Generate a `SETUP_GUIDE.md` file that instructs the user on integrating the services. Include steps to access the n8n web UI and create a new workflow using the 'HTTP Request' node to query the Ollama service at its internal Docker network address `http://ollama:11434/api/generate`.
## Guidelines
- Adapt everything to my existing project — do not assume a specific stack or directory layout
- Use whichever AI provider I already have configured; if I need a new one, tell me what to sign up for and I'll give you the key
- Check my .env files for existing API keys (OpenRouter, OpenAI, Anthropic, Google AI) before asking me to add one
- Review any fetched code for safety before installing or executing it
- After setup, run a quick verification and show me a summary of exactly what was installed, where, and how to use it