> ## Documentation Index
> Fetch the complete documentation index at: https://docs.haitoken.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Trae Work

> Connect Trae Work to HaiToken

Trae Work supports custom model services through OpenAI-compatible or Anthropic-compatible protocols. For HaiToken, the most reliable setup is `OpenAI Chat Completions`.

## What You Need

* A HaiToken API key
* At least one available model ID, such as `deepseek-v4-flash`
* HaiToken OpenAI-compatible address: `https://api.haitoken.ai/v1`

## Setup Steps

### Step 1: Open the model settings

In Trae Work, go to **Settings** > **Models**.

If the current page shows **Add Model**, click it to open the add-model dialog.

<img src="https://mintcdn.com/hai-token/VEsEJoBleYGPGfir/images/trae/PixPin_2026-07-08_18-09-44.png?fit=max&auto=format&n=VEsEJoBleYGPGfir&q=85&s=45c5dfd8a1ffb72ef843eb2da88c1788" alt="Open Trae Work model settings" width="1323" height="774" data-path="images/trae/PixPin_2026-07-08_18-09-44.png" />

### Step 2: Choose `Custom Configuration`

In the add-model dialog, switch from preset providers to **Custom Configuration**.

This allows Trae Work to call HaiToken directly with the protocol, endpoint, and model ID you provide.

<img src="https://mintcdn.com/hai-token/VEsEJoBleYGPGfir/images/trae/PixPin_2026-07-08_18-10-20.png?fit=max&auto=format&n=VEsEJoBleYGPGfir&q=85&s=9efd99134631ffcdd995b83e9766e852" alt="Choose custom configuration" width="1204" height="580" data-path="images/trae/PixPin_2026-07-08_18-10-20.png" />

### Step 3: Choose the API format

Select **OpenAI Chat Completions** as the API format.

HaiToken provides an OpenAI-compatible chat endpoint at `POST /v1/chat/completions`, and this is the simplest path for most Trae Work integrations.

<img src="https://mintcdn.com/hai-token/VEsEJoBleYGPGfir/images/trae/PixPin_2026-07-08_18-10-39.png?fit=max&auto=format&n=VEsEJoBleYGPGfir&q=85&s=7e80096083373cb09517816354f67542" alt="Choose OpenAI Chat Completions" width="1182" height="854" data-path="images/trae/PixPin_2026-07-08_18-10-39.png" />

### Step 4: Fill the endpoint, model ID, and API key

Use the following values:

| Field       | Recommended value                                    |
| ----------- | ---------------------------------------------------- |
| API format  | `OpenAI Chat Completions`                            |
| Model ID    | A real HaiToken model ID such as `deepseek-v4-flash` |
| API Key     | Your HaiToken API key                                |
| Request URL | Prefer `https://api.haitoken.ai/v1`                  |

If the UI provides a **Full URL** switch, it is safer to keep it off first and enter the base address `https://api.haitoken.ai/v1`.

If **Full URL** is already enabled, then use the full endpoint `https://api.haitoken.ai/v1/chat/completions` instead.

If the dialog also exposes optional fields, adjust them according to the real model capability:

* Multimodal: enable only if the model supports image input
* Display name: for example `HaiToken DeepSeek V4 Flash`
* Context window and max output: keep the defaults if you are unsure

<img src="https://mintcdn.com/hai-token/VEsEJoBleYGPGfir/images/trae/PixPin_2026-07-08_18-11-40.png?fit=max&auto=format&n=VEsEJoBleYGPGfir&q=85&s=04c522c1cdb0db28ebf69cfa8544cc80" alt="Fill the Trae Work custom model form" width="1175" height="827" data-path="images/trae/PixPin_2026-07-08_18-11-40.png" />

### Step 5: Add the model and enable it

Click **Add Model**.

If Trae Work reports a successful connection, the model should appear in the model list. Make sure it is enabled and switch to it in the chat UI.

## Verification

1. Open the Trae Work chat panel.
2. Switch to the HaiToken-backed model.
3. Send a simple test prompt such as `hi` or `Explain what this file does`.
4. If the reply returns normally, the integration is working.

## Notes

<Note>
  If you are using base-address mode in Trae Work, enter `https://api.haitoken.ai/v1`. If you are using Full URL mode, enter `https://api.haitoken.ai/v1/chat/completions`. Do not mix the two modes.
</Note>

| Item                     | Value                                        |
| ------------------------ | -------------------------------------------- |
| Trae Work API format     | `OpenAI Chat Completions`                    |
| Actual HaiToken endpoint | `POST /v1/chat/completions`                  |
| Auth method              | `Authorization: Bearer YOUR_API_KEY`         |
| Model source             | The model ID you manually added in Trae Work |

Trae Work's official model documentation states that custom configuration supports both `OpenAI Chat Completions` and `Anthropic Messages`. For HaiToken, the OpenAI path is usually the most direct. [Official model docs](https://docs.trae.ai/ide/models)

## FAQ

### The request URL is reported as invalid

First check which mode you are currently using:

* If **Full URL** is off, enter `https://api.haitoken.ai/v1`
* If **Full URL** is on, enter `https://api.haitoken.ai/v1/chat/completions`

The most common mistake is mixing base-address mode and full-URL mode.

### 401 or authentication failed

Make sure the API key is valid. HaiToken uses OpenAI-compatible Bearer authentication:

```http theme={null}
Authorization: Bearer YOUR_API_KEY
```

### model not found

Make sure the model ID in Trae Work exactly matches a model ID returned by HaiToken.

### The model was added but does not appear in the chat UI

Go back to the model management page and confirm the model was added successfully and is enabled.

If it still does not show up, reopen the model list or restart Trae Work once and check again.

## Next

* See [Get API Key](/docs/en/quickstart/get-api-key)
* See [OpenAI format API](/docs/en/api-reference/chat/openai-format)
* See [List models](/docs/en/api-reference/models/list-models)
