In this categoryDify · 9
DifyBeginner

Dify Tutorial: Build Your First AI App (Complete Walkthrough)

A beginner walkthrough of Dify: what it is, cloud versus self-host, creating an app, picking an app type, adding a model, writing a prompt with variables, and publishing to get an API or embed.

15 minBeginner

Dify is an open-source platform for building LLM apps without writing orchestration code. You connect a model provider, choose an app type, write a prompt, and publish, getting a working app you can reach over an API or embed on a site. This walkthrough takes you from a blank account to your first published app.

What you need

  • A Dify Cloud account or a self-hosted Dify instance
  • An API key from a model provider such as Anthropic or OpenAI
  • About 15 minutes

Step 1: Choose cloud or self-host

You can start on Dify Cloud at cloud.dify.ai, where the Sandbox plan gives you free credits to try the platform with no install. If you need full data control or want to run local models, self-host with the Docker Compose bundle instead. Both options give you the identical app builder.

OptionBest forTradeoff
Dify CloudTrying Dify fast, no maintenanceData passes through the hosted service
Self-host (Docker)Data control, local or private modelsYou run and update the containers

Step 2: Add a model provider and create an app

Go to Settings and then Model Provider, install the plugin for your provider, and paste your API key. Set a default chat model so new apps use it automatically. Then open Studio, click Create from Blank, and choose an app type. The five types are Chatbot, Agent, Chatflow, Workflow, and Text Generator.

Which app type to pick
For your first app, choose Chatbot for a simple conversational assistant, or Chatflow if you want a chat app you can extend with knowledge bases and logic later. Pick Workflow for single-shot automation, Agent for tool-calling tasks, and Text Generator for one-off content output.

Step 3: Write a prompt with variables

In the prompt editor, write a system prompt that describes what the app does. To make it reusable, add input variables: define a variable like topic, then reference it as {{topic}} in the prompt. Dify renders a small form so each run can supply different values without editing the prompt. This turns one prompt into a flexible tool.

Step 4: Test in preview

Use the Debug and Preview pane on the right to try the app before shipping. Type a message or fill in the variable form and check the response. Tune the system prompt and the model parameters, such as temperature, until the output is consistent. The preview uses the same model and settings as the live app, so what you see is what users get.

Step 5: Publish and connect

Click Publish and then Publish Update to make the app live. From there you can open the hosted web app, embed it on your own site with the provided snippet, or call it through the API. Open Access API to copy your API key and the request format. The call below sends a message to a published chat app and returns the answer.

call-dify-app.sh
curl -X POST https://api.dify.ai/v1/chat-messages \
  -H "Authorization: Bearer $DIFY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "inputs": { "topic": "onboarding" },
    "query": "Write a welcome message.",
    "response_mode": "blocking",
    "user": "first-app"
  }'

Related guides

Watch related tutorials

Free weekly email

New guides in your inbox

Fresh step-by-step how-to guides as we publish them. One email a week, no more.

Tags
#dify tutorial#dify ai#dify#llm app#getting started#no-code