How to Use Dify: The Beginner's Guide (First App, First Model, First RAG Knowledge Base, and the Key That Stays Secret)

CodexFuse Team · 2026-10-31T03:57:27.257Z · 14 min read

Learn how to use Dify: pick Cloud or self-host, connect a model provider safely, build your first chatbot, add a RAG knowledge base, and publish it with an API.

How to Use Dify: The Beginner's Guide (First App, First Model, First RAG Knowledge Base, and the Key That Stays Secret)

Learning how to use Dify is the fastest route from "I have a prompt" to "I have a deployed AI app." Dify is an open-source platform for building LLM applications without assembling the plumbing yourself: it bundles a prompt IDE, a visual workflow builder, retrieval-augmented generation (RAG) with vector storage, agent frameworks with tool calling, and a deployment layer that exposes your app as a web chat, an embed, or an API endpoint. This Dify tutorial walks the entire beginner arc in one sitting: decide between Dify Cloud and self-hosting, set up your workspace, connect a model provider the safe way, build your first chatbot app, feed it a knowledge base so it answers from your documents, and publish it — including the API key you use to call it from your own code. One rule governs the whole guide: your model-provider key goes in the provider integration and nowhere else — never in a prompt, a screenshot, or public code.

You will build in this order: choose Cloud or Docker, create your workspace, wire up a model provider, pick the right app type, build and test your first chatbot in the prompt IDE, upload documents into a knowledge base and watch the app answer from them, then publish and call the app's API. Once your app is live and answering through its API, you can test every endpoint exactly like any other web API — a free REST API tester is the fastest way to send requests to your Dify app's API and inspect what comes back.

How do you use Dify? (The 30-second version)

Here is the complete beginner arc — seven steps from zero to a published AI app:

  1. Choose Cloud or self-host: Dify Cloud is the shortest path; Docker self-hosting is for data residency and production control (details below).
  2. Create a workspace: sign up, and you land in Studio — the home of all your apps.
  3. Connect a model provider: go to Integrations > Model Provider, paste your API key once, and set a default model.
  4. Create a chatbot app: Studio > Create from Blank, expand the basic app types, choose Chatbot, and name it.
  5. Write the instruction and test: give the chatbot a role and rules in the prompt IDE, set a conversation opener, and try it in the preview window.
  6. Add a knowledge base: upload documents to Knowledge, let Dify chunk and embed them, and attach the knowledge base to the app for RAG answers.
  7. Publish and call the API: hit Publish > Publish Update, then use the web app, the embed code, or the API with your per-app API key.

What is Dify, exactly?

Dify is an open-source LLMOps platform — a complete toolkit for building, testing, and operating AI applications without writing the boilerplate. Under the hood it is a Python web application (Flask backend, React frontend) that talks to model providers through one normalized interface, and you can run it as a managed cloud or self-host it with Docker. It does not train models and does not replace your model provider; what it removes is the repetitive work between a good prompt and a deployed, observable, version-controlled LLM app.

Everything in Dify is built around apps. Each app is one of five types, and choosing the right type is the first real decision you make. The types share one design idea: nodes on a visual canvas for the logic-driven apps, and a prompt IDE for the chat apps.

Should you start on Dify Cloud or self-host Dify?

Start on Dify Cloud if you are learning; self-host on Docker when you need control over data, updates, and cost. The official quick start uses Dify Cloud for a reason — you skip server administration entirely and go straight to building. But there is a billing detail beginners miss: new Cloud Sandbox accounts may include one-time AI credits, and they are not a recurring monthly allowance, so check your current workspace balance before relying on them. After those credits run out, you connect your own model-provider credentials — which is the same thing self-hosted users do from the start.

QuestionDify CloudSelf-hosted Docker
Time to first appMinutes — sign up and buildAn hour or two — VPS, Docker, DNS
Model usage includedOne-time sandbox credits, then your own keysNone — configure a provider or local model first
Data locationDify's infrastructureYour server — full data residency
Cost shapeSubscription + model usageVPS cost + model usage only
Operations burdenZeroYou own updates, backups, TLS, monitoring
Best forLearning, prototypes, first appsProduction, private data, teams

