Dify
Dify is an LLM app platform that can use any OpenAI-compatible API as a model provider. Register MirAPI once, then add the models your apps need. Dify does not discover them automatically, so you add each model by its exact catalog name.
What you need
Section titled “What you need”| Element | Value |
|---|---|
| Base URL | https://api.mirapi.ai/v1 |
| API key | A MirAPI key (sk-...) created in the Platform |
| Model | deepseek-chat (add each model separately) |
Register MirAPI as a provider
Section titled “Register MirAPI as a provider”- In Dify, open Settings → Model Provider.
- Click Add model provider and choose OpenAI-API-compatible.
- Fill in the provider:
Provider name: MirAPIBase URL: https://api.mirapi.ai/v1API key: sk-...Dify appends /chat/completions itself, so leave the base URL as https://api.mirapi.ai/v1 and do not add the endpoint path. Dify sends the key in the Authorization: Bearer header, which is what MirAPI’s OpenAI-compatible endpoints expect.
Add models
Section titled “Add models”Add each model under the provider, using the exact id from the catalog (GET /v1/models):
Model name: deepseek-chatModel type: LLM- Use the
idexactly as returned byGET /v1/models. Leave out thevendor/prefix. It exists only for browsing the Platform catalog and is not part of the API model name. - Take the context size from the model’s
context_lengthon the models page.
MirAPI endpoints map to Dify model types as follows:
| Dify model type | MirAPI endpoint | Typical use |
|---|---|---|
| LLM | /v1/chat/completions |
Chat and completion apps |
| Text Embedding | /v1/embeddings |
Knowledge-base retrieval (RAG) |
| Rerank | /v1/rerank |
Re-scoring retrieval candidates |
Save and test each model from the provider list before wiring it into an app.
Verify with a message
Section titled “Verify with a message”- Create or open an app that uses the MirAPI model.
- Open the debug panel and send:
Reply with exactly: connected to MirAPI- The output should contain
connected to MirAPI.
Errors and billing
Section titled “Errors and billing”- 401: the key Dify sends is missing or invalid; check the provider’s API key field.
- 403 with a valid key: the model is not on your key’s whitelist, the balance is exhausted, or the key hit a quota or IP limit. Topping up restores an empty balance immediately.
- 429: you hit a rate limit; retry with exponential backoff. The gateway does not retry for you and sends no
Retry-Afterheader. - Chat is billed per token, images per image, and video per second. You can see usage and spend in the Platform billing log and through the
/api/log/tokendetail endpoint. See Billing & top-ups.