# Dify

Dify connects any OpenAI-compatible service through the OpenAI-API-compatible model provider. Add each model on its own, and change a few defaults.

> https://nezhagate.com/en/docs/integrations/dify

Written against Dify 1.17 · OpenAI-API-compatible 0.0.68

## Before you start

- A workspace owner or admin account; only they can set up model providers.

- Install **OpenAI-API-compatible** (the official langgenius plugin) from the Marketplace.

## Add a model

Open **Model Provider** (under Integrations in newer versions, Settings in older ones), click **Add Model** on the OpenAI-API-compatible card and fill in the form as below:

| Field | Value |
| --- | --- |
| **Model Type** | LLM |
| **Model Name** | The exact model id, such as `gpt-5.5` |
| **API Key** | Your NezhaGate API key |
| **API Base URL** | `https://nezhagate.com/v1` |
| **Completion mode** | Chat |
| **Model context size** | The model's real context length (see its API doc). **The default is 4096**; left as is, long conversations get cut. |
| **Upper bound for max tokens** | The model's maximum output tokens; this also defaults to 4096. |
| **Function Call Type** | **Tool Call** for models with tool calling. The default, Not Support, keeps agents from calling tools. |
| **Vision Support** | Support, for models that take image input. |
| **API Type** | Keep **Chat Completions API**. |

The address must include `/v1`: the plugin appends `/chat/completions` directly. Leave the other fields at their defaults.

## Claude (optional)

You can also install the official **Anthropic** plugin, set **API URL** to `https://nezhagate.com/anthropic`, and add Claude models one by one with **Add Model** (such as `claude-sonnet-5`).

## Test

Saving sends one very short request to validate (billed on its tiny usage). Then create a chatbot in **Studio**, pick the model and send a message in the preview.

## Troubleshooting

**Credentials validation failed with status code 404**

The address is missing `/v1`; it should be `https://nezhagate.com/v1`.

**Validation returns 401 or model not found**

401 means the key is wrong; model not found means the model id is misspelled. Use the ids in the [API reference](https://nezhagate.com/en/docs/api).

**The agent never calls tools**

**Function Call Type** is still Not Support in the model form; change it to Tool Call.

**Long answers or conversations get cut**

**Model context size** and **Upper bound for max tokens** are still at 4096; raise them to the model's real values.