This guide builds on the Cloud path first, because the Studio steps are identical on both. The self-hosting section near the end covers the Docker stack and the VPS sizing you need before installing.

How do you set up your first Dify account and workspace?

Sign up at Dify Cloud, verify your email, and you arrive in Studio — the dashboard where every app lives. A workspace is your team's container: apps, knowledge bases, and model-provider connections all belong to it, and every member gets a role (owner, admin, editor, or viewer) that controls what they can change.

Two things to do before building. First, open the workspace settings and confirm your sandbox credit balance, so you know whether your first experiments ride on the one-time credits or your own provider key. Second, invite collaborators later, not now — build your first app solo so you understand every screen before anyone else touches it.

How do you connect a model provider in Dify? (The key that stays secret)

You connect a provider once per workspace, in Integrations > Model Provider: pick your vendor, paste the API key, name the connection, and it becomes available to every app in that workspace. Dify supports OpenAI, Anthropic, Azure OpenAI, Google, Mistral, and a long tail of other models through a plugin system, so you are not locked to one vendor. Then open Default Models and choose a system reasoning model that is available in your workspace — this is the model Dify reaches for when a node needs one.

The key rule, stated once and remembered forever: the API key lives in the provider integration only. Do not paste it into an app prompt, into client-side code, into a screenshot you share, or into a forum post asking for help. Provider keys are billed against your account, and a leaked key is a leaked wallet. If you ever need to rotate one, replace it in the same Integrations > Model Provider screen and every app picks up the new key.

Self-hosted users have one extra decision: your Dify installation includes no third-party model usage at all, so you must configure a provider — or a compatible local model such as one served by Ollama — before building anything. Cloud users can lean on the one-time sandbox credits for the first experiments, then add their own key exactly the same way.

Which Dify app type should you build first?

Build a Chatbot first — it is the instant-start type designed for a quick Q&A assistant. The official beginner path says the same thing: if you are new here and want to build something with your data immediately, the chatbot is the starting point. The other four types solve harder problems, and you will recognize when you need them.

App typeWhat it isBuild it when…
ChatbotA chat window driven by an instructionYou want a Q&A assistant fast — your first app
AgentA goal plus tools; it chooses its own stepsThe task needs reasoning and tool use, not fixed steps
Text GeneratorStructured text output from inputsYou need reports, summaries, or generated content
WorkflowFixed steps from input to output on a canvasA repeatable process must run the same way every time
ChatflowA workflow with a chat window and memoryConversation needs branching logic and memory

One interface detail that trips up beginners: in Studio, click Create, then Create from Blank. You first see Workflow and Chatflow; the other three types — Chatbot, Agent, and Text Generator — appear when you expand the basic app types. That is the button everyone misses when they want to build their first chatbot.

How do you build your first chatbot app in Dify?

You create the app, write its instruction in the prompt IDE, set the tone with a conversation opener, and iterate in the preview window until it behaves. This is the heart of Dify for beginners, and it takes about ten focused minutes.

Start in Studio: Create > Create from Blank, expand the basic app types, choose Chatbot, and give it a descriptive name like "Support FAQ Bot". You land in the prompt IDE — the screen with your instruction field, model settings, and a live conversation preview on the side.

Write the instruction as a job description, not a wish. Name the role, draw the boundary, and define the honest fallback for questions it cannot answer. A support bot's instruction might read:

You are a support assistant for Example Product.
Answer only questions about the product, its plans, and its setup.
If the available information is insufficient, say what is missing.
Do not invent account, billing, or security details.

Then set a conversation opener and a few suggested questions — small touches that decide whether anyone actually talks to the app. Use the preview window to test it like a skeptical user: ask a normal question, ask an edge-case question, and ask something outside its scope. When it misbehaves, refine the instruction and test again; this prompt-test-refine loop is the core skill of Dify, and it is faster than any code edit.

How do you add a knowledge base so the app answers from your documents?

You upload documents into the Knowledge section, Dify parses, chunks, and embeds them into its vector store, and you attach that knowledge base to your app — then answers are grounded in your files instead of the model's training data. This is retrieval-augmented generation (RAG), and it is the difference between a generic chatbot and one that knows your product.

