> For the complete documentation index, see [llms.txt](https://docs.tensorx.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tensorx.ai/automation-platforms/dify.md).

# Dify

Dify is an open-source LLMOps platform for building AI applications, chatbots, and agents with a visual workflow interface.

## Prerequisites

* A Dify instance (self-hosted or [Dify Cloud](https://cloud.dify.ai))
* Your TensorX API key from [app.tensorx.ai](https://app.tensorx.ai)

## Configuration

Dify connects to TensorX through the **OpenAI API Compatible** plugin, which supports custom OpenAI-compatible endpoints.

### Step 1: Install the Plugin

1. Go to your Dify workspace
2. Navigate to **Plugins** in the left sidebar
3. Search for **OpenAI API Compatible**
4. Click **Install** to add the plugin

{% hint style="info" %}
The OpenAI API Compatible plugin is an official Dify plugin that supports LLMs, text embedding, speech-to-text, and text-to-speech from OpenAI-compatible providers.
{% endhint %}

### Step 2: Add Model Provider

1. Go to **Settings** → **Model Providers**
2. Find **OpenAI API Compatible** in the list
3. Click **Add Model**

### Step 3: Configure the Model

Fill in the configuration form:

| Field                | Value                         |
| -------------------- | ----------------------------- |
| **Model Type**       | `LLM`                         |
| **Model Name**       | `deepseek/deepseek-chat-v3.1` |
| **API Key**          | Your TensorX API key          |
| **API Endpoint URL** | `https://api.tensorx.ai/v1`   |

Click **Save** to add the model.

### Step 4: Add More Models (Optional)

Repeat Step 3 to add additional TensorX models:

| Model Name             | Best For                      |
| ---------------------- | ----------------------------- |
| `z-ai/glm-5.1`         | Tool calling, code generation |
| `minimax/minimax-m2.5` | Reasoning, functions          |
| `moonshotai/kimi-k2.5` | Vision, long context          |

## Using TensorX Models

### In Chat Applications

1. Create a new **Chatbot** or **Agent** application
2. In the orchestration panel, click the model selector
3. Select your configured TensorX model
4. Adjust parameters (temperature, max tokens) as needed

### In Workflows

1. Create a new **Workflow** application
2. Add an **LLM** node to your workflow
3. Select your TensorX model from the dropdown
4. Configure the prompt and parameters

## Recommended Models

{% hint style="info" %}
**For Coding Tasks:**

* `z-ai/glm-5.1` - Best for tool calling and structured outputs
* `minimax/minimax-m2.5` - Best for complex reasoning tasks
  {% endhint %}

| Model ID                      | Use Case                             |
| ----------------------------- | ------------------------------------ |
| `deepseek/deepseek-chat-v3.1` | General chat, balanced performance   |
| `z-ai/glm-5.1`                | Tool calling, function calling, code |
| `minimax/minimax-m2.5`        | Reasoning, analysis, complex tasks   |
| `moonshotai/kimi-k2.5`        | Vision tasks, long context           |

## Advanced Configuration

### Adding Embedding Models

To use TensorX for text embeddings:

1. Go to **Settings** → **Model Providers**
2. Click **Add Model** under OpenAI API Compatible
3. Set **Model Type** to `Text Embedding`
4. Enter the embedding model name
5. Configure API key and endpoint URL

### Adding Speech Models

For text-to-speech or speech-to-text:

1. Add a new model with type `TTS` or `Speech2Text`
2. Use the appropriate TensorX audio model
3. Configure API key and endpoint URL

## Agent Configuration

When building agents that use tools:

1. Select `z-ai/glm-5.1` as your model (best tool calling support)
2. Enable **Function Calling** in the agent settings
3. Add your desired tools from the Dify tool library
4. Configure tool permissions and parameters

## Example: Building a Code Assistant

1. Create a new **Agent** application
2. Select `z-ai/glm-5.1` as the model
3. Add a system prompt:

   ```
   You are an expert programming assistant. Help users write, debug, and explain code.
   ```
4. Enable tools like **Code Interpreter** if available
5. Set temperature to `0.3` for more deterministic outputs
6. Publish your application

## Troubleshooting

### "Model Not Found" Error

* Ensure you're using the full model ID (e.g., `deepseek/deepseek-chat-v3.1`)
* Verify the API Endpoint URL is exactly `https://api.tensorx.ai/v1`

### "Authentication Failed" Error

* Check that your API key is correct
* Verify the key at [app.tensorx.ai](https://app.tensorx.ai)
* Ensure there are no extra spaces in the API key field

### Model Not Appearing in Selector

* Confirm the plugin is installed and enabled
* Check that the model was saved successfully in Model Providers
* Refresh the page or restart the application

### Slow Responses

* Check your Dify instance's network connection
* Consider using a model with faster response times
* Enable streaming in the application settings

## Support

Need help? Contact us at <support@tensorx.ai>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tensorx.ai/automation-platforms/dify.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
