Dify on Elestio: Build Custom AI Agents with RAG, Workflows, and Tool Calling
You know what's funny about the AI agent hype? Everyone's building agents that can write code, analyze data, and draft emails. But ask them where their RAG pipeline runs, who owns the data, or how much they're paying OpenAI per month, and you get silence.
Dify changes that equation. It's an open-source platform (130k+ GitHub stars) that lets you build production-grade AI agents, RAG chatbots, and multi-step workflows, all through a visual builder. And you can self-host the whole thing, meaning your documents, your embeddings, your conversations never leave your infrastructure.
Here's how to get it running on Elestio and build your first RAG-powered agent.
Deploy Dify on Elestio
Skip the Docker Compose debugging. Elestio gives you a fully managed Dify instance with automated SSL, backups, and monitoring.
- Go to the Dify service page on Elestio
- Pick your provider (Netcup recommended for best value, starting at $14/month in EU)
- Choose at least 2 CPU / 4 GB RAM for a smooth experience
- Click Deploy and wait about 3 minutes
Once deployed, access your Dify dashboard through the URL in your Elestio admin panel. You'll land on the setup wizard to create your admin account.
Connect Your LLM Providers
Dify doesn't lock you into one model provider. Head to Settings > Model Providers and you can connect:
- OpenAI, Anthropic, Mistral, Cohere, and dozens of other commercial providers
- Self-hosted models via Ollama, vLLM, or any OpenAI-compatible API
- Azure OpenAI, Google Vertex AI, and other enterprise endpoints
The power move here? Connect both a cloud provider (like Claude for complex reasoning) and a local Ollama instance (for cheap, fast tasks). Dify lets you switch between models per-workflow, so you can route simple queries to a local model and complex analysis to a frontier model.
Build a RAG Knowledge Base
This is where Dify really shines. Go to Knowledge > Create Knowledge Base and upload your documents (PDFs, text files, markdown, even web pages).
Dify handles the entire RAG pipeline:
- Document parsing extracts text from your files
- Chunking splits content into semantic segments
- Embedding converts chunks into vectors using your chosen model
- Indexing stores vectors in the built-in vector database
You can pick from three retrieval strategies:
| Strategy | Best For |
|---|---|
| Vector Search | Semantic similarity, natural language queries |
| Full-Text Search | Exact keyword matching, technical terms |
| Hybrid | Combines both for highest accuracy |
I initially left chunking at the default 500 tokens and got terrible results on long technical docs. Bumping to 1000 tokens and switching to hybrid retrieval with reranking made a huge difference. For most use cases, hybrid gives the best results. Dify supports external vector databases too (Qdrant, Weaviate, Milvus, pgvector) if you need to scale beyond the built-in store.
Create Your First Agent Workflow
Here's where things get interesting. Go to Studio > Create App > Workflow and you'll see Dify's visual workflow builder.
A typical RAG agent workflow looks like this:
Start → LLM (intent classification)
↓
Knowledge Retrieval (your docs)
↓
LLM (generate answer with context)
↓
End (response to user)
But you're not limited to simple chains. Dify supports:
- Conditional branching to route queries based on intent
- Tool calling with dozens of built-in tools (Google Search, DALL-E, WolframAlpha, custom APIs)
- Human-in-the-loop nodes for approval workflows
- Code execution nodes for data transformation
- HTTP request nodes to call external services
Here's a practical example. Say you're building a support bot for your team:
- Start node receives the user question
- LLM node classifies intent (bug report, feature request, general question)
- Conditional branch routes based on classification
- Knowledge retrieval searches your internal docs for relevant context
- LLM node generates a response using the retrieved context
- HTTP node creates a ticket in your issue tracker if needed
The whole thing is drag-and-drop. No code required for the workflow itself, though you can add code nodes when you need custom logic.
Expose It as an API
Once your workflow is ready, Dify gives you a production API endpoint automatically. Go to Monitoring > API Access to get your keys.
curl -X POST 'https://dify-xxxxx.vm.elestio.app/v1/chat-messages' \
-H 'Authorization: Bearer your-api-key' \
-H 'Content-Type: application/json' \
-d '{
"inputs": {},
"query": "How do I reset my password?",
"response_mode": "streaming",
"user": "user-123"
}'
You can embed this in your app, Slack bot, website widget, or any other frontend. Dify handles conversation memory, rate limiting, and usage tracking without extra configuration.
Troubleshooting
Models not appearing after adding provider? Make sure you've entered valid API keys. Dify validates credentials on save but sometimes caches stale provider lists. Restart the Dify service from your Elestio panel if models don't appear after 30 seconds.
RAG returning irrelevant results? Check your chunking settings. Default chunk size (500 tokens) works for most documents, but technical documentation often needs larger chunks (1000-1500 tokens) to preserve context. Also try switching from vector-only to hybrid retrieval.
Workflow timing out? Complex workflows with multiple LLM calls can hit the default timeout. Access your Dify container via Elestio's admin panel and increase the timeout in the environment variables.
Why This Setup Works
Dify on Elestio gives you a complete AI application platform for the cost of a single SaaS seat. No per-query fees to OpenAI (bring your own keys), no data leaving your server, and full control over your models and workflows.
Infrastructure starts at $14/month in EU ($16 in US) on Elestio, and that includes SSL, daily backups, and 24/7 monitoring. Compare that to Dify Cloud's pricing or the developer hours you'd spend maintaining Docker Compose yourself.
Check out Dify on Elestio to deploy your instance, or explore the Dify documentation to plan your first workflow.
Thanks for reading! See you in the next one.