Model Providers
Every Dify app needs at least one model provider. Keys are workspace-scoped: Owner / Admin configures them once, every app can pick those models. Official entry: Integrations → Model Provider (the Marketplace installs more plugin providers).
Add a cloud vendor
Typical path:
- Find the vendor under “Install model providers” or in the Marketplace
- After install, click Setup on the card
- Paste the API key; add a custom endpoint / organization if you use a proxy or dedicated cloud
- Dify validates before enabling—do not select a failed provider in an app
Which cards you see depends on version and Marketplace—do not memorize a vendor list.
Models are not only chat
One provider often exposes several model types. Set Default Models (usually top-right) per job:
A High Quality knowledge index requires a working embedding model. Strong chat plus a missing embedder is the most common first-week stall.
Multiple keys and custom models
- Add more than one key per vendor to split dev/prod or quota (Configure / manage credentials on the card)
- Missing or fine-tuned models: Add Model on vendors that support custom models; supply name and credentials
- If name and type match an existing model, Dify attaches the new key instead of duplicating the card
- Deleting a custom model’s last key removes the model; leftover credentials may remain under “manage credentials”
Cloud may also spend platform AI credits on a popular subset. Bring your own account when you need higher limits. Self-host almost always means your keys or your Ollama.
Choosing and comparing inside an app
Chatbot / Agent / LLM nodes pick a model from a dropdown. Leave sampling defaults first. Compare with one frozen prompt:
- Fix a user question (include one that should be refused)
- Run two or three models
- Score instruction following, language quality, latency, price
- Agent preview can Debug as Multiple Models (docs: up to about four) side by side
Tool-using agents prefer models with native Function Calling. Agent Settings labels Function Calling vs fallback ReAct. See Agent.
Safety
- Keep keys in the Dify workspace (or self-host secrets)—not in frontend code, shared DSL packs, or public Git
- Use workspace environment variables for secrets so exported DSL does not leak them
- Rotate by adding the new key before deleting the old one, or live apps get
401
Versus LangChain: there you export OPENAI_API_KEY into a process; Dify is the same idea as a workspace UI.
Troubleshooting
Validation fails? Check key scope, quota, whether the endpoint needs /v1, and outbound HTTPS proxies.
Chat works, knowledge ingest does not? Set a default embedding model or pick one in the knowledge-create flow.
Ollama will not connect? Do not use localhost:11434 from Docker. See Ollama Integration.
Next steps
- Knowledge Base
- Quick Start
- On this site: Ollama · LangChain models