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
- Log into TokenLab Dashboard
- Open API Keys
- 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:
| Field | Value |
|---|---|
| API Key | sk-your-tokenlab-key |
| Model type | LLM |
| Completion mode | Chat |
| API Type | Chat Completions API |
| API Base URL | https://api.tokenlab.sh/v1 |
Add Models
Add the models you want to use, for example:
gpt-5.4gpt-5.4-miniclaude-sonnet-5claude-opus-4-8gemini-3.5-flashgemini-3.1-flash-litedeepseek-v4-flash
Step 3: Test Connection
- Select a model you added, such as
gpt-5.4-mini. - Send a test prompt
- 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-smalltext-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.