Mindket

Dify tutorial: what it is, how to run it and your first app

A black banner titled "Dify" over the line "Build AI apps and workflows without code".

Dify is an open-source platform for building apps on large language models. It has a visual canvas for workflows, a RAG pipeline, agents and an API for every app. You can start on Dify Cloud with nothing to install, or run it yourself with Docker Compose. This lesson covers both routes, the licence and a first chatbot.

In this lesson

  • Choose Cloud or a Docker install by how much server work you want to own.
  • Check the licence before you build a hosted service for other teams on Dify.
  • Bring up a local Dify, make the admin account and connect a model provider.
  • Build a three-node chatbot and preview it.
  • Read the release notes of your version before you follow a tutorial.
All courses
On this page
  1. What Dify is
  2. Cloud, self-hosted or Enterprise
  3. The licence has two conditions
  4. Run Dify on your own machine
  5. Build a first chatbot
  6. The function behind the fun fact
  7. Dify changes fast, so match the page to your version
  8. Common mistakes
  9. Try it yourself
  10. Next
  11. Check yourself
  12. Frequently asked questions
  13. Sources

What Dify is

Dify is open source, and it lets you assemble apps that call large language models (LLMs), the kind of model behind ChatGPT and Claude. You put an app together on a visual canvas where each step is a block called a node, then publish it as a web page, an API or a chat widget on your own site.

The README lists seven parts. There is a workflow canvas, support for hundreds of proprietary and open-source models, and a Prompt IDE for writing and comparing prompts. The rest are a RAG pipeline, agents that work in a sandbox of their own, LLMOps tools for watching logs and performance, and an API for every feature. RAG, retrieval-augmented generation, means the app looks up passages in your own documents and hands them to the model with the question. The RAG tutorial builds one from scratch in Python.

Studio is the part of Dify where you build. A Workflow runs once from start to finish and returns a result. A Chatflow adds a conversation, so each message runs the flow before a reply goes out. The docs call Workflow the basis for every other app type.

From the Key Concepts page. The new Agent row is from the README and the new Agent overview.
App typeHow it runsFrom the docs
WorkflowOnce, from start to finishStarts with User Input or a Trigger. The web app and the API run batches of tasks
ChatflowOn every message of a conversationAlways starts with User Input. Can keep conversation variables
Agent (new, in beta)As a chat app, or as one step in a workflowWorks in a sandbox of its own
Chatbot, Agent (legacy), Text GeneratorOn the same engineBasic types behind simpler legacy screens

Cloud, self-hosted or Enterprise

Dify comes in three editions. Dify Cloud is hosted by LangGenius, the company behind Dify. The Community Edition is the self-hosted one, and the Deploy Dify page says it runs anywhere Docker runs: a laptop, an on-premises server or a cloud VM. Dify Enterprise adds single sign-on (SSO), role-based access control (RBAC) and support agreements for organizations that host Dify themselves.

A new Cloud account starts on the Sandbox plan with 200 AI credits for calling models from providers such as OpenAI, Anthropic and Gemini. The quick start says the credits are a one-time allocation that does not renew. Self-hosted, you add a model provider and its API key yourself, because every Dify app needs at least one provider.

From the README and the Deploy Dify page.
EditionWho runs the serversHow you startFits
Dify CloudLangGeniusSign up at cloud.dify.aiTrying Dify with nothing to install
Community EditionYouDocker Compose, as in the next sectionKeeping apps and data on a machine you control
Dify EnterpriseYou, on your own infrastructureThe sales form the README linksSSO, RBAC, support SLAs, multi-workspace management and Kubernetes deployment

The licence has two conditions

The repository carries the Dify Open Source License, which is Apache 2.0 with extra conditions. The file says Dify may be used commercially, including as a backend for other applications, until one of two conditions applies. Then a commercial licence from LangGenius is required.

Unless LangGenius authorizes it in writing, you may not use the source code to run a multi-tenant environment, and one tenant means one workspace. That is the first condition. The second concerns the logo: when you use Dify's frontend, you may not remove or change the logo or copyright information in the console or apps. The frontend is the web/ folder, or the web image in Docker, and the rule does not cover uses that skip it.

