Skip to main content
To connect Dify to BetterToken, prepare an API key, enter the Base URL shown below, and choose a current Model ID from the model plaza.

Key settings

Prerequisites

Additional requirements

  • Dify Cloud or a self-hosted Dify instance with plugins enabled
  • Permission to install model plugins and manage workspace models
This guide configures LLM Chat only. Do not add a GPT chat model as Text Embedding, Rerank, Speech-to-Text, or Text-to-Speech.

Install

Install the OpenAI-compatible model plugin

1

Open Model Providers

In the Dify workspace, go to Integrations > Model Providers.
2

Install the official plugin

Click Install model providers, search for OpenAI-API-compatible, and install it.Dify manages model providers as workspace-level plugins. After installation, apps with the required workspace permissions can select models from this provider.
3

Add a custom model

On the OpenAI-API-compatible card, click Add Model. If the card first shows Setup or Configure, open it and then choose the option to add a model.

Manual setup

Complete this setup in the Dify model-provider UI. You do not need to edit a configuration file.

Enter the model configuration

Use these values for the first model:
Enter only https://bettertoken.ai/v1 as the API Base URL. Do not append /chat/completions; the Dify plugin calls the required endpoint.
Use conservative values for the remaining optional capabilities:
  • Thinking Mode Support: enable it only after confirming model support
  • Stream function calling: select Not Support for the first test
  • Vision Support: enable it only when both the model and endpoint accept image input
  • Structured Output: keep it off until plain chat works
Click Save. Dify validates the API Key, Base URL, and model ID.

Use the model in an app

1

Create or open a Dify app

Open a Chatbot, Agent, Chatflow, or Workflow.
2

Select the model

In the app model selector or an LLM node, choose the model you added under OpenAI-API-compatible.
3

Test plain chat first

Run the first request with a short text input and no tools or images:
4

Enable Agent capabilities afterward

After plain chat works, edit the model configuration if you need tool calls. Set Function Call Type to the mode supported by the model. OpenAI-compatible tool calling usually uses Tool Call, but you must verify support for the selected model and endpoint.

Verify the connection

Send a short test prompt. If the tool returns a response without an authentication or Model ID error, the connection works. Fully restart the tool after changing its configuration.

Switch models

Open the model selector or change the Model field in the configuration. Use the exact Model ID from the model plaza, then restart the current session. Dify stores custom configuration per model ID. To add another model from a supported provider, click Add Model again under the same provider. Use the new ID for both Model Name and model name for API endpoint. You can reuse the Base URL and API Key.

Common errors

Saving returns 401

  • Check that the API Key is complete
  • confirm that the Model ID comes from the supported provider
  • Check the key status and balance in the BetterToken Dashboard

Saving returns 404

  • The API Base URL must be https://bettertoken.ai/v1
  • Do not append /chat/completions
  • Make sure model name for API endpoint exactly matches the model plaza ID

Dify reports model not found

Model Name can affect how Dify displays and selects the model. The actual request model is controlled by model name for API endpoint. Use the same model ID from a supported provider in both fields.

Plain chat works, but Agent tools fail

Set Function Call Type back to Not Support and verify a basic LLM node. Change it to Tool Call only when the selected model supports tool calling, then test the tool arguments again.

Knowledge cannot use this model as an Embedding Model

This is expected. A chat LLM cannot replace an embedding model. This guide does not confirm BetterToken embedding or rerank endpoints for Dify; configure a supported embedding provider separately for Knowledge.

Advanced setup

Supported providers

Statuses apply to the BetterToken setup documented on this page.
  • Manual setup: enter the API Key, Base URL, and Model.
  • Not supported: no verified direct setup is currently available.

Technical details

This setup uses https://bettertoken.ai/v1. The tool appends the OpenAI-compatible endpoint path. Do not add /chat/completions or /responses unless a specific field explicitly requires it.