# Dify (/docs/guides/dify)

Use cheapaimodel models in Dify apps and workflows through the OpenAI-API-compatible model provider.



Dify connects to OpenAI-compatible services through the **OpenAI-API-compatible** model provider plugin. You add each model by hand, and every app in the workspace can then use it.

|          | Dify setting     | Value                                                                             |
| -------- | ---------------- | --------------------------------------------------------------------------------- |
| Base URL | **API Base URL** | `https://api.cheapaimodel.ai/v1`                                                  |
| API key  | **API Key**      | Your key from the console's [API Keys](https://console.cheapaimodel.ai/keys) page |
| Model ID | **Model Name**   | `deepseek-v4-1-flash`, or any ID from the [catalog](/models)                      |

## Set it up [#set-it-up]

<Steps>
  <Step>
    ### Install the provider [#install-the-provider]

    As a workspace owner or admin, open **Integrations → Model Provider**. Find **OpenAI-API-compatible** under **Install model providers**, or in the Dify Marketplace, and install it.
  </Step>

  <Step>
    ### Add a model [#add-a-model]

    On the **OpenAI-API-compatible** card, select **Add Model** and fill in:

    | Field                          | Value                                                                                                          |
    | ------------------------------ | -------------------------------------------------------------------------------------------------------------- |
    | **Model Type**                 | **LLM**                                                                                                        |
    | **Model Name**                 | `deepseek-v4-1-flash`                                                                                          |
    | **API Key**                    | Your cheapaimodel key                                                                                          |
    | **API Base URL**               | `https://api.cheapaimodel.ai/v1`                                                                               |
    | **Completion mode**            | **Chat**                                                                                                       |
    | **Model context size**         | The context length on the model's page, for example [/models/deepseek-v4-1-flash](/models/deepseek-v4-1-flash) |
    | **Upper bound for max tokens** | The maximum output tokens on the same page                                                                     |

    Both size fields start at `4096`, so set them from the model page. Leave **model name for API endpoint** empty and **API Type** on &#x2A;*Chat Completions API (/chat/completions)**. The capability fields, such as **Function Call Type** and **Vision Support**, start off; turn one on only for what you've confirmed the model handles.

    Select **Save**. Dify sends a short test request to the model before saving, so a wrong field fails here instead of in your app. Repeat for each model ID you want.
  </Step>

  <Step>
    ### Use it [#use-it]

    Pick the model in an app's or LLM node's model selector, or make it the workspace default with **Default Models → System Reasoning Model**.
  </Step>
</Steps>

## Knowledge bases [#knowledge-bases]

cheapaimodel has no embeddings models yet. Don't add a **Text Embedding** model that points at cheapaimodel; set **Default Models → Embedding Model** to another provider for your knowledge bases.

## Common mistakes [#common-mistakes]

* **Save fails with `Credentials validation failed with status code 404` and a body of `fault filter abort`.** **API Base URL** is missing `/v1`. Set `https://api.cheapaimodel.ai/v1`.
* **Save fails with status code `404` and `Invalid URL (POST /v1/chat/completions/chat/completions)` in the body.** **API Base URL** includes the endpoint path. Dify appends `/chat/completions` itself; set `https://api.cheapaimodel.ai/v1`.
* **Save fails with status code `401`.** The key is wrong, expired or out of budget. Check it in the console.
* **Save fails with status code `503` and `model_not_found`.** **Model Name** must be a catalog ID, spelled exactly. Put a friendlier label in **Model display name** instead.