A company that gives each customer a workspace on a Dify it hosts is the case the first condition describes. Ask LangGenius or a lawyer before you build that, because a summary here is no substitute for the file.

Run Dify on your own machine

The Docker Compose setup bundles PostgreSQL, the Weaviate vector database and the other services Dify needs, so there is no database to prepare first. You need Docker with Docker Compose, Git and OpenSSL. On macOS, give Docker Desktop's virtual machine at least 2 virtual CPUs and 8 GiB of memory. On Windows, use Docker Desktop with WSL 2 and keep the source code in the Linux file system. If Docker is new to you, the n8n self-hosting lesson shows where to get it.

What a local install asks for

2 cores

of CPU at least

Source: Dify Docs: Deploy Dify with Docker Compose (read November 6, 2026)

4 GiB

of RAM at least

Source: Dify Docs: Deploy Dify with Docker Compose (read November 6, 2026)

2.35.0

the oldest Docker Compose version

Source: Dify Docs: Deploy Dify with Docker Compose (read November 6, 2026)

8 GiB

of memory for Docker Desktop on macOS

Source: Dify Docs: Deploy Dify with Docker Compose (read November 6, 2026)

docker compose version
git clone --branch <version> --depth 1 https://github.com/langgenius/dify.git
cd dify/docker
cp .env.example .env
openssl rand -hex 32
# paste the output into .env as DIFY_AGENT_LOCAL_SANDBOX_AUTH_TOKEN
docker compose up -d
docker compose ps --all
  1. Run docker compose version and check that it reports 2.35.0 or later.
  2. Pick a tag on the Dify releases page. Clone it with git clone --branch followed by the tag, --depth 1 and the repository address, then move into dify/docker.
  3. Copy the template with cp .env.example .env.
  4. Make a token with openssl rand -hex 32 and set it in .env as DIFY_AGENT_LOCAL_SANDBOX_AUTH_TOKEN. Leave COMPOSE_PROFILES at its default.
  5. Start the services with docker compose up -d, then run docker compose ps --all. Long-running services should show Up or healthy. The one-time init_permissions task shows Exited (0) when it is done, which is expected.
  6. Open http://localhost/install, create the administrator account and sign in at http://localhost. If port 80 is taken, set EXPOSE_NGINX_PORT in docker/.env to another port.

Before anyone else can reach the install, set up HTTPS and replace the bundled development credentials in docker/.env. That covers the database and Redis passwords, the code sandbox keys, the Weaviate key, the plugin daemon keys and the agent tokens. After a change to .env, run docker compose up -d, because docker compose restart keeps the old environment.

Build a first chatbot

Connect a model first. In Integrations > Model Provider, install a provider such as OpenAI, click Add API Key on its card and enter the key. On Cloud, the Sandbox credits cover supported models once the provider is installed, with no key. Then click Default Models at the top right and set the System Reasoning Model, which every node without a model of its own falls back on. When a default is empty, the features that rely on it stop working.

The chatbot below is the docs' own beginner example, split there into three steps of 2, 6 and 3 minutes. It finds the country in a question, answers it and adds a fun fact that a Code node looks up. This is the system prompt for its LLM node, copied from the Simple Chatbot page.

