vLLM as the model provider for Dify

Connect self-hosted Dify workflows and agents to a private vLLM endpoint inside your own network boundary, with the provider setup, access controls and tests planned before go-live.

On this page

How vLLM becomes the model provider for Dify

If you run or plan Dify workflows and agents and want the models served by your own vLLM server, the connection is set up in two places: Dify's vLLM model provider, installed from the Model Provider settings in Dify, and the vLLM server's /v1 API endpoint URL, which that provider is pointed at. Both stacks stay inside the same network boundary, so prompts, retrieved documents and completions never have to leave infrastructure you control. The vLLM server exposes OpenAI-compatible routes such as /v1/chat/completions and /v1/completions, and Dify's provider talks to those routes, which makes the OpenAI-compatible API the connection point between the two systems. The vLLM Dify guide is the supported method for this setup, and it is the document to follow when a step in this section is unclear.

Before you install the provider, decide where each component runs and who can reach it. Dify is started from its Docker Compose files, and the vLLM server runs as its own service, so Dify's api and worker containers need a route to the vLLM endpoint on the private network. Confirm that the endpoint URL Dify will store is reachable from inside the Dify containers, not only from the host, because localhost in one container does not point at another. Check that the model name you register in Dify matches the name the vLLM server was started with, and that the model has a chat template, either built in or supplied with --chat-template, because chat completions depend on it.

What you need before connecting Dify to vLLM

Connecting Dify to vLLM takes four pieces in place: a Dify host, a running vLLM server with a usable chat model, a network path from Dify's containers to the vLLM /v1 URL, and an explicit decision on how the vLLM endpoint is protected. Confirm each one before you open the Model Provider settings, because most failed connections trace back to one of them.

Dify Docker Compose host

The community edition runs wherever Docker runs. The self-hosting docs set a minimum of 2 CPU cores and 4 GB of RAM and require Docker Compose 2.24.0 or later. That stack starts the api, worker, web, plugin daemon, PostgreSQL, Redis, Weaviate, Nginx, a code sandbox and an SSRF proxy. Size the host for those services, not only for the model traffic, and confirm the Compose version with docker compose version before you start.

Dify Compose docs

A served chat model with a template

vLLM serves chat completions only when the model has a chat template or receives one through --chat-template. Start the server with vllm serve, confirm the model name it reports, and send one test request to /v1/chat/completions from the host. Without this check, Dify's model connection can appear to succeed while chat calls fail on the first workflow run.

vLLM online serving docs

Reachable vLLM /v1 URL

Dify's API and worker run in Docker containers, so localhost on the vLLM host is not the address they use. Choose a URL that the Dify containers can resolve and reach, such as a private host address or a DNS name on the same internal network, and include the /v1 path in the base URL. Test the route from inside a Dify container, not only from the host shell.

API key and reverse proxy decision

The vLLM --api-key option protects only the /v1, /v2, /inference and /cohere endpoints, and the vLLM security docs advise against relying on it alone. Decide whether Dify will send that key, and place a reverse proxy in front of vLLM that allowlists only the endpoints Dify calls. Keep /metrics, /health, /pause and /abort_requests off the user-facing path.

vLLM security docs

Version pins for both stacks

Record the vLLM release and the Dify release you tested together. vLLM ships new minor releases about every two weeks, and Dify minor releases arrive roughly monthly. Confirm the current vLLM version on the vLLM releases page and the current Dify version on the Dify releases page, then pin both in your deployment files so a routine pull does not change the provider behavior.

Dify releases

Configuring the vLLM provider in Dify step by step

