TokenLab

Frameworks & Platforms

Dify

Integrate TokenLab with Dify using the OpenAI-API-compatible provider and a custom base URL

Overview

Use the OpenAI-API-compatible model-provider plugin to connect Dify to TokenLab. Set the model type to LLM, Completion mode to Chat, and API Type to Chat Completions API. This guide uses Chat Completions.

Prerequisites

  • TokenLab account with API access
  • Dify Cloud or self-hosted Dify

Configuration Steps

Step 1: Get Your API Key

  1. Log into TokenLab Dashboard
  2. Open API Keys
  3. Create or copy an API key that starts with sk-

Step 2: Configure the Provider

Open Model Providers

In Dify, go to Settings → Model Providers

Select OpenAI-API-compatible

Open OpenAI-API-compatible. If it is missing, install that model-provider plugin from the Dify Marketplace. Choose Add model to enter the TokenLab settings.

Enter TokenLab Settings

Use these values:

FieldValue
API Keysk-your-tokenlab-key
Model typeLLM
Completion modeChat
API TypeChat Completions API
API Base URLhttps://api.tokenlab.sh/v1

Add Models

Add the models you want to use, for example:

  • gpt-5.4
  • gpt-5.4-mini
  • claude-sonnet-5
  • claude-opus-4-8
  • gemini-3.5-flash
  • gemini-3.1-flash-lite
  • deepseek-v4-flash

Step 3: Test Connection

  1. Select a model you added, such as gpt-5.4-mini.
  2. Send a test prompt
  3. Confirm Dify receives a valid response

Embeddings for Knowledge Bases

For RAG and knowledge base indexing, add an embedding model such as:

  • text-embedding-3-small
  • text-embedding-3-large

Then set it as the default embedding model in the relevant knowledge base or application settings.

Choose models

Copy current chat and embedding model IDs from the Models page. Dify must configure chat and embeddings separately, and each model must support the API used by that Dify component.

Best Practices

Troubleshooting

On this page