# WorkBuddy Integration Guide

This guide details how to integrate the TokensByte platform into the **WorkBuddy** AI client, configure OpenAI-compatible custom model channels, set model capabilities and feature toggles, and use them effectively in conversations.

---

## 1. Prerequisites

Before configuring WorkBuddy, log in to the TokensByte Console to obtain your credentials:

1. **API Base URL**: Obtain the base request URL at the top of **"Token Management"** in the Console (e.g., `https://api.yourdomain.com`).
2. **API Token (API Key)**: In **"Token Management"**, click **"Create API Token"** and copy the key starting with `sk-`.
3. **Model Name (Model ID)**: Locate the desired model in **"Model Marketplace"** and copy its full model name (e.g., `doubao-seed-2-1-lite-260915`).

---

## 2. Step-by-Step Integration

### Step 1: Open Settings and Go to Model Management

1. Open the WorkBuddy client and click **"Models"** under the **"Features"** category in the left navigation bar.
2. In the **"Custom Models"** section on the right, click the **"Add Model"** button in the upper-right corner.

![Open Model Settings and Add Model](/assets/docs/workbuddy/image1.png)

> [!NOTE]
> Added model configurations are automatically saved to your local configuration file:
> `%USERPROFILE%\.workbuddy\models.json`

---

### Step 2: Select "Custom" as the Provider

1. In the **"Add Model"** popup window, click the **"Provider (OpenAI-Compatible API Only)"** dropdown.
2. Scroll down to the **"Other"** category at the bottom and select **"Custom"**.

![Select Custom Provider](/assets/docs/workbuddy/image2.png)

---

### Step 3: Configure Endpoint URL, Key, and Model Parameters

Follow the screenshot below to enter the credentials obtained from the Console into the corresponding fields:

![Configure Endpoint and Model Parameters](/assets/docs/workbuddy/image3.png)

1. **Endpoint URL**: Enter the full Chat endpoint URL:
   ```text
   https://<your-domain>/v1/chat/completions
   ```
   > [!IMPORTANT]
   > The Base URL at the top of the Console only contains the domain (e.g., `https://api.example.com`)—you **must append `/v1/chat/completions` at the end**, otherwise requests will not route to the correct chat endpoint.

2. **API Key**: Enter the `sk-` key copied from "Token Management".
3. **Connectivity Check**: After entering the URL and key, click **"Test Connection"** on the right and wait for the **"Connection Successful"** prompt before continuing.
4. **Model Name**: Paste the standard model name copied from Model Marketplace (e.g., `doubao-seed-2-1-lite-260915`).
5. **Advanced Settings** (check options according to the model's actual capabilities):
   - **Tool Calling**: Check this if the model supports Function / Tool Calling;
   - **Image Input**: Check this if it is a multimodal Vision model;
   - **Thinking Mode / Allow Disabling Thinking**: For models with deep reasoning chains such as DeepSeek-R1 and Thinking models, check the corresponding options for the best reasoning display.
6. Click **"Save"** in the lower-right corner.

---

### Step 4: Select the Model in Chat and Start Using It

1. Open the WorkBuddy chat interface.
2. In the model selector dropdown at the bottom-right corner of the input box, choose the model you just added (e.g., `doubao-seed-2-1-lite-260915`).
3. Send any message (e.g., "Hello"), wait for the model's reply, and verify the model badge below the reply to confirm it was successfully invoked through the TokensByte gateway.

![Select Model in Chat and Verify Usage](/assets/docs/workbuddy/image4.png)

---

## 3. Frequently Asked Questions & Troubleshooting (FAQ)

### 1. Clicking "Test Connection" returns an error or gets no response?
* **Check Endpoint URL**: Confirm that `/v1/chat/completions` has been appended at the end and the protocol is `https://`.
* **Check Network Environment**: Confirm that your machine can access the TokensByte site domain normally.

### 2. Prompted with 401 Unauthorized?
* **Invalid Key or Insufficient Quota**: Go to Console "Token Management" to confirm that the API token is active, not expired, and has sufficient available quota.

### 3. Returning 404 Not Found or Model Not Found?
* **Model Name Spelling**: Verify that the model name entered in WorkBuddy strictly matches the ID in the platform's "Model Marketplace" (case-sensitive and hyphen-sensitive).