This sequence connects a self-hosted vLLM server to a self-hosted Dify instance so that Dify workflows and agents call the model inside your network. Each step ends with a check that tells you whether the link works before you build on it.

  1. Start the vLLM server and confirm the model list

    The platform engineer starts the model with vllm serve on a host or cluster that has the accelerator capacity the model needs, and sets the --api-key option along with the network controls described in the vLLM security guidance. The --chat-template option may be needed if the model does not ship a chat template, because the chat completions API depends on one. From a host that Dify can reach, run curl against the /v1/models endpoint with the key. The step is done when the response lists the model name you will enter in Dify. Note the exact model identifier and the base URL, because both go into the Dify form.

  2. Bring up Dify from its Docker Compose files

    The platform engineer deploys Dify with its Docker Compose files on a host that meets the documented minimums of 2 CPU cores, 4 GB of RAM and Docker Compose 2.24.0 or later. The stack starts the api, worker, web, plugin daemon and supporting services, including PostgreSQL, Redis, Weaviate, Nginx, the code sandbox and the SSRF proxy. Set SECRET_KEY to a value you generate and store securely before first login, since changing it later logs out all users. The step is complete when the Dify web console loads and the administrator account can sign in.

  3. Confirm the network path from Dify to vLLM

    The platform engineer checks that the Dify api and worker containers can reach the vLLM server on its /v1 address, not just the host shell. This matters because Dify's outbound requests may pass through the SSRF proxy, which blocks internal and private IP ranges by design, so an address that works from the host can still fail inside the stack. Confirm the proxy settings in the Dify environment reference and, if needed, add an explicit allowance for the vLLM host rather than widening the proxy broadly. Run a curl to /v1/models from inside the Dify api container. The step is done when the same model list returns from inside the container.

  4. Add the vLLM provider in Model Provider settings

    The Dify administrator opens the Model Provider settings in the Dify console and installs the vLLM model provider. In the provider form, enter the vLLM server's /v1 endpoint URL, the model name returned by /v1/models, and the API key set at startup. Field names and any additional required values change between versions, so confirm the exact form fields in the vLLM Dify guide for the Dify and vLLM versions you run. The step is complete when the provider is saved and Dify shows the model as available under the provider.

  5. Check provider status in Dify

    The Dify administrator reviews the provider status and the model entry in the Model Provider settings. A failed connection usually shows as an error on the provider, so treat any error as a stop condition. If the status is an error, check three things in order: whether the URL includes /v1, whether the model name matches the /v1/models response exactly, and whether the API key matches the one passed to vllm serve. The step is done when the provider reports a healthy state and the model appears as selectable in the model options.

  6. Send a test chat from a workflow or agent

    The Dify builder creates a minimal chat app or a single-step workflow that uses the vLLM model, then sends a short prompt in the preview or debug panel. The step closes when a completion returns and the run log shows the request reached the vLLM model name you configured. If the request fails, check the Dify api logs and the vLLM server logs side by side, since the vLLM server log shows whether the request arrived. Record the model name, the endpoint and the test result so the configuration can be reproduced after an upgrade.

Keeping Dify and vLLM inside one network boundary

Place the Dify api and worker containers and the vLLM server on the same private network segment, and keep that segment closed to everything else. Dify calls the model provider from its backend services, not from the browser, so the path that matters runs from api and worker to the vLLM /v1 endpoint. The vLLM security documentation is direct about the surrounding risk: in a multi-node deployment, communication between nodes is insecure by default, with no authorization or encryption, and it must be protected by an isolated network. Your own design should apply the same logic to the single-host link between Dify and vLLM, because vLLM's --api-key option does not cover every endpoint it exposes, and the documentation recommends a reverse proxy that allowlists only the endpoints users need. Decide who owns that proxy and firewall rule before the Dify provider is configured.

Dify's outbound request handling adds a second constraint. Its SSRF_PROXY settings route outbound requests through a proxy that blocks internal and private IP ranges, and this is intended behavior that protects Dify from being used to reach internal services. A vLLM address on a private subnet can therefore be blocked by the same control that is meant to keep Dify safe. Before you enter the endpoint URL, check whether the address falls inside a range the proxy refuses, and confirm with the team that maintains the proxy whether a specific allowlist entry for the vLLM host or port is permitted and how that entry is reviewed. Do not widen the proxy to all private ranges to make the connection work.

Treat the routing as unproven until someone tests it. Ask your network team to confirm, from the Dify api and worker containers themselves, that the vLLM host and port are reachable, that no other path to vLLM is open, and that the request leaves through the route you intended. Record the firewall rules, proxy allowlist entries and the vLLM address in your change record so an auditor or a later upgrade can trace them. Repeat the check after any change to Docker networks, DNS names or the Dify Compose file, because those changes can silently move traffic onto a path that the proxy handles differently.

Mapping Dify model settings to vLLM server settings

This table pairs each Dify model provider field with the vLLM server setting it depends on, so you can check both sides before the first request. Read each row left to right: the Dify field must match the vLLM value exactly, and the items marked for confirmation depend on the Dify version in your environment. The main takeaway is that the served model name and the endpoint path are the two values most often mismatched.

