> ## Documentation Index
> Fetch the complete documentation index at: https://docs.openp.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Dify

> Use OpenPAI as a model provider in Dify

[Dify](https://dify.ai/) is an open-source LLMOps platform that supports integrating OpenPAI as a unified model provider.

## Configuration steps

<Steps>
  <Step title="Open settings">
    Avatar at the top-right of the Dify console → **Settings → Model Provider**.
  </Step>

  <Step title="Choose OpenAI-API-compatible">
    Find **OpenAI-API-compatible** in the provider list and click **Setup**.
  </Step>

  <Step title="Fill in the model info">
    Add a separate row for each model you want to use:

    * **Model type**: LLM
    * **Model Name**: `gpt-5.5` (or another OpenPAI model ID)
    * **API Key**: `sk-XXXXXXXXXXXXXXXX`
    * **API Base / URL**: `https://openp.ai/v1`
    * **Model context length**: per the chosen model (e.g. `gpt-5.5` is 1000000)
    * **Max tokens upper limit**: as needed (e.g. 4096)
    * **Function Calling**: enable (if the model supports it)
    * **Vision support**: enable (if the model supports it)
  </Step>

  <Step title="Save and test">
    After saving, Dify makes a call to verify.
    Once it passes, the model can be selected in app orchestration in the Studio.
  </Step>
</Steps>

## Adding Embedding / Rerank

Dify's RAG needs embedding and rerank models, also added via **OpenAI-API-compatible**:

| Model type     | Model name                 | Notes           |
| -------------- | -------------------------- | --------------- |
| Text Embedding | `text-embedding-3-small`   | 1536 dimensions |
| Text Embedding | `bge-m3`                   | 1024 dimensions |
| Rerank         | `rerank-multilingual-v3.0` | Cohere          |
| Rerank         | `bge-reranker-v2-m3`       | BAAI            |

<Note>Rerank goes through OpenPAI's `/v1/rerank` endpoint. Choosing the **Cohere** or **Jina** provider type in Dify also routes correctly — set the Base URL to `https://openp.ai/v1` as well.</Note>

## Use in workflows

After adding the models, create an app in Dify Studio:

* **Chat assistant** → choose OpenPAI's GPT/Claude/Gemini model.
* **Workflow** → add an LLM node and select OpenPAI as the model.
* **Agent** → combine with Tools and Function Calling.
* **Knowledge base RAG** → use OpenPAI for both embedding and rerank.

## Multi-model strategy

Dify lets you **choose a different model per node** within one app. A typical combination:

* Retrieval stage: `gpt-5.4-mini` (low latency)
* Complex reasoning: `claude-opus-4-8` or `o3-mini-high`
* Summarization: `gemini-3.1-flash-lite` (fast + long context)

All calls share the same OpenPAI key and account quota, keeping management simple.