The user will ask a question about a country. The question is {{sys.query}}
Tasks:
1. Identify the country mentioned.
2. Rephrase the question clearly.
3. Answer the question using general knowledge.
Respond in the following JSON format:
{
  "country": "<country name>",
  "question": "<rephrased question>",
  "answer": "<direct answer to the question>"
}
  1. Go to Studio > Workflow > Create from Blank > Orchestrate > New Chatflow > Create, as the tutorial words it.
  2. Add an LLM node with Add Node and connect it to the start node. Choose a default model and paste the prompt above. Type { or / in a field to pick a variable.
  3. Under Output Variables, switch Structured on, click Configure and choose Import from JSON. Paste a schema that gives country, question and answer the type string. Structured output is what lets the next node read country on its own.
  4. Add a Code node after the LLM node. Rename one input variable to country and set it to structured_output > country. Paste the Python from the next section and rename the output variable result to fun_fact.
  5. Add an Answer node with three lines: Q: {{ structured_output.question }}, A: {{ structured_output.answer }} and Fun Fact: {{ fun_fact }}.
  6. Click Preview and ask one of the tutorial's questions, such as "What is the capital of France?" or "Describe the culture in Italy".
Dify's own channel on YouTube. The docs embed this video on their Simple Chatbot page.

The function behind the fun fact

A Code node runs Python or JavaScript inside a sandbox. Its function takes the input variables you declare and has to return a dictionary whose keys are the output variables you declared, here fun_fact. The three countries in the dictionary are the tutorial's sample data. For any other country the function returns the fallback line that starts "No fun fact available for".

def main(country: str) -> dict:
  country_name = country.lower()
  fun_facts = {
    "japan": "Japan has more than 5 million vending machines.",
    "france": "France is the most visited country in the world.",
    "italy": "Italy has more UNESCO World Heritage sites than any other country."
  }
  fun_fact = fun_facts.get(country_name, f"No fun fact available for {country.title()}.")
  return {"fun_fact": fun_fact}

Dify changes fast, so match the page to your version

A tutorial written for an older release can show screens that have moved. Dify publishes releases on GitHub with tags such as 1.19.0, dated 4 November 2026. These releases changed parts this course covers.

For an existing self-hosted install, the Docker Compose page says to read the target release's upgrade guide first and to keep your own .env.

Releases that changed what these lessons teach
  1. 1.9.0

    Introduced the Knowledge Pipeline and a queue-based graph engine for running workflows.

  2. 1.10.0

    Added triggers, which start a workflow on a schedule, a webhook or an integration event.

  3. 1.12.0

    Introduced Summary Index, which adds AI-written chunk summaries as a retrieval layer.

  4. 1.13.0

    Added the Human Input node, which pauses a workflow for a person to review or edit.

  5. 1.14.0-rc1

    A release candidate brought the sandboxed Agent and its skills.

  6. 1.18.0

    Added portable .ifpkg app packages and the opt-in Agent Knowledge Base.

Source: Dify releases on GitHub (read November 6, 2026)

Common mistakes

  • Starting the stack without the sandbox token. The agent backend and its local sandbox need DIFY_AGENT_LOCAL_SANDBOX_AUTH_TOKEN in docker/.env, and they keep restarting without it.
  • Reading init_permissions with Exited (0) as a failure. It is a one-time task that prepares storage permissions.
  • Editing .env and then running docker compose restart. Restart keeps the containers' old environment, so use docker compose up -d.
  • Opening localhost for a server that runs elsewhere. For a remote deployment, use the server's IP address or domain.
  • Leaving the bundled development passwords on a machine other people can reach.
  • Starting an app before a model provider is connected, so the LLM node has nothing to call.

Try it yourself

  • Ask the chatbot about a country the dictionary does not hold, and read the fallback line it returns.
  • Add a fourth country to the dictionary in the Code node and preview again.
  • Change the model on the LLM node, or its Temperature, which runs from 0 for the most predictable replies to 1 for the most varied, and compare two answers to the same question.

Next

Lesson 2 builds a workflow with branches, variables and the tools for debugging a run. The best AI agent builder guide compares other tools for building agents, such as n8n, Zapier and Make, if you want to see those first.

Check yourself

  1. Which command checks that your Docker Compose is new enough for the Dify install?

    Show answer

    B. docker compose version The Docker Compose page has you run docker compose version first and asks for 2.35.0 or later.

  2. After docker compose up -d, the init_permissions task shows Exited (0). What does that mean?

    Show answer

    C. The one-time storage setup finished, as expected The docs call init_permissions a one-time task that prepares storage permissions and say Exited (0) is what it shows when done.

  3. The LICENSE file says one tenant corresponds to one workspace. Which of its conditions does it give that definition for?

    Show answer

    A. The multi-tenant condition The LICENSE file gives the definition under its multi-tenant condition: without Dify's written authorization, you may not use the source code to operate a multi-tenant environment. Whether a particular setup counts is a question for LangGenius.

  4. On Dify Cloud, what lets a new account call supported models before it adds its own API key?

    Show answer

    C. A one-time allocation of Sandbox AI credits New Cloud accounts start on the Sandbox plan with 200 AI credits, a one-time allocation that covers supported models once the provider is installed.

Frequently asked questions

What is Dify?

Dify is LangGenius's open-source tool for putting a model behind a chatbot, a workflow or an agent without writing the backend yourself. You design the app in Studio, the visual builder, and each finished app gets an API of its own.

Is Dify free and open source?

You can read and self-host the code, and the licence allows commercial use until one of its two conditions applies. Dify Cloud is a separate product with its own plans, and the Sandbox plan is where new accounts begin.

Do I need to code to use Dify?

No, not for most of it. The docs describe the work as dragging, connecting and configuring nodes, and a Code node in Python or JavaScript is there for the cases that need it.

What is the difference between Dify and n8n?

Dify is built around LLM apps: model providers, knowledge bases, agents and publishing. n8n connects many apps and services in automations. Dify has an HTTP Request node and an API for each app, and n8n has webhooks, so either can call the other.

Which AI models does Dify work with?

Whichever ones your connected providers offer. The README names dozens of inference providers and also accepts any model with an OpenAI-compatible API. You add a provider under Integrations > Model Provider with its API key.

Sources

  1. Dify on GitHub: README (read November 6, 2026)https://github.com/langgenius/dify/blob/main/README.md
  2. Dify on GitHub: LICENSE (read November 6, 2026)https://github.com/langgenius/dify/blob/main/LICENSE
  3. Dify Docs: Deploy Dify with Docker Compose (read November 6, 2026)https://github.com/langgenius/dify-docs/blob/main/en/self-host/deploy/quick-start/docker-compose.mdx
  4. Dify Docs: Deploy Dify (read November 6, 2026)https://github.com/langgenius/dify-docs/blob/main/en/self-host/deploy/overview.mdx
  5. Dify Docs: 30-Minute Quick Start (read November 6, 2026)https://github.com/langgenius/dify-docs/blob/main/en/quick-start.mdx
  6. Dify Docs: Simple Chatbot (read November 6, 2026)https://github.com/langgenius/dify-docs/blob/main/en/learn/tutorials/simple-chatbot.mdx
  7. Dify Docs: Key Concepts (read November 6, 2026)https://github.com/langgenius/dify-docs/blob/main/en/learn/key-concepts.mdx
  8. Dify Docs: Workflow & Chatflow (read November 6, 2026)https://github.com/langgenius/dify-docs/blob/main/en/self-host/use-dify/build/workflow-chatflow.mdx
  9. Dify Docs: LLM node (read November 6, 2026)https://github.com/langgenius/dify-docs/blob/main/en/self-host/use-dify/nodes/llm.mdx
  10. Dify Docs: Code node (read November 6, 2026)https://github.com/langgenius/dify-docs/blob/main/en/self-host/use-dify/nodes/code.mdx
  11. Dify Docs: New Agent overview (read November 6, 2026)https://github.com/langgenius/dify-docs/blob/main/en/self-host/use-dify/build/new-agent/overview.mdx
  12. Dify Docs: Build a new Agent (read November 6, 2026)https://github.com/langgenius/dify-docs/blob/main/en/self-host/use-dify/build/new-agent/build.mdx
  13. Dify Docs: Model Providers (read November 6, 2026)https://github.com/langgenius/dify-docs/blob/main/en/self-host/use-dify/workspace/model-providers.mdx
  14. Dify releases on GitHub (read November 6, 2026)https://github.com/langgenius/dify/releases
  15. Dify on YouTube: Dify Quickstart Guide: Build Your First AI Workflow (read November 6, 2026)https://www.youtube.com/watch?v=dJ34OU_JY7Y

Share this lesson

Find more open-source projects

Mindket's Kits collect open-source projects with plain setup notes. Dify is one of them.

Browse kits

This lesson as Markdown · Dify tutorial: build AI apps and workflows without code · All courses