Dify
Dify is an LLM app platform that calls any OpenAI-compatible API as a model provider. Register MirAPI once, then add the models your apps need — Dify does not auto-discover them, so you add each model by its exact catalogue 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 console |
| Model | deepseek-chat (added per model) |
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 — 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”Dify does not list MirAPI models automatically. Add each model under the provider, using the exact id from the catalogue (GET /v1/models):
Model name: deepseek-chatModel type: LLM- Use the
idexactly as returned byGET /v1/models. Skip thevendor/prefix — it only exists for browsing the console catalogue 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 — Dify is sending a missing or invalid key; check the provider’s API key field.
- 403 with a valid key — the model is not on your key’s allowlist, the balance is exhausted, or the key hit a quota or IP limit. Top up to restore 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. - Billing is per token for chat, per image, or per second of video. Usage and spend are in the console billing log and the
/api/log/tokendetail endpoint — see Billing & top-ups.