Dify में OpenAI-compatible API और पहला workflow
Dify में model provider, API Key और current Model ID configure कर के text-in/text-out workflow का सुरक्षित पहला test चलाने की गाइड।
विषय-सूची

Dify official OpenAI-API-compatible model provider से external API जोड़ सकता है। अपना API Key, compatible Base URL और current Model ID चाहिए। Verification के लिए text input, एक LLM node और text output वाला छोटा workflow बनाएँ, एक बार run करें और provider record से मिलाएँ।
इस workflow के लिए अपनी API Key चाहिए? BetterToken खाता बनाएँ
एक अलग test key के साथ बिना external action वाला workflow चलाने हेतु BetterToken Dify guide खोलें। यह model API setup को कवर करती है; Dify installation, Marketplace, third-party plugins, agents और tools अलग layers हैं।
तैयारी
आपके पास working Dify Cloud या self-hosted Dify, Integrations/Marketplace और Model Providers का access, अपना BetterToken API Key, catalog से current Model ID और tools रहित नया test workflow होना चाहिए। BetterToken endpoint और Dify Cloud, Marketplace, GitHub, Docker registry या third-party plugins की उपलब्धता को एक ही बात न मानें।
1. official provider स्थापित करें
Dify में Integrations या Marketplace, फिर Model Providers खोलें। Official OpenAI-API-compatible provider खोजें और जरूरत हो तो install करें। Author और listing को official Dify Marketplace में मिलाएँ; मिलता-जुलता नाम वाला random plugin अलग fields और credential handling रख सकता है।
2. BetterToken model जोड़ें
Provider settings में नया LLM model जोड़कर ये values दें:
- Model Type: LLM;
- Model Name / ID: current catalog का exact Model ID;
- API Key: आपका BetterToken API Key;
- API Base URL:
https://www.bettertoken.ai/v1; - Completion mode: यदि provider/model माँगे तो Chat।
Base URL में /chat/completions न जोड़ें; provider पूरा path बनाता है। Real credential को export, screenshot या issue में न रखें। Context size, max tokens, vision या streaming fields हों तो current model documentation के अनुसार ही भरें; पहले test में ये अतिरिक्त features आवश्यक नहीं हैं।
3. credential save करके जाँचें
Save करते समय Dify credential validate करता है। इससे केवल provider की authentication प्रक्रिया पूरी होना सिद्ध होता है, पूरा workflow नहीं। Error पर provider name/version, Model ID, key रहित Base URL, छोटा error type/HTTP status और समय नोट करें। API Key या sensitive full response न सहेजें।
4. न्यूनतम workflow बनाएँ
नया Workflow application बनाकर केवल तीन elements जोड़ें:
questionनाम के text variable वाला Start;- जोड़ा गया BetterToken model वाला LLM;
- LLM response text वाला End।
LLM prompt के लिए यह template रखें:
एक पंक्ति में उत्तर दें। इनपुट: {{question}}
Start → LLM → End जोड़ें। पहले run में HTTP tools, database, knowledge retrieval, agent loop या publishing न जोड़ें; वे पहली failure की वजह छिपा देंगे।
5. एक test run करें
इनपुट दें:
DIFY_OK और 2 + 2 के योग के रूप में संख्या 4 लौटाएँ।
Setup तब verify होता है जब Dify expected text दे, LLM node credential/model/endpoint error के बिना पूरा हो और BetterToken Dashboard में expected model व status का record दिखे। Dashboard में input, output, applicable cache tokens और charge मिलाने से यह जोखिम घटता है कि workflow ने चुपचाप कोई दूसरा provider या model इस्तेमाल किया।
Errors को अलग करें
Provider या plugin install नहीं होता
यह Dify Marketplace/plugin-daemon layer की समस्या है। Self-hosted setup में Dify version, plugin daemon की network access, HTTPS और certificate chain जाँचें। BetterToken API Key बदलने से यह ठीक नहीं होगा।
ToolProviderCredentialValidationError या 401
Key फिर भरें, spaces और selected provider जाँचें। देख लें कि credential model के लिए है, unrelated tool plugin के लिए नहीं।
404 या model not found
Base URL https://www.bettertoken.ai/v1 हो और manually जोड़ा /chat/completions हटाएँ। फिर model plaza से current ID copy करें और उसकी key/provider availability जाँचें।
Credential save है, workflow फिर भी fail है
केवल LLM node चलाएँ। Tools, streaming और structured output हटाकर छोटा text-in/text-out test दोहराएँ; सफल होने पर extra nodes एक-एक करके वापस लाएँ।
इस setup की सीमा
पहला workflow official OpenAI-API-compatible provider से एक model request सिद्ध करता है। यह हर Dify agent, community plugin, tool या external service की compatibility सिद्ध नहीं करता। Side effect वाले action के लिए अलग test और explicit user confirmation रखें। Dynamic Model IDs और prices configuration के दिन दोबारा जाँचें।