The flow: open Knowledge, create a knowledge base, and upload your sources — PDFs, text files, or even a Notion connection. Dify processes the content and makes it searchable. The indexing step matters: you choose an embedding model and chunking behavior, which decides how finely your documents are split for retrieval. Smaller, cleaner source documents retrieve better than one giant manual, so split sprawling docs by topic before uploading.

Then attach the knowledge base inside your app's configuration so retrieved passages are passed to the model as context. Test with two kinds of questions: one whose answer is in the documents, and one whose answer is not. The second test is the important one — a well-grounded app says "I don't have that information" instead of inventing an answer, and your instruction from the previous section is what enforces it.

How do you publish your Dify app and call its API?

You click Publish > Publish Update, and the app becomes live and shareable — exposed as a hosted web app, an embeddable chat widget, or an API endpoint. Publishing in Dify is a deliberate action: you can keep iterating privately in the prompt IDE for as long as you like, and nothing is public until you publish.

The web app is the fastest way to share — a ready-made chat page anyone with the link can use. The embed option drops the chat into your own site. The API is the power lane: each published app gets its own API key (in the app-xxx format), and on Dify Cloud the API server is https://api.dify.ai/v1 (self-hosted uses your own domain). One detail that saves debugging time: Chatflow apps use the Chat-type API, while Workflow apps use the Workflow-type API — pick the type that matches your app or the calls fail.

Treat that per-app API key like a password: it belongs in your server's environment variables or secrets manager, never in frontend JavaScript a visitor can read. The same key rule from the model-provider section applies all the way down.

How do you self-host Dify with Docker?

You clone the repository, copy the example environment file, and start the whole stack with Docker Compose — but only after sizing the VPS, because Dify is a real multi-container system, not a single app. The stack includes the web frontend, the API backend, a worker, PostgreSQL, Redis, a sandbox for executing code safely, Nginx, and Weaviate as the default vector database. That is why RAM is the resource that matters most: a minimum of 2 vCPUs and 2 GB RAM will run Dify, while 4–8 GB RAM and 2–4 vCPUs with 40 GB or more of storage is the recommended shape for real use, since embedding generation and vector storage grow with your document volume.

The install itself is short. On a Linux server with Docker and the Compose plugin installed — if Docker is new to you, start with a Docker beginner guide first — run:

git clone https://github.com/langgenius/dify.git
cd dify/docker
cp .env.example .env
docker compose up -d
docker compose ps

Edit .env before starting for anything beyond a local test: set your domain, generate a real secret key, and change the database and Redis passwords from their defaults. An Exited status on the one-shot init_permissions container is expected and normal; everything else should show Up or healthy. The server this all runs on is a VPS — if the concept is new, read what is VPS hosting before renting one. And if the git clone step is unfamiliar, a GitHub beginner guide covers repos, branches, and cloning in plain terms.

Plan the unglamorous parts from day one: back up the PostgreSQL database and the Weaviate data directory, because they hold your apps, workflows, and every embedded document. Updates are a fresh pull of the release you want plus docker compose up -d — read the release notes first, since the stack's shape evolves.

Dify vs LangChain: which should you learn first?

Learn Dify first if you want a working AI app without writing code; learn LangChain when you outgrow the visual builder and need code-level control. They are siblings, not rivals: Dify is the no-code studio that ships the app, while LangChain is the code framework that wires models, prompts, memory, and tools together in Python. Many teams prototype in Dify and rebuild the hot path in LangChain later — the RAG concepts (chunking, embeddings, retrieval, grounding) transfer directly.

Two more lanes worth naming so the map is complete: n8n is the workflow-automation lane for connecting apps and services, and Ollama is the local-model lane that pairs with Dify as a private, no-cloud model provider. Dify fills the cluster's missing visual app-builder slot — Ollama runs the models, LangChain codes the wiring, Dify ships the app.

What mistakes do Dify beginners always make?

