In this categoryDify · 9
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.
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.
| Option | Best for | Tradeoff |
|---|---|---|
| Dify Cloud | Trying Dify fast, no maintenance | Data passes through the hosted service |
| Self-host (Docker) | Data control, local or private models | You 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.
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.
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
How to Get Started with Dify AI Platform
Install Dify locally with Docker, connect your first LLM provider, and have a working chatbot running in under fifteen minutes.
How to Set Up an AI Code Review Workflow in Dify
Build a Dify workflow that takes a diff or code snippet and returns a structured review covering bugs, security, and style, then call it from CI or a git hook.
Watch related tutorials
24:16
21:45
12:00
18:00
26:00
18:00New guides in your inbox
Fresh step-by-step how-to guides as we publish them. One email a week, no more.