Overview
Guide for configuring Dify workflow variables correctly for API access.
Adding Input Variables to START Node
- Click the START node (User Input) in the workflow
- In the settings panel, find "Input Field" section
- Click the "+" button to add a new field
- Configure the field:
- Field Type: Short Text (for string inputs)
- Variable Name: e.g.,
query - Label Name: e.g.,
query - Required: Enable if the field is mandatory
- Click "Save"
The START node label will update to show the new variable (e.g., "START User Input query required").
Using Variables in LLM Node
Important: Do NOT manually type variable syntax like {{query}}. This will be treated as literal text.
Correct Method
- Click the LLM node to open settings
- In the USER message textbox, type
{(single curly brace) - A variable picker dropdown will appear showing:
- User Input variables (e.g., query)
- SYSTEM variables (user_id, app_id, etc.)
- Click the desired variable (e.g., "query" under User Input)
- The variable will be inserted as a proper reference
Common Mistake
- Typing
{{query}}or{{#sys.query#}}manually - These are NOT recognized as variable references
- The LLM will receive the literal text instead of the resolved value
Configuring Output Node Variables
- Click the Output node
- Find "Set variable" section
- Click the "+" button to add a variable slot
- Click the text area (not the trash icon on the right)
- A "Search variable" dropdown appears with autocomplete
- Select the source variable (e.g., LLM → text)
- The variable name will be set automatically
API Request Format
After publishing, call the workflow API:
POST /v1/workflows/run
Headers:
Authorization: Bearer {API_KEY}
Content-Type: application/json
Body:
{
"inputs": {"query": "your question here"},
"response_mode": "blocking",
"user": "user-id"
}
The inputs object keys must match the variable names defined in the START node.
Troubleshooting
| Symptom | Cause | Solution |
|---|---|---|
LLM receives literal {{query}} | Manual text entry | Use variable picker with { trigger |
| API returns "variable not found" | Missing START node variable | Add input field in START node settings |
| Output is empty | Output variable not configured | Select LLM/text in Output node |