Build a chat app with Dify
Connect a Primex chat model through Dify's official OpenAI-API-compatible provider plugin. Choose a model from Dify Setup. This guide starts with LLM → Chat → Chat Completions.
Configure the workspace model
In your Dify workspace's Settings → Model Providers, install the official OpenAI-API-compatible plugin. This review uses plugin 0.0.73. Add an LLM model and enter:
| Form field | Value |
|---|---|
| Model type | LLM |
| Model name | Your exact live Primex offering ID |
| Model name for API endpoint | The same exact offering ID |
| API Base URL | https://gateway.primexos.com/v1 |
| API Key | A dedicated Primex key |
| Completion mode | Chat |
| API Type | Chat Completions API |
| Token parameter name | max_tokens |
| Model context size | The current published Catalog context limit |
| Upper bound for max tokens | The current published Catalog output limit |
| Function Call Type | Not Support |
| Vision Support | Not Support |
| Include Usage in Stream | Enabled |
| User Identity Support | Not Support |
The Setup copy is a reference checklist for these form fields. Store the key in the workspace model credential. Keep it out of prompts, app code and shared exports. Confirm any unpublished context or output limit before saving; a form's default value is not evidence of model capacity.
Explicit max_tokens avoids the plugin's model-name heuristic choosing a different
token parameter for an alias. Start with strict compatibility and no extra
thinking, web-search, image or tool settings. This guide does not qualify Responses
or Dify's separate embedding, reranking, speech or image model interfaces.
Saving can send a model validation prompt. The reviewed plugin has fallback validation paths, so saving is not necessarily a single credential-only check. Use a dedicated key with a suitable cap and inspect Usage before saving again. Read Dify's model-provider guidance for workspace permissions and provider management.
Verify a short chat
Create a Chatbot app and select the Primex model. In its model parameters, choose a small output limit within the published upper bound; use a temperature accepted by that model. Start without a knowledge base, tools or external calls.
Send a short greeting in Preview, then a follow-up referring to the first reply. Check that both answers finish and the follow-up retains conversation context. In Usage, confirm the exact model and key, both requests and any earlier credential-validation request.
Dify's token estimates, configured prices and application statistics can differ from Primex's recorded usage and charges. Keep Primex Usage as the account record. An interrupted client stream or app error does not establish the final charge; check Usage before retrying. Plugin/platform request deadlines and automatic retries remain unqualified in this guide.
Add a simple chatflow
Once the short chat works, create a Chatflow with user input, one LLM node and one Answer node. Select the same Primex model in the LLM node, bind the user's question into its prompt, and map that node's text output into Answer. Run it in Preview and confirm the answer and corresponding Usage request.
Keep node retries and fallback branches disabled for the first flow. Configure retrieval, agents and tools separately from the basic LLM node.
Retrieval and team use
For a knowledge base, select and verify an embedding model separately from the chat model. Then verify ingestion, retrieved passages and the final LLM answer. The compatible plugin's non-LLM URL construction can differ from its chat path; do not copy this chat base URL into every model-type form without checking it. Reranking and tool/plugin calls need their own endpoint, credential and error handling.
Use a dedicated key for the app or environment, review its caps, and agree which workspace members can use or change the provider. Before sharing or publishing the app, review the data sent to Dify, plugins and model providers with your team. See team evaluation and data handling.
Common fixes and removal
- 404: check the chat base URL, API type and Chat mode; avoid a duplicated
/v1or a full request path in the base-URL field. - Wrong model or token parameter: set the endpoint model name to the exact
Primex ID and select
max_tokensexplicitly. - 401, 402 or 429: review the key, balance/cap and error guide before saving or running again.
- Unexpected requests: distinguish model validation, retries, fallback nodes, retrieval and auxiliary/plugin calls in Usage.
Before removing the credential or model, replace it in dependent apps and flows. Revoke the dedicated Primex key when those workloads no longer need it. Removing a provider does not remove app data, published apps or their retained history.
Need help connecting? Report a setup issue.