Dify provider fieldvLLM setting it must matchWhat to confirm before go-live
Endpoint URLHost and port that vllm serve listens on, with the /v1 path appendedDify runs in Docker, so confirm the URL resolves from inside the Dify containers, not only from the host
Model nameServed model name set for the vLLM serverConfirm the exact string Dify sends in its request matches the served name, including case and any path prefix
API key (if used)Value passed to --api-key on the vLLM serverConfirm the key is stored as a Dify secret and that --api-key does not protect /metrics or /health
Model type: chatChat completions endpoint at /v1/chat/completions, which needs a chat templateConfirm the model ships a chat template or that one is supplied with --chat-template
Model type: embeddingEmbeddings endpoint at /v1/embeddings, served by a model that supports poolingConfirm the embedding model is started for embeddings and that Dify lists it under the embedding type
Network pathListen address and port reachable from the Dify api and worker containersConfirm both stacks sit in the same network boundary and that no reverse proxy blocks the /v1 routes Dify calls
Metrics and health checks/metrics and /health remain reachable on the API server without the API keyConfirm these endpoints are blocked at a reverse proxy or network policy if users must not reach them

Securing the Dify to vLLM connection

The connection between Dify and vLLM crosses two services with different trust models, so each side needs its own controls. The cards below cover the vLLM endpoint exposure, the Dify secrets and service authentication, and the licensing limits that apply when the platform is shared.

Allowlist the /v1 endpoints at a proxy

The vLLM security docs say the --api-key option does not protect /invocations, /pause, /resume, /abort_requests, /metrics or /health, and they advise against relying on it alone. Place a reverse proxy in front of the vLLM server that forwards only the /v1 paths Dify calls, such as /v1/chat/completions and /v1/completions, and returns denial for everything else. Test the allowlist from a host outside the Dify network to confirm the blocked paths stay blocked.

vLLM security docs

Keep metrics and health off user paths

The vLLM server exposes Prometheus metrics at /metrics, and the health endpoint sits alongside it. Neither should be reachable through the user-facing proxy or from the Dify web tier. Scrape them only from a monitoring network that the proxy does not expose, and confirm the scrape job authenticates or runs on a path that users cannot reach.

Treat SECRET_KEY as a long-lived secret

Dify uses SECRET_KEY to sign session cookies and JWTs and to encrypt OAuth credentials. Generate a strong value before the first start and store it in your secrets manager. Changing it after deployment logs out every user, so plan any rotation as a scheduled event with a user notice and a check that stored credentials still decrypt.

Verify token-based service authentication

The Dify 1.16.1 release notes describe token-based API authentication between services. Confirm your deployed version includes this change before relying on it, and check that the api, worker and plugin daemon services reject unauthenticated internal calls. Record the Dify version in your change log so each upgrade can be checked against this behavior.

Dify releases on GitHub

Confirm agent sandbox isolation

Dify 1.16.1 adds agent sandbox network isolation through a Squid proxy. Workflows that run code or call tools can reach the vLLM endpoint and other internal services, so test whether a sandboxed agent can open connections to the vLLM host and to private address ranges. Check the SSRF_PROXY settings as well, since they route outbound requests through a proxy that blocks internal IP ranges.

Check the license before sharing tenants

Dify is released under the Dify Open Source License, a modified Apache License 2.0. It prohibits using the source code to run a multi-tenant environment, where one tenant is one workspace, without written authorization. If several business units or customers will share one self-hosted Dify, confirm with the licensor whether your model is permitted before the rollout.

Dify LICENSE file

How to test the provider before users rely on it

Start with direct API checks against the vLLM server before Dify is involved at all. Send a request to /v1/completions, a request to /v1/chat/completions and a request to /v1/embeddings using the same base URL and model name that Dify's provider settings will use. The chat test matters most: confirm the model returns a sensible reply, which also shows the model has a chat template, either built in or supplied with --chat-template. Run the embeddings check only if the Dify workflow depends on embeddings, and confirm the model you serve is a pooling model that supports them. If any direct call fails, fix it at the vLLM layer, since Dify will only show you a less specific error.