MistakeWhat happensDo this instead
Pasting the provider key into a prompt or screenshotThe key leaks; someone else spends your budgetKeys live only in Integrations > Model Provider
Assuming sandbox credits refill monthlyApps stop working mid-demo when credits run outCheck the workspace balance; add your own key early
Self-hosting on a tiny VPSWeaviate and the stack crawl or crash on 1 GB RAMStart at 2 vCPU / 4 GB RAM minimum
Uploading one giant PDF as the knowledge baseRetrieval returns mushy, off-topic chunksSplit docs by topic before uploading
Skipping the "answer not in docs" testThe app confidently invents product factsTest both in-docs and out-of-docs questions
Calling the API with the wrong app typenot_workflow_app-style errorsChatflow apps use the Chat API; Workflow apps use the Workflow API
Publishing before testing the honest fallbackUsers get invented answers they trustWrite the fallback into the instruction and verify it

Sources

  • Dify official — "Get Started with Dify" (dify.ai): the five app types (Chatbot, Agent, Text Generator, Workflow, Chatflow), when to start with each, and the node concept — fetched 2026-10-31.
  • Dify Docs — "30-Minute Quick Start" (docs.dify.ai): Studio > Create from Blank flow, User Input / Parameter Extractor / LLM / Answer nodes, Test Run, Publish > Publish Update — fetched 2026-10-31.
  • Dify Docs — "Agent" reference (docs.dify.ai): build-once agent used standalone as a chat app or as a step inside a workflow; sessions on the Logs page — fetched 2026-10-31.
  • dify-hosting.com — "Dify Tutorial 2026: Build and Publish a Chatflow" (September 2026): one-time Sandbox credits are not a recurring allowance; Integrations > Model Provider + Default Models setup; credential rule (keys only in the provider integration); Chatflow-vs-Workflow choice; self-hosted instances include no third-party model usage — fetched 2026-10-31.
  • EnterpriseDNA — "Dify Tutorial: Build LLM Apps on a Visual Platform": Flask backend + React frontend; Docker Compose services (PostgreSQL, Redis, Weaviate, sandbox, web, API, worker, Nginx); provider list (OpenAI, Anthropic, Azure OpenAI, Google, Mistral via plugin system); workspace roles (owner, admin, editor, viewer) — fetched 2026-10-31.
  • Contabo — "How to Self-Host Dify on a VPS": 2 vCPU / 2 GB RAM minimum, 2–4 vCPU / 4–8 GB RAM and 40 GB+ storage recommended; clone langgenius/dify, cp .env.example .env, docker compose up -d — fetched 2026-10-31.
  • dev.to (LangBot integration guide): per-app API key format app-xxx; Dify Cloud API base https://api.dify.ai/v1; Chatflow apps must use the Chat API type — fetched 2026-10-31.
  • LeX Consultancy — "Building in Dify" workshop guide (September 2026 UI): Create from Blank shows Workflow and Chatflow; Chatbot, Agent, and Text Generator appear under the basic app types — fetched 2026-10-31.

Frequently Asked Questions

Is Dify free to use?

Dify itself is open-source and free to run. Dify Cloud offers a free Sandbox tier that may include one-time AI credits — they do not refill monthly. Self-hosting costs whatever your VPS costs, and in both cases you pay your model provider (or run a local model) for the actual AI usage.

Do I need to know how to code to use Dify?

No. Chatbot, Agent, and Text Generator apps are built entirely in the prompt IDE, and Workflow and Chatflow apps are assembled by connecting nodes on a visual canvas. Code becomes useful only when you call a published app's API from your own application — and even that is ordinary HTTP requests.

What is the difference between a Chatflow and a Workflow in Dify?

A Chatflow is a conversational app with a chat window, memory, and branching logic — users talk to it across a session. A Workflow is a one-shot process: it takes inputs, runs a fixed sequence of nodes, and returns an output. Choose Chatflow for conversations, Workflow for repeatable background processes.

Can Dify answer questions from my own documents?

Yes — that is the knowledge base feature. Upload PDFs, text files, or connect sources like Notion; Dify chunks and embeds them into its vector store. Attach the knowledge base to your app and retrieved passages become context for the model, so answers are grounded in your documents instead of invented.

Should I use Dify or LangChain?

Use Dify when you want a working AI app quickly without writing the RAG and deployment plumbing — it is the visual studio that ships the app. Use LangChain when you need code-level control over models, memory, and tools. The concepts overlap heavily, so starting with Dify makes LangChain easier later.

Featured on Twelve Tools Launch Llama Tools Launch your MCP