Skip to main content
To connect Dify to BetterToken, install the official OpenAI-API-compatible model plugin and add a custom LLM configuration for each GPT Key group model you want to use. Set the API Base URL to https://www.bettertoken.ai/v1.

Prerequisites

  • Dify Cloud or a self-hosted Dify instance with plugins enabled
  • BetterToken API Key (register here)
  • A GPT Key group model ID copied from the model plaza
  • 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 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.

Enter the model configuration

Use these values for the first model:
Enter only https://www.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.

Add more models

Dify stores custom configuration per model ID. To add another GPT Key group model, 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.

Troubleshooting

Saving returns 401

  • Check that the API Key is complete
  • Confirm that it belongs to the GPT Key group
  • Check the key status and balance in the BetterToken Dashboard

Saving returns 404

  • The API Base URL must be https://www.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 GPT Key group model ID 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.