Next, run a Dify workflow that calls the vLLM-backed model with a known prompt and a fixed expected answer, such as a short instruction with a single correct output. Then run an agent that is allowed to use at least one tool, so you can see whether tool calls are issued, executed and returned correctly through the model. Keep these runs in a test workspace. Because the community edition is limited to a single workspace, use the same instance for tests and production only after you have confirmed how your team will separate them. For the SSRF check, configure a tool or HTTP step in a test app to request an internal address and confirm the SSRF_PROXY path blocks it, using the internal and private ranges you care about. Record the result of each blocked and allowed request.

While the tests run, watch the request counters on vLLM's /metrics endpoint. Each test should move the request counts by the number you expect, so a workflow that silently retries or an agent that loops will show up as extra traffic. Note the token throughput and latency histograms at the same time, since they give a baseline for later comparison. Finally, record the vLLM version and the Dify version that were tested, along with the model name, the provider settings and the test results. Dify ships minor releases roughly monthly, and vLLM releases about every two weeks, so this record tells you exactly what to retest after each upgrade. Confirm the current release history with the Dify releases page and the vLLM releases page before you set the retest schedule.

Why the Dify to vLLM connection fails

This table lists the five failures teams hit most often when Dify calls a self-hosted vLLM endpoint, with the cause and fix for each. Read it by matching the symptom you see in Dify to the row, then check the cause before changing settings on either side.

FailureLikely causeFix
Dify cannot reach the endpointDify runs in Docker containers, so localhost points at the container itself. Outbound requests through the SSRF proxy may also be blocked when the vLLM address is private.Use an address the Dify api container can reach, such as the host or service name on the shared Docker network. Confirm the SSRF_PROXY settings allow that private address before changing vLLM.
Model not foundThe model name entered in Dify does not match the name vLLM serves, which is set when the server starts.Query the /v1/models endpoint on vLLM and copy the exact served model name into the Dify provider configuration, including case and path separators.
Chat requests fail with template errorsThe model has no chat template, so the chat completions API cannot format messages.Confirm the model ships a chat template, or start vLLM with a template supplied through --chat-template. Test /v1/chat/completions directly with curl before retrying in Dify.
Authentication errorsThe --api-key value is not sent in the Authorization header, or a reverse proxy in front of vLLM blocks the path Dify calls.Enter the same key in the Dify provider settings and confirm the proxy allowlists the /v1 paths. Do not rely on --api-key alone, since the docs list endpoints it does not protect.
Slow or timed-out responsesvLLM is short on capacity for concurrent requests, or Dify's request timeout is shorter than long generations need.Check vLLM's /metrics for queue depth and KV cache use, then adjust capacity or limits. Raise the Dify timeout only after vLLM response times are understood. For deeper fixes, see the vLLM operations and troubleshooting guide.

Questions buyers ask about Dify and vLLM

What does it cost to run Dify with vLLM as the model provider?

vLLM has no paid edition, so its cost comes from accelerator capacity, the surrounding infrastructure and the people who operate it. Dify Community is free to self-host but is limited to a single workspace. Dify Enterprise is a custom-priced self-hosted edition that adds SSO, multiple workspaces, advanced security, a commercial license and professional support. Your recurring costs will be GPU hours or hardware, hosting for the Dify stack, storage and backups, and staff time for upgrades. Ask any partner for a quote that lists each of these separately, with the one-time setup work shown apart from the ongoing support work. Dify Cloud prices are published separately, but they do not apply to a self-hosted deployment.

How long does a Dify and vLLM setup take?

Duration depends on the scope you agree, not on a fixed template. The main drivers are the number of models you want to route through vLLM, how far the network work reaches (firewall rules, DNS, and keeping vLLM and Dify on the same internal boundary), how much SSO and access control you need, and how deep the testing goes. A single model behind one vLLM endpoint with Dify Community on a flat network is a much smaller job than several models, Enterprise SSO and a formal review of data handling. Ask for a written timeline tied to a defined scope, and confirm which approvals must come before work starts, such as change windows and GPU capacity bookings.

Can our own team set up Dify with vLLM without a partner?

Yes, a capable internal team can do this if it has three skills: Docker and Docker Compose operations, GPU operations for vLLM, and network administration for the internal boundary. Dify's Docker Compose deployment starts several services, including the api, worker, web, plugin daemon, PostgreSQL, Redis, Weaviate, Nginx, a code sandbox and an SSRF proxy, so someone must own that stack after launch. The vLLM side needs the server started with an OpenAI-compatible endpoint, a model that has a chat template, and a clear plan for protecting its API. If one of these skills is missing, a partner can cover that part while your team keeps ownership of the running system.

