Dify — Quick reference

Open-source LLM app builder · build chatbots, agents & workflows on a visual canvas · RAG knowledge bases · 50+ model providers · published as chat URL, widget, or Service API

At a glance

What it is: a Studio for assembling production LLM apps by drag-and-drop instead of code. You upload PDFs/web pages, Dify chunks & embeds them into a managed knowledge base, and your app answers grounded with citations. Get started free: Dify Cloud Sandbox = $0 (200 message credits, 50 MB / 50 knowledge documents). Self-host via Docker (~4 GB RAM, free under Apache 2.0). The course instance dify.32dots.de is currently paused — use Dify Cloud or a self-host. Pro plan: $59/mo.

Core building blocks — the three app types

App type
Chatbot
Answers questions, optionally grounded in a knowledge base. YOU set behaviour in the instructions field. The simplest app — a grounded Q&A bot in minutes.
App type
Agent
The model decides which tools to call, and in what order, to reach a goal — so the path can differ every run. Use when steps depend on what the model finds.
App type
Workflow
A fixed graph of typed nodes you wire by hand. YOU decide the path — same every run. Use when the sequence of steps is known in advance.

Agent vs Workflow — the one axis that separates them is control: in a Workflow you fix the path; in an Agent the model picks the path. All three app types publish the same three ways (see below).

Core building blocks — Workflow node types

NodeWhat it does
Knowledge RetrievalFetches the grounded chunks most relevant to the input from a knowledge base
LLMGenerates text (e.g. writes the answer using retrieved chunks)
Question ClassifierSorts an input into categories so you can branch on its type
If/ElseBranches on a condition (e.g. route long vs short questions)
IterationLoops the same step over every item in a list
Parameter ExtractorPulls structured fields out of free text
TemplateFormats output
CodeRuns your own Python or Node.js
ToolsCalls an external capability (built-in or connectable)

Every node's output is typed and visible in the run trace, so when an answer is wrong you can see exactly which node produced it — the opposite of one opaque prompt.

Build a workflow — on the canvas

StepDo this
1In the Studio, Create App → Workflow.
2Add a Knowledge Retrieval node, point it at a knowledge base you built.
3Add an LLM node; connect the retrieval output into it so the model answers from the retrieved chunks.
4Add a Question Classifier near the start (e.g. factual lookup / open discussion) to send each class down a different path.
5Add an If/Else node to branch further if needed, then run with a test input.
6Watch the run trace light up each node in order; confirm an answer comes out the end. Publish.

Data & config — knowledge bases (RAG)

StepDo this
1In the Studio, open the Knowledge section and create a new knowledge base.
2Add sources — Dify ingests PDFs, documents, and web-page URLs into the same base.
3Dify chunks each source, embeds it, and the document count rises (Sandbox: up to 50 documents).
4Attach the base to a Chatbot, Agent, or a Workflow's Knowledge Retrieval node — the same base is shared across every app.
5Ask a cross-source question; the answer cites the chunk it retrieved.

RAG = retrieval-augmented generation. The app doesn't "know" your docs — at question time it retrieves the most relevant chunks and feeds them to the model; the citation you see is that chunk. Curating what goes in (keeping it on-topic) is the single biggest lever on answer quality. Swap the model any time from the app's model selector — OpenAI, Anthropic, Groq, local Ollama/LM Studio and dozens more — without touching the knowledge base or instructions. Configure providers once in settings; then any app can use them.

Run / deploy — three delivery surfaces

For humans
Public chat URL
Hit Publish and Dify gives a public chat URL to share with collaborators instantly.
For humans
Embeddable widget
Drop the app into another site as an embedded chat widget.
For your code
Service API
Every published app is callable from your scripts via Dify's own Service API, using the app's API key.

Service API — Dify's own endpoints (NOT OpenAI-compatible)

Dify exposes its own Service API — these are not the OpenAI chat-completions endpoints. You build the app in the GUI; the API only calls the app you built, carrying its knowledge base and instructions with it. Authenticate with the app's secret key as a Bearer token. Base URL: https://api.dify.ai (or your self-host's URL).

EndpointUse for
POST /v1/chat-messagesChatbot / Agent apps — sends query, supports multi-turn via conversation_id
POST /v1/completion-messagesText-completion apps — sends only inputs, no conversation turn
curl -X POST 'https://api.dify.ai/v1/chat-messages' \
  --header 'Authorization: Bearer {YOUR_APP_API_KEY}' \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "inputs": {},
    "query": "What is the main finding of this paper?",
    "response_mode": "streaming",
    "conversation_id": "",
    "user": "abc-123"
  }'

Leave conversation_id empty to start a new conversation; pass the id returned by the first call to continue the thread. response_mode is streaming or blocking. user is your own end-user identifier.

Tips

Pick the right app type: fixed sequence of steps → Workflow; the path depends on what the model finds → Agent; just grounded Q&A → Chatbot. Stress-test a knowledge base by asking one question whose answer IS in the corpus and one that clearly is NOT — note whether it cites, admits it doesn't know, or guesses; that tells you if you'd trust it for real work. Reshape behaviour in plain language, not code — edit the instructions (e.g. "answer in three bullet points for a first-year student, and always name the source"), re-publish, and grounding survives the rewrite. Watch your limits: the Sandbox's 200 message credits go fast in a classroom — swap to a local model (Ollama / LM Studio) to keep data on-prem and cost at zero.