Skip to content

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.

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)
  1. In Dify, open Settings → Model Provider.
  2. Click Add model provider and choose OpenAI-API-compatible.
  3. Fill in the provider:
Provider name: MirAPI
Base URL: https://api.mirapi.ai/v1
API 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 each model under the provider, using the exact id from the catalog (GET /v1/models):

Model name: deepseek-chat
Model type: LLM
  • Use the id exactly as returned by GET /v1/models. Leave out the vendor/ 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_length on 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.

  1. Create or open an app that uses the MirAPI model.
  2. Open the debug panel and send:
Reply with exactly: connected to MirAPI
  1. The output should contain connected to MirAPI.
  • 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-After header.
  • 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/token detail endpoint. See Billing & top-ups.