What does the work need from our team?

The work needs access and decisions from several owners. Plan for:

  • Host access: servers or cloud accounts where Dify and vLLM will run, with the right to install Docker and drivers.
  • GPU capacity: accelerators sized for the models you choose, and confirmation of the NVIDIA, AMD or Intel GPU generation you actually have.
  • Network approvals: rules that let Dify reach the vLLM /v1 endpoint and keep both services off public networks.
  • Identity owners: the people who approve SSO, admin roles and workspace access.
  • Data owners: whoever decides which documents and prompts Dify may send to the model and where logs are kept.

Agree on who signs off each item before the schedule is fixed.

Does the Dify license allow multi-tenant use on our own servers?

No, not without written authorization. Dify's license is a modified Apache License 2.0 that forbids using the source code to operate a multi-tenant environment, where one tenant is one workspace, without written permission from the licensor. It also forbids removing or modifying the logo or copyright information in the Dify console. If you plan to offer Dify to several internal business units or customers as separate workspaces, have your legal team read the LICENSE file and ask the Dify team for written terms before you build the design around that model.

Is vLLM's API protected enough to sit behind Dify?

Not on its own. The vLLM --api-key option protects the /v1, /v2, /inference and /cohere paths, but it does not protect /invocations, /pause, /resume, /abort_requests, /metrics or /health, and the vLLM docs warn against relying on it alone. Put a reverse proxy in front of vLLM that allowlists only the endpoints Dify needs, and keep the vLLM port off the public network. Confirm the exact paths your Dify version calls before you write the allowlist, and test that the admin and metrics paths are unreachable from the Dify network segment.

What should we check after Dify starts talking to vLLM?

Check the connection, the model behavior and the operations signals. Confirm that the model provider in Dify's settings points at the vLLM server's /v1 endpoint URL and returns a response for a test prompt. Confirm that the model has a chat template, or that one was supplied with --chat-template, because chat completions depend on it. Check that Dify's outbound SSRF proxy and its blocked private ranges do not stop the vLLM call. Then confirm vLLM's Prometheus metrics at /metrics are scraped by your monitoring, and that a Dify upgrade is tested against the same vLLM version before it reaches production.

Which parts of a Dify and vLLM project are one-time and which recur?

One-time work covers design, network and identity setup, initial model loading, configuration, testing and documentation for your review. Recurring work covers vLLM and Dify upgrades, patching the host and container images, monitoring, backups of the Dify database and file storage, key rotation (including Dify's SECRET_KEY, where a change logs out all users), and capacity changes as usage grows. Dify minor releases arrive roughly monthly, and vLLM minor releases about every two weeks, so budget time for regular upgrade testing. Ask any partner to separate setup fees from a support or retainer agreement.

How DeployOpen scopes and delivers this integration

DeployOpen scopes the Dify and vLLM connection in writing before any work starts. The written scope names the Dify version and deployment method, the vLLM server version and hardware, the model and its chat template, the /v1 endpoint URL that Dify will call, and the network path between the two stacks. It also records who approves access, which workflows and agents move first, and what counts as done. Most engagements are fixed-scope, so the deliverables and timeline are agreed before the build begins, and a quote follows from that document rather than from a list price.

The build happens inside your own infrastructure, in your cloud accounts, data centers or air-gapped network. DeployOpen installs Dify from its Docker Compose files, adds the vLLM model provider from Dify's Model Provider settings, points it at the vLLM server and confirms that Dify's SSRF proxy, plugin daemon and sandbox can reach the endpoint without opening anything else. Placement of both stacks on the same protected segment, the handling of SECRET_KEY and the vLLM --api-key setting are configured and checked as part of this work, not left as defaults.

Testing and handover follow the build. DeployOpen tests the working connection, including model responses, error paths and access controls, and delivers documentation covering configuration, network placement, secrets and operating steps for your team. Ongoing upgrades to Dify and vLLM, which both ship new releases regularly, can be covered by a retainer. Before you choose a delivery model, ask your own platform team which of these steps they can staff and what evidence your security and compliance reviewers will need.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.