Lesson 3 / 25
Setting Up: Cloud or Self-Hosted, and Model Providers
Where Dify runs and which models it uses.
Two hosting options
The cloud service is quickest to start. Self-hosting (typically with Docker Compose from the Dify repository) keeps data on your infrastructure and gives more control, but you operate the database, vector store, workers and upgrades. Either way you add model providers in settings with API keys (OpenAI, Anthropic, Azure OpenAI, Google, local runtimes such as Ollama, and others), then choose models per node. Use separate keys per environment, limit who can see them, and set spending limits at the provider. Dify's node names, menus and options change between versions; check the current Dify documentation.
Self-hosting outline (sketch)
The usual Docker Compose route; follow the current README for exact steps.
git clone https://github.com/langgenius/dify.git
cd dify/docker
cp .env.example .env # review secrets, ports, storage settings
docker compose up -d # starts API, worker, web, database, vector store, ...
# then open the web UI, create the admin account, add model provider keysPin versions when self-hosting
Upgrade deliberately: read release notes, back up the database and test apps on a staging copy first.
Quick check: What is a main reason to self-host Dify?
- It removes the need for API keys
- It requires no maintenance
- It makes models free
- Keeping data and infrastructure under your own control
Answer
Keeping data and infrastructure under your own control — Control comes with